Guides

Scripts and CI

peel keeps results on standard output and errors on standard error, with one exit code per failure kind, so a script never has to parse prose.

Peel 1.4.0 · Snack Studio · Updated

Conventions

for f in demo.zip locked.zip damaged.zip missing.zip; do peel test -q "$f" 2>/dev/null; echo "$f: exit $?"; done
demo.zip: exit 0
locked.zip: exit 3
damaged.zip: exit 5
missing.zip: exit 11
Real output from peel 1.4.0, recorded 2026-11-26.

Pass -j and you get the error as data:

TerminalShell
peel test -j damaged.zip
Text
{"error":"damaged","detail":"test damaged.zip: zip error: invalid Zip archive: Could not find EOCD: invalid Zip archive: Could not find EOCD"}

The detail text changes between releases. Match on error and the exit code.

Some commands exit 0 on a negative result. peel assess and peel find-originals report a finding, not a failure. peel unlock exits 0 even when it recovered nothing. Read the JSON field (feasibility, entries_matched, recovered) for those. See the recover guide.

JSON and jq

Most read commands take -j: list, inspect, probe, test, assess, find-originals, salvage, repair and extract. These recipes were run against the demo archives.

TerminalShell
# Files only, one per line
peel l -j demo.zip | jq -r '.[] | select(.is_dir | not) | .name'

# Total uncompressed size of the files
peel l -j demo.zip | jq '[.[] | select(.is_dir | not) | .size] | add'

# One-line summary
peel inspect -j demo.zip | jq -c '{format, entries: (.entries | length), total_uncompressed_bytes, has_encrypted_entries}'

# Did every entry check out?
peel test -j demo.zip | jq -e '.ok'

# What was written
peel x demo.zip -o out -j | jq -r '.extracted[]'

jq -e sets jq’s own exit status from the value, so .ok works as a test in if. Locked archives get the same treatment. This is the output of peel assess -j, trimmed with jq:

peel assess -j locked.zip | jq '{feasibility, scheme: .encryption.scheme, verdict: .recovery_contract.verdict.class}'
{
  "feasibility": "uncertain",
  "scheme": "zip-aes",
  "verdict": "no_practical_path"
}
Real output from peel 1.4.0, recorded 2026-11-26.

Progress events

--ndjson-progress writes one JSON event per line to standard error during extract, at most about ten a second. Standard output keeps the result.

peel x demo.zip -o events --ndjson-progress > /dev/null
{"phase":"extract","entries_done":0,"entries_total":11,"bytes_done":0,"bytes_total":null,"current_entry":null,"destination":"events"}
{"phase":"extract","entries_done":11,"entries_total":11,"bytes_done":32550,"bytes_total":32550,"current_entry":null}
{"phase":"extract","entries_done":11,"entries_total":11,"bytes_done":32550,"bytes_total":32550,"current_entry":null}
{"phase":"done","entries_done":11,"entries_total":11,"bytes_done":0,"bytes_total":null,"current_entry":null}
Real output from peel 1.4.0, recorded 2026-11-26.

The fields are phase (extract, then done), entries_done, entries_total, bytes_done, bytes_total and current_entry. The first event also carries destination. bytes_total can be null while the total is unknown. The same event can repeat. Treat the stream as a state, not a log.

A failure arrives on the same stream as {"error": …}. Split the two with has("error"):

TerminalShell
peel x -q "$archive" -o out --ndjson-progress 2>&1 >/dev/null \
  | jq -r 'if has("error") then "error: \(.error)" else "\(.entries_done)/\(.entries_total)" end'

2>&1 >/dev/null sends standard error down the pipe and discards standard output. The order matters, and it is written for bash. Add -q, as above, to keep the human summary off standard error. Only extract emits progress today. peel test --ndjson-progress prints its normal result and no events.

Passwords

Give the password through a pipe, so no other process can read it:

TerminalShell
# From the macOS keychain
security find-generic-password -s backup -w | peel x locked.zip -o out --password-stdin

# From a file descriptor
peel x locked.zip -o out --password-fd 3 3< <(security find-generic-password -s backup -w)
printf 'correct horse battery staple' | peel test locked.zip --password-stdin
OK   Zip  11 entries, 8 verified, 0 unchecked  locked.zip
Real output from peel 1.4.0, recorded 2026-11-26.

Both drop one trailing newline. A wrong password exits 4, and a missing one exits 3, so a script can ask again instead of giving up:

TerminalShell
peel x -q locked.zip -o out --password-stdin <<< "$guess"
[ $? -eq 4 ] && echo "wrong password, try the next one"

Avoid the alternatives. -p and --password show the password in the process list. PEEL_PASSWORD is visible to other processes of the same user while peel runs (ps eww). It is fine for a throwaway test and not for a secret you care about. Never put a password in a CI log. Use the CI system’s secret store and pipe it in.

Many archives

Test a set and keep going after the first failure, then fail the script at the end:

TerminalShell
shopt -s nullglob
status=0
for f in release/*.zip release/*.7z; do
  if ! peel test -q "$f"; then
    echo "bad archive: $f" >&2
    status=1
  fi
done
exit $status

nullglob makes an unmatched pattern expand to nothing instead of the literal text. Quote "$f" for names with spaces. peel takes one archive per call, so loop. Collect a report the same way:

TerminalShell
for f in *.zip; do
  peel assess -j "$f" | jq -c --arg f "$f" '{file: $f, feasibility, scheme: .encryption.scheme}'
done
Text
{"file":"demo.zip","feasibility":"plausible","scheme":"none"}
{"file":"locked.zip","feasibility":"uncertain","scheme":"zip-aes"}

Test archives in CI

peel test reads every entry to the end and checks it against the format’s own checksums. It writes nothing. Exit 0 means every entry passed, 1 means some entries failed, 5 means the archive cannot be read, and 3 and 4 are password errors.

peel test corrupt.zip; echo "exit $?"
BAD  Zip  11 entries, 7 verified, 0 unchecked  corrupt.zip
  FAIL project/README.md: io error: corrupt deflate stream
peel: 1 of 8 entries failed
exit 1
Real output from peel 1.4.0, recorded 2026-11-26.

With -j, the failures are data: {"ok": false, "verified": 7, "entries": 11, "failures": [{"name": "project/README.md", "error": "io error: corrupt deflate stream"}]}. The counts say how much was verified: verified entries had a checksum, and readable_only entries were read without one.

GitHub Actions

GitHub ActionsYAML
name: archives
on:
  pull_request:
    paths: ["release/**"]
concurrency:
  group: archives-${{ github.ref }}
  cancel-in-progress: true
jobs:
  test-archives:
    runs-on: macos-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install peel
        run: |
          curl -fsSL https://filesunwrapped.com/developers/install.sh | sh -s -- --prefix "$HOME/.local"
          echo "$HOME/.local/bin" >> "$GITHUB_PATH"
      - name: Test every archive
        env:
          ARCHIVE_PASSWORD: ${{ secrets.ARCHIVE_PASSWORD }}
        run: |
          shopt -s nullglob
          status=0
          for f in release/*.zip release/*.7z; do
            printf '%s' "$ARCHIVE_PASSWORD" | peel test "$f" --password-stdin || status=1
          done
          exit $status

What the install script does, from its source: it picks the release, downloads the tarball, checks its SHA-256 and aborts on a mismatch before extracting anything, then copies peel into PREFIX/bin. It never calls sudo. With no --prefix it uses /usr/local if writable, otherwise ~/.local. If no Rind release exists yet, it installs the peel binary from the newest Peel app release on macOS. Use macOS runners: that is the platform Peel supports today. --with-lib also installs libpeel and peel.h.

An archive that is not password-protected ignores the piped password. If your set mixes both, drop --password-stdin for the open ones.

Completions and the man page

TerminalShell
peel completions zsh  > ~/.zfunc/_peel                                  # fpath must include ~/.zfunc
peel completions bash > ~/.local/share/bash-completion/completions/peel
peel completions fish > ~/.config/fish/completions/peel.fish
peel man > peel.1 && man ./peel.1

peel completions also takes elvish and powershell. peel man prints the peel(1) page as roff on standard output. The Mac app bundles both.

Capabilities

peel reflect prints the engine’s capability index as one JSON document in an rr-rsp-0.1 envelope. It has schema_version, subject_id, a provenance block naming the engine version, and a body. The capability ids in this build are listed by:

TerminalShell
peel reflect | jq -r '.body.descriptor.capabilities[].id'
Text
inspect list read_member probe assess find_originals extract repair diagnose formats

Each capability has a description, endpoint, inputs and outputs. Use it to check that a binary offers what a script needs before calling it. --sign signs the document with an Ed25519 key for this installation, and creates that key on first use.

Diagnose for bug reports

peel diagnose builds a report that is safe to share. It says it contains no file names, paths or contents.

peel diagnose demo.zip
Peel diagnostic report — safe to share (no file names, paths, or contents)
  Peel 1.4.0 · macOS 27.2.1
  format zip · 2424 bytes · 11 entries
Real output from peel 1.4.0, recorded 2026-11-26.

With -j it gives os, peel and a report with format, size, entries, error_kind and findings. For an archive that will not open, error_kind is the same kind as the exit code table, such as damaged. Attach the output to the bug report.