For AI agents: the complete documentation index is available at https://docs.phax.run/llms.txt, the full documentation bundle is available at https://docs.phax.run/llms-full.txt, and this page is available as Markdown at https://docs.phax.run/guide/run.md.

Running a plan

Run a plan

phax run --plan docs/plans/2610041201-greet-plan.md
phax run greet --plan <plan>          # name the run you expect: a name other than the plan's is refused
phax run --plan <plan> --dry-run      # show what would run, change nothing
FlagEffect
--allow-dirtyrun from a working tree with uncommitted changes
--security <mode>override the security mode for this run
--provider-priority <a,b>override which providers to prefer, for this run
--allow-skill-editslet phases edit the .claude/skills files the plan declares
--refreshextract the plan again instead of using the cache

A plan under docs/plans/ must be Approved and fresh: a Draft, Stale, Completed or Abandoned plan, or one whose spec, own text or planned files changed since its approval, is refused with exit 12 before anything runs. Before naming the run, phax checks everything it can without it: the commands the plan needs, each phase's model, the MCP and records settings, a clean working tree. A refused run leaves nothing behind, and trying again gets the same name.

Then, for each phase:

  1. A worktree under ~/.phax/worktrees/, on the branch phax/<name>--phase-NN, branched from the previous phase.
  2. commands.setup runs in it.
  3. The agent gets the phase's instructions, the previous phase's handoff and how that phase deviated from its plan.
  4. The gate runs; on failure, the same agent session gets the failure and tries again, up to agent.maxFixAttempts.
  5. The agent writes the phase's handoff.
  6. phax commits with the planned message, then compares the files changed with the files planned (file-reconciliation.json in the phase's folder).

A phase that changes nothing stops the run (exit 9). The last phase runs the gate's terminal steps too, then the run stops at review_open. Its plan is completed on the run's branch, and its spec too when the plan says it is the spec's last (completes-spec: true) and no other live plan still needs it. The run's folder is ~/.phax/runs/<namespace>.<name>/; when the run ends, phax prints what happened and the next command to run. On a Mac, keep it awake for long runs: caffeinate -ims phax run --plan <plan>.

The phase commit

A phase commit is the planned subject and body, then a --- line and these trailers, in this order:

  • Run-Id and Short-Name: the run, and its short name.
  • Phase-Id and Phase-Title: the phase. phax records explain and the release notes find a phase's commits by them.
  • Model and Effort: what the phase ran on.
  • Gate-Log: the log of the gate attempt that let the commit through, as a path relative to the run's folder (phase-02/checks-attempt-01.log), or none when no attempt is recorded.

A commit made when a stop is closed carries fewer trailers. A declared interactive phase's commit carries Run-Id, Short-Name, Phase-Id, Phase-Title, Interactive-Phase and Gate-Log: no Model or Effort, since no agent session wrote the correction. A held stop's review commit carries Run-Id, Short-Name, Phase-Title, Held-Phase and Gate-Log (phase-03/review-gate/checks-attempt-01.log): no Phase-Id, Model or Effort, since the phase commit it sits on keeps its own; it is found by Run-Id and Held-Phase.

No trailer names a path outside the run's folder, and none carries a provider session.

Commits written by earlier versions may also carry Worktree:, a Gate-Log: holding an absolute path, and Session-Id:. Closing a stop still reads such a Gate-Log. phax never rewrites history: cleaning older commits is your choice, on your own branches. git filter-repo --message-callback and git filter-branch --msg-filter can drop those lines from commit messages; read their documentation first, and do not rewrite a branch others have pulled.

When a run stops

phax resume <run> --yes               # continue from the next phase, or finish a committed phase's cut-short handoff (without --yes: a preview)
phax resume <run> --yes --provider-priority codex-cli,claude-code
phax reset-phase <run> [phase-id] --yes  # throw a stuck phase's worktree away so resume starts it over
phax enter-phase <run> <phase-id>     # open that phase's agent session
phax session-info <run>               # state, phase, worktree, agent session id
phax unlock <run>                     # remove a stale lock left by a process that died

resume never re-runs a committed phase's work; it only runs that phase's handoff turn again when the turn was cut short. A run stopped by a provider rate or usage limit (exit 8), by a phase with no changes (exit 9) or at an interactive phase (exit 13, see Interactive phases) is meant to be resumed. A run already at review is not resumed: use phax enter.

A phase that committed but whose handoff turn was cut short (a rate or usage limit) gets its handoff written first: phax resume runs the handoff turn again in that phase's session and worktree, then goes on. When that worktree is gone, resume refuses with exit 1 and names the commands that restore it, git worktree prune then git worktree add <worktree> <phase branch> (git keeps a deleted worktree registered until it is pruned); when the session id is gone, it names the phase-handoff.md file to write by hand. After a handoff written by hand, the next phax resume finishes that phase without an agent turn: it collects the phase's pulled briefs, writes its record and runs its cleanup, then goes on to the next phase. When that phase's worktree is gone as well, its cleanup commands do not run and the phase is still cleaned up; phax warns and names them, so run them yourself if they free resources outside the worktree. The final message counts every phase of the run that committed, across resumes.

Without --yes, phax reset-phase previews the reset, and it applies the same refusals of the run's state as --yes, with the same message and exit 1. (Only --yes takes the run lock, so a held lock is refused there alone, with its own exit code.)

Interactive phases

A plan can ask for a person to review the work after a phase, before the phases that repeat its pattern begin. Say so on the phase, after its model, effort and assignment-reason lines:

## phase-02 — Invoice export, the first exporter \{#phase-02-invoice-export}

**Recommended model:** claude-sonnet-5-5
**Recommended effort:** medium
**Mode:** interactive

Declare one directly after the first phase that sets a pattern, never by default. It plans no file to create or edit: its optional files name what the person may touch, and its instructions name what to review. It is never the first or the last phase, and never directly follows another interactive phase. One may sit between the two phases of an acceptance pair, and takes no acceptance role.

When phax run reaches the phase, it sets up the worktree as for any phase, writes a seed into .phax-context/ (the phase's instructions, the handoffs so far and the plan's later phases) and runs one read-only first turn: the agent reads the work and reports the pattern it found. Then the run stops with the state awaiting_review, writes review-stop.json in the run folder and exits 13. It does not wait for input, so the person can leave and come back. The output names the worktree, the first reading and a command that continues the agent session phax started (or starts a fresh one when there is none to continue):

cd ~/.phax/worktrees/phax.invoice-export/phase-02 && claude --resume 6f1c… --permission-mode acceptEdits …

The command carries the phase's filesystem, network and MCP posture, but a step outside it asks you first. The first time codex opens the worktree, it asks you to trust the directory, then to review its hooks. You can also work by hand, in any editor, or with any other agent.

phax ls --awaiting-review                # the runs waiting for a person, with the stopped phase
phax session-info invoice-export         # the stop's worktree, seed and current session
phax enter-phase invoice-export phase-02 # continue the session, or start a fresh one
phax enter-phase --new-session invoice-export phase-02   # a new read-only first turn; its session becomes current
phax path invoice-export                 # phax shell and phax open take the same worktree

phax path, phax shell and phax open target the stopped phase's worktree. While the stop's close is running, enter-phase refuses the phase until the close ends.

To close the stop, run phax resume invoice-export --yes from the main checkout. phax:

  1. runs the phase's gate first. A red gate returns the phase to you (exit 4): fix the worktree, resume again;
  2. takes the handoff: your .phax-context/correction-handoff.md when it exists, with the sections ## What was corrected, ## The pattern to follow from now on, ## Guards and ## What the next phases need to know (one guard per correction); otherwise a read-only closing turn writes it from the diff of your corrections. A closing turn that edits the worktree is refused (exit 5): its edits are set aside in the phase's refused-turn-NN/ folder and the worktree put back to the tree the gate passed. An answer still invalid after one corrective resume is refused too (exit 5);
  3. commits exactly the gated tree, with an Interactive-Phase: <phase-id> trailer and no model or session trailers, because no agent session wrote it. A review that changed nothing commits an empty commit;
  4. continues with the next phase, whose prompt carries your correction under ## Review corrections, after the previous phase's handoff.

Leave your corrections uncommitted: phax commits the gated tree itself. A commit you make in the stopped worktree is refused (exit 1) with the git -C <worktree> reset --soft <base> that keeps its changes uncommitted; phax never rewrites the history itself.

A refused close puts the run back to awaiting_review; so does an interrupt during the close. phax reset-phase at a stop discards the phase's worktree so that phax resume runs it again, first turn included. phax archive --force archives the run. phax adjust-plan --landed is refused until the run lands.

A user interface reads review-stop.json for the stopped phase, its worktree, the current session, the last refused close and the commands above, each as { cwd, argv, env }; its format is under Persisted formats.

Holding a run

A plan declares a stop for a review it always wants. When you want one only on this run, hold it:

phax run --plan plan.md --hold                       # every headless phase but the final one
phax run --plan plan.md --hold phase-02,phase-04     # the phases listed
phax run --plan plan.md --hold acceptance            # the acceptance phases

Prefer a declaration for the review the plan is built around, directly after the phase that sets a pattern. Prefer --hold for a look you decide on at run time: a risky phase, a first run of a new plan, or the acceptance tests of a pair. The selection is fixed for the run and recorded with it: phax resume takes no --hold, and no configuration key sets one. A bare --hold takes the next word as its value, so put the run's name before it or write --hold=<selection>. A malformed value exits 1; a selection the plan cannot honour (an unknown, interactive or final phase) exits 11 with Hold preflight failed. The final phase never holds, because it is already kept open for review. phax run --dry-run prints the resolved hold as Hold: none or Hold: listed — phase-02, phase-04.

For example, phax run --plan plan.md --hold phase-02 on the invoice-export plan runs phase-02 like any phase: its agent works, its gate passes, it commits and its handoff is validated. Then, before its record and its cleanup, and with no agent turn, the run stops in awaiting_review (held), writes review-stop.json and exits 13. It does not wait for input.

You review the phase by hand, with any agent, or by continuing the builder's own session, which is the default of phax enter-phase invoice-export phase-02. phax enter-phase --new-session starts a fresh read-only look instead and makes its session current. phax ls, phax session-info, phax path, phax shell and phax open work as at a declared stop; session-info names the phase headless, committed <short sha>.

phax resume invoice-export --yes closes a held stop. phax:

  1. runs the phase's gate first; a red gate returns the phase to you (exit 4);
  2. takes the correction handoff: your .phax-context/correction-handoff.md, or a closing turn that resumes the builder session and writes it from the diff of your corrections. The handoff lands beside the phase's own phase-handoff.md, which stays as the builder wrote it;
  3. leaves one review commit on top of the unchanged phase commit, with a Held-Phase: <phase-id> trailer and you as author, or no commit when nothing changed;
  4. writes the phase's record once, runs its cleanup and starts the next phase from the branch tip in the same invocation. The next prompts carry your corrections under ## Review corrections, after the held phase's own handoff.

Leave your corrections uncommitted. A commit of your own in the stopped worktree is refused (exit 1) with git -C <worktree> reset --soft <phase commit>, which keeps its changes uncommitted. phax reset-phase at a held stop discards the phase commit and the phase's worktree; the phase runs again and is held again when it commits.

The closing turn resumes the builder read-only, on every provider: Claude Code with its reading tools and no shell, Mistral Vibe with only read_file and grep in the worktree alone (phax refuses the turn's result if the resumed session ran under another agent than accept-edits, which Vibe can restore on a resume), codex with exec resume under sandbox_mode=read-only and approval_policy=never. On codex, the read-only override is the provider's to honour: codex merges a rollout's persisted permissions on resume, so a builder that ran with workspace-write may keep it. phax compares the worktree after every turn, but cannot see a write outside it.

The phase's record is written at closing, once. It names the builder's provider, model, effort and session, the phase commit as its source, and the review commit as part of the stop. Its usage is the builder's, read when the run stopped, so it leaves out the closing turn on every provider. See The record of a stop. A resume finishes a hold or a close that was interrupted: a held phase that committed but did not stop stops then, and a close that landed but did not clean up runs its cleanup, writing the record only if the phase has none.

Reviews inside an acceptance pair

A stop, held or declared, may sit between the two phases of an acceptance pair, and --hold acceptance is how you review the acceptance tests before they are passed. When your corrections change an acceptance test file, the close runs the acceptance provider's authored verdict again as the last step of its gate. The passing phase then judges the latest commit of the pair that passed authored. A held passing phase closes on its configured steps only, with a warning for each acceptance test file your corrections changed, because the acceptance provider does not see the change. phax resume --skip-acceptance is refused at a stop.

Who closed the stop, and the transcripts

A close reads your identity first, from the main checkout's git configuration (user.name and user.email, or author.name and author.email when set). An unset identity refuses the close with exit 1 and the run stays in awaiting_review: run git config user.name and git config user.email, then resume. The identity is written in the stop, with the cause and outcome.

Before it commits, the close copies the transcript of each session it recorded into the phase folder: <run>/<phase>/interactive-transcripts/<session id>.jsonl. The recorded sessions are the builder (at a hold), each first turn that answered and every --new-session session. A closing turn that started its own session is not one of them; its stream stays in the phase folder as closing-turn-NN.jsonl. A copy is written with mode 0600 in a folder with mode 0700, because a continued session may hold secrets you typed. A transcript phax cannot find or read is not an error: the close records it as missing, with the reason not-found or unreadable. A copy that cannot be written refuses the close, and the next close copies again.

The record of a stop

A stop writes its phase's record at closing, once, declared or held. The record names:

  • the mode (headless or interactive) and the stop's cause (declared or held);
  • the outcome, corrected or unchanged, and who closed it;
  • for a held stop that you corrected, the review commit;
  • each recorded session with its provider, model, effort, origin (first-turn, new-session or builder) and its transcript's sha256, or missing with its reason.

A declared phase's record names the phase's routed provider, model and effort, the declared commit as its source, and no token usage, because no agent session built the phase. A held phase's usage is the builder's, read when the run stopped. If the records destination refuses the write, the run pauses (exit 1) and phax resume writes the record again once the destination accepts it.

phax records explain <commit> takes a phase commit, a declared commit or a held phase's review commit, and shows the stop's lines beside the usual ones. A review commit finds its record through its Run-Id and Held-Phase trailers.

An interactive transcript's content never reaches the records branch, whatever records.transcript says: a session you continued ran outside phax's enforcement and may hold secrets you typed, and a dedicated records repository faces no visibility check. The record carries the digest; the copy stays in the run folder, so only the run folder can replay what you and the agent said at a stop. output.jsonl, the stream of a headless phase phax ran, still follows records.transcript.

The security record

The phase's security.json has a stop section, null for a phase that never stopped. A close sets it to the cause, personWork: "outside-phax-enforcement", and one entry for each first and closing turn phax ran. Each entry names the turn, its kind, the narrowing it ran under (read-only-tools on Claude Code and mistral-vibe, read-only-sandbox on codex) and its agent commands, which are none. The other fields stay the posture the builder ran under, which your own work did not have. The record carries the file.

Review handoff, PR and run list

review-handoff.md gains a ## Reviewed phases table (Phase | Stop | Outcome | Closed by | Corrections | Guards), and each corrected stop a ### <phase> (<held|interactive>) section with what was corrected and its guards. The compliance reviewer reads the same section. The PR body's line for a stopped phase ends with · held, corrected by Ada Example (2 guards), · interactive, corrected by Ada Example (1 guard) or · held, reviewed without change by Ada Example. A run with no stop reads exactly as before.

phax ls --json prints one versioned run-list document, and each run embeds its review-stop document as stop (null for a run not waiting at a stop) and the URL of the pull request phax opened for it as pullRequest (null when it opened none). Together with review-stop.json, it is what a review UI reads:

{
  "$schema": "https://…/run-list/…",
  "runs": [
    {
      "qualifiedName": "example.invoice-export",
      "namespace": "example",
      "shortName": "invoice-export",
      "state": "awaiting_review",
      "branch": "phax/invoice-export",
      "currentPhase": "2/6",
      "gateProfile": "standard",
      "updatedAt": "2026-10-24 09:30",
      "lockState": "none",
      "recordsPending": null,
      "archivePath": null,
      "stop": { "$schema": "https://…/review-stop/…", "…": "…" },
      "pullRequest": "https://github.com/example/invoices/pull/12"
    }
  ]
}

A script that read the old bare array now reads .runs[]; see upgrading. A run being closed lists running with stop: null.

The cost ledger covers Claude Code invocations, for every phase, and also counts the compliance and code review sessions; a stop's first and closing turns on Claude Code are in it like any other turn. phax plans estimate sizes an interactive phase from those turns.

What phax reads from a provider's session store

At closing, phax reads only what it needs from each provider's own store. The roots are ~/.claude and ~/.codex, moved by CLAUDE_CONFIG_DIR and CODEX_HOME (an empty variable counts as unset). phax reads no session from Mistral Vibe's home.

  • What it reads at closing: the transcript file of each recorded session, and nothing else. Claude Code: projects/<slug>/<session id>.jsonl, where the slug is the worktree's path with every character outside A-Z a-z 0-9 replaced by -. When that misses, it tries the slug of the worktree's real path (/var/… is /private/var/… on macOS). When both miss, phax lists the names under projects/ and tries <name>/<session id>.jsonl in each. Codex: sessions/YYYY/MM/DD/rollout-*-<session id>.jsonl, listing the date directories' names.
  • Mistral Vibe: nothing. The answer, session id, usage and transcript come from the turn's stream and from the export.json Vibe writes into the turn's own output directory, beside the stream. A session you ran in Vibe's TUI therefore has no transcript.
  • What it never reads: a provider's credentials or configuration.
  • Where the copies go: the run folder only. They never enter a commit or a record.
  • Session ids that are not made of letters, digits, ., _ and - are refused before any path is built.

See what it is doing

phax run --plan <plan> --verbose      # print phax's events as they happen
phax run --plan <plan> --trace        # and write them to semantic.jsonl in the run folder
phax report <run>                     # open a GitHub issue from the run's telemetry (a secret gist holds the log)

phax records its events for every run (state changes, agent calls, gate results); turn that off with "enabled": false in ~/.phax/telemetry.json. docs/observability.md has the details.