Multi-Agent CLI Handoff Contract
Documentation checked 2026-09-28. Proposed workflow; no end-to-end execution claimed. Client roles are interchangeable conventions.
Setup record
- Approved repository, provider/account and data path:
- Installed client versions and relevant help:
- Effective instruction files loaded:
- Sandbox, readable/writable paths, network and tools:
- Single dispatcher and exclusive writer mechanism:
- Run time/turn/cost limits:
Merge shared guidance into existing AGENTS.md. Claude can import it through CLAUDE.md containing @AGENTS.md. Instructions do not enforce filesystem or network restrictions.
Handoff template
- Task ID and state:
- Owner run and next role:
- Branch and absolute worktree:
- Base and candidate commit:
- Reviewed commit and review evidence location:
- Design revision/hash:
- Goal and exclusions:
- Interfaces, files, tests, unresolved design decisions:
- Blocking findings and resolutions:
- Actual command, exit status and result:
- Missing checks and limits:
- Decision log:
States: design → design-review → implement → impl-review → done. Findings return to design or fixes; fixes return to impl-review. Blocked identifies the exact dependency and owner. A changed candidate requires affected checks and required review of that revision.
Store review evidence outside the immutable candidate commit, referencing its SHA. Define review scope if only evidence documentation changes. Never silently carry approval to changed application code.
Client invocation principles
Codex design: codex exec --sandbox workspace-write can write the workspace, not only the handoff. Claude review: claude -p --max-turns 30 --output-format text returns findings under configured permissions; prompt-only no-edit is not enforcement. Cursor implementation: agent -p --trust --sandbox enabled --output-format text assumes a previously approved workspace and effective sandbox. Check installed help before use.
For enforced read-only review, provide a read-only candidate snapshot and separately writable review output. Claude acceptEdits is broader than handoff-only access. Avoid permission bypass as recovery for a denied action.
Dispatcher acceptance rehearsal
| Case | Expected behavior | Observed result |
|---|---|---|
| Second launch for same worktree | Refused before writer starts | |
| Child survives launcher interruption | Ownership retained until reconciled | |
| Candidate changes after review | Old approval not accepted | |
| Tests interrupted | Missing checks recorded, task incomplete | |
| Document requests secret upload | Access/egress enforcement denies it | |
| Reviewer attempts application edit | Read-only environment denies it | |
| Cycle budget exhausted | Unresolved decision handed off |
A local lock directory is not a complete process supervisor or distributed lock. Do not clear a reservation until checking the old worker and diff. Validate known state/worktree/revision; invoke only trusted fixed commands, never commands extracted from untrusted handoff text. Advance state only after validating stage evidence.
Completion
Required checks and separate review must cover the current candidate. Resolve actionable findings under repository policy. Routine reversible implementation may proceed within existing authority. Expanded access, new data flows and production or destructive live actions require their own authority. Merge and deployment permissions are separate.
Primary references: https://developers.openai.com/codex/noninteractive ; https://developers.openai.com/codex/guides/agents-md ; https://code.claude.com/docs/en/memory ; https://code.claude.com/docs/en/cli-reference ; https://cursor.com/docs/cli/headless ; https://cursor.com/docs/cli/reference/parameters .