Running a plan
Run
Each phase:
- Creates a Git worktree at
~/.phax/worktrees/<short-name>/phase-NN/on its own branch<run.branch>--phase-NN. - Runs
commands.setupinside the worktree. - Builds a prompt from the plan and the previous phase's handoff, sends it to the selected provider's agent (resolved by the routing layer; see Multi-provider model routing).
- Runs the gate profile; on failure, resumes the same agent session once and retries.
- After passing gates, resumes the agent to produce
phase-handoff.md. - Commits with the planned message. If the worktree is clean (no changes), the run stops with a non-zero exit and writes
resume-instructions.md— usephax resumeto continue from the next phase. - Reconciles the files actually touched against the phase's planned files, writing
file-reconciliation.{json,md}to the phase folder. Deviations (unplanned creates/edits, missing planned changes) are injected into the next phase's prompt so the agent sees how the prior phase diverged from its plan; withfileReconciliation.mode: "warn"they are also logged (defaultreport_onlyonly records them).
Each phase gets its own branch (<run.branch>--phase-01, <run.branch>--phase-02, …), chained: phase-01 branches off <run.branch>, phase-N branches off the previous phase's branch. The base <run.branch> stays at the run-start commit. The final phase's branch carries the full commit chain and is the ref to review, merge, or push.
Worktrees from every phase persist on disk for the lifetime of the run and are available for inspection until phax archive is run.
The final phase stays open for review. A review-handoff.md is written to the run folder showing the final phase branch as the review target. When the run reaches review, two optional steps run automatically if enabled in phax.json (both are non-fatal — the run stays review_open if they fail):
- Compliance review (
review.compliance.enabled) — a non-mutating plan-compliance pass writes its verdict to the run folder, so it can land in the PR body. - Publish (
publish.auto) — pushes the final phase branch to the configured remote and opens (or reuses) a pull request; details are recorded inpublication.json.
See Compliance review & publishing.
When phax run finishes (or is interrupted), it prints an end-of-run recap to the terminal summarizing the run state, the review target branch, any published PR URL, and the next command to run.
macOS sleep prevention — long-running phax run sessions can be wrapped with
caffeinate to prevent macOS from sleeping while phax executes:
Resume
Resume validates the run state, lock, and worktree before proceeding. It never re-runs committed phases. If the run is review_open, it refuses and points you at phax enter.
Locks
phax writes a lock file at ~/.phax/locks/<short-name>.lock for every active run. If a process dies, the lock can become stale: