Skip to content
$ shellfirm

Replay agent sessions

See what shellfirm would have blocked or asked about in your past Claude Code and Codex CLI sessions, without running anything.

shellfirm audit replay answers "what would shellfirm have done in my earlier agent sessions?" without running anything. It reads the session transcripts coding agents already keep on disk, finds every shell command and file operation the agent ran, and judges each one exactly as that agent's hook (shellfirm check --hook claude-code / --hook codex) would have: with the working directory recorded for the call, your agent settings (agent.auto_deny_severity, require_human_approval, ignores, denies) and the project policies (.shellfirm.yaml, org policy) that apply there.

Codex CLI cannot ask, so, as in its hook, an ask for a Codex command or file edit is reported as deny; an edit of only agent instruction files (AGENTS.md, …) is an allow, as Codex lets it through with a note. Each file an apply_patch patch touches is judged on its own, also when the patch is run through the shell (by Codex, by a Claude Code Bash call, or inside bash -lc "…"). The settings are checked as check does: an invalid settings.yaml prints shellfirm: warning: invalid settings file … on stderr, and the built-in defaults are used.

Run it before you connect a hook to see what the hook would catch, or after, to check sessions from before it was installed.

shellfirm audit replay                              # last 7 days, every agent
shellfirm audit replay --since 30d --min-severity high
shellfirm audit replay --agent codex --project ~/work/api
shellfirm audit replay --redact                     # rule ids and reasons only
shellfirm audit replay --since all --json | jq 'select(.type == "finding")'
shellfirm audit replay --since 24h --fail-on deny   # exit 11 when a deny is found

The report

Output
shellfirm audit replay — last 7d (since 2026-11-12T19:37:12Z)
  Claude Code   2 sessions, 4 commands, 1 file operation  (~/.claude/projects)
                skipped: 2 malformed lines
  Codex CLI     1 session, 2 commands, 0 file operations  (~/.codex/sessions)
                skipped: 1 compressed rollout not read

Decisions: 4 deny, 1 ask, 2 allow

Would have blocked or asked (4 findings, worst first):

  DENY [CRITICAL] fs:recursively_delete +1 ×2
       2026-11-19 19:07  claude-code  ~/work/app
       This deletes a critical location: the filesystem root, your home directory, a system directory, the repository, or everything in the current directory.
       $ rm -rf /

  DENY [CRITICAL] fs:recursively_delete +1
       2026-11-19 19:25  codex  ~/work/app
       This deletes a critical location: the filesystem root, your home directory, a system directory, the repository, or everything in the current directory.
       $ rm -rf /

  DENY [HIGH] git:force_push
       2026-11-19 19:10  claude-code  ~/work/app
       This force-pushes and can overwrite remote history.
       $ cat <<'EOF' > notes.txt hello EOF git push --force origin main

  ASK  [HIGH] shellfirm-self:rc_file_edit
       2026-11-19 19:27  claude-code  ~/work/notes
       Edits a shell startup file (where the shellfirm shell hook is loaded)
       Write ~/.bashrc

Read-only: nothing was run, sent or written (shellfirm's audit log included).
Next: `shellfirm connect claude-code` has shellfirm decide these before they run.
Next: `shellfirm connect codex` has shellfirm decide these before they run.

The report starts with the window and, per agent, the sessions, commands and file operations read (plus anything skipped), then the deny / ask / allow totals, then the findings worst first: deny before ask, then severity, then how often. Identical calls in the same project are grouped (×N). Each finding shows when it last happened, the agent, the project, the decision, the most relevant rule (+N more matched: the most severe, and among equally severe rules the most specific, so fs:delete_home_folder before fs:recursively_delete_outside), its severity, the rule's full description and the command, cut to one line.

  • Secrets are hidden. Secrets in commands and paths are replaced with ***, as in the audit log (Secret redaction), with or without --redact. Control characters in commands and project paths are escaped.
  • Older sessions. When some of an agent's sessions are older than the window, the header says so: 1 older session not read (use --since 30d or --since all).
  • Next step. The report ends with how to have shellfirm decide such calls live (shellfirm connect claude-code / codex), or, when that agent's hook is connected at user scope, that new sessions get these decisions.

With no transcripts in the window:

Output
shellfirm audit replay — last 7d (since 2026-11-12T20:29:32Z)
  Claude Code   no transcripts found
  Codex CLI     no transcripts found

Decisions: 0 deny, 0 ask, 0 allow

Nothing shellfirm would have blocked or asked about.

Options

OptionMeaning
--since WHEN24h, 7d, 30d, 2w, a date or timestamp, or all (as in audit show). Default 7d: a week of sessions is what you remember, it reads quickly, and Codex CLI compresses rollouts older than a week. An invalid or future value exits 2 (as for audit show). Calls without a valid timestamp (or with one in the future) are judged only with all, and counted in the header otherwise
--agent AGENTclaude-code, codex or all (default)
--project PATHOnly calls made in PATH or below it (a relative path is resolved against the current directory). A path that is not a directory, or an empty value, exits 2. Skipped lines are counted only for transcripts with calls in PATH
--min-severity LEVELList only findings at or above LEVEL (the totals still count every call)
-n, --limit NList at most N findings (default 25 in the text output, all with --json; 0 = all)
--jsonJSON lines: one {"type": "finding", …} object per finding, then one {"type": "summary", …}
--redactNo command text, file paths or session ids; the project is shown by its directory name only, for screenshots and bug reports. The same findings as without it
--fail-on DECISIONdeny: exit 11 when a deny was found. ask: also exit 10 when an ask was found. Counted after --min-severity, before --limit. Otherwise, when a transcript file or directory (the agent's folder, such as ~/.claude, included) could not be read, or a compressed Codex rollout in the window was not read, exit 66, so an unreadable source never passes silently. Whenever that happens, whatever the exit status, stderr says … the replay is incomplete
--config-dir DIRJudge with the shellfirm configuration in DIR

What is read

AgentTranscriptsCalls judged
Claude Code~/.claude/projects/<project>/*.jsonl and <session>/subagents/*.jsonl ($CLAUDE_CONFIG_DIR/projects when set; a relative value is resolved against the current directory, as connect does)Bash, PowerShell, Monitor commands; Write, Edit, MultiEdit, NotebookEdit edits; Read (judged like cat <path>, as the hook does)
Codex CLI~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl and ~/.codex/archived_sessions/ ($CODEX_HOME when set)exec_command, shell, shell_command and local_shell_call commands (bash -lc '<script>' is judged as the script); apply_patch edits (each file the patch adds, updates, deletes or moves to)

A call recorded twice (a resumed or forked session) is judged once. A file last changed before the window is not opened. Lines that are not valid JSON, lines over 16 MiB, shell and file calls whose input cannot be read or has the wrong shape (Codex arguments that are not JSON, {"cmd": 123}, a Claude Code Bash input without a command string), unreadable files and directories, compressed Codex rollouts (.jsonl.zst) and anything named like a transcript that is not a regular file (a FIFO, a device, a symbolic link, a folder: never opened) are skipped and counted in the header. An unreadable folder or a skipped compressed rollout makes the replay incomplete: stderr says so, and the JSON summary has incomplete: true. JSON escapes are decoded before a line is classified ("tool\u005fuse" is a tool_use). An apply_patch sent through the shell (["apply_patch", "<patch>"], apply_patch <<'EOF' … EOF, also inside bash -lc "…"), by Codex or by a Claude Code Bash call, is judged as the patch: each file it touches, as the hook does. A Read is judged as the hook judges it, also under a home or $CLAUDE_CONFIG_DIR the checks do not spell.

What replay does not do

Read-only

Nothing from a transcript is executed. No external program is started for context (git, kubectl, …: as with check --no-context), the LLM review is off, nothing leaves the machine, and nothing is written, not even shellfirm's audit log.

  • Decisions use today's state. Your current settings, policies and files decide, not the ones in effect when the agent ran the call. A path that was deleted since then no longer matches checks that need it to exist, and a working directory that is gone has no project policy. Impact details (blast radius) are not computed.
  • Calls the agent made through other tools (web, MCP servers, sub-agent launches) are not judged, as the hook does not see them either.

In CI or a script

--fail-on turns findings into an exit code, like check --exit-code:

shellfirm audit replay --since 24h --fail-on deny; echo $?   # 11 when a deny was found
shellfirm audit replay --since 24h --fail-on ask;  echo $?   # 10 for an ask, 11 for a deny

With --fail-on, a transcript file or folder that could not be read, or a compressed rollout in the window, exits 66 instead of passing (unless a deny or ask exit applies). stderr says … the replay is incomplete either way.

See Exit codes.

JSON output

Each finding line has type: "finding", agent, decision (deny / ask), severity, rule_id (the most severe rule), rule_ids, reason (that rule's description), deny_reason (when denied), subject (command, file edit or file read), tool, count, first_seen, last_seen and, without --redact, command or path (secrets replaced; command_redacted / path_redacted: true when one was), cwd, session_id and decision_reason; with --redact, project (the directory name) instead.

The last line has type: "summary", schema_version (1), since, until, agents (per agent: found, files, sessions, commands, file_operations, malformed_lines, oversized_lines, calls_unreadable, calls_undated, files_unreadable (files and directories), files_compressed, files_outside_window, crashed, and roots without --redact), totals (deny, ask, allow), incomplete (true when a transcript file or directory could not be read or a compressed rollout was skipped), findings (after --min-severity), shown (after --limit) and redacted.

# The rules that would have fired most, across every session
shellfirm audit replay --since all --json \
  | jq -r 'select(.type == "finding") | "\(.count)\t\(.rule_id)"' | sort -rn | head