Markdown

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

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

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

CaseExpected behaviorObserved result
Second launch for same worktreeRefused before writer starts
Child survives launcher interruptionOwnership retained until reconciled
Candidate changes after reviewOld approval not accepted
Tests interruptedMissing checks recorded, task incomplete
Document requests secret uploadAccess/egress enforcement denies it
Reviewer attempts application editRead-only environment denies it
Cycle budget exhaustedUnresolved 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 .