Skip to content
leonleePublic

About

Claude Code and Codex review each other's work.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

cc-pair

English | 中文

Abstract. pair lets Claude Code and Codex review each other's work, or their own: Claude can review Claude, and Codex can review Codex. One agent authors a change, the other reviews it, and they exchange messages through files in a shared directory. Roles are symmetric. In auto mode, pair start opens the author and runs a reviewer for each round. In manual mode, you run both agents yourself.

Features:

  • Two modes. Auto mode runs the author and starts the reviewer for each round, returning the review inline (Auto mode). In manual mode you run both agents, and an MCP server wakes Codex without polling (Manual mode).
  • Any pairing. Cross-vendor by default; same-vendor pairs and any named participants, such as alice and bob, in either mode (Participants).
  • Code review. Numbered findings with severity and an approve or changes verdict. Findings still open at the round cap escalate to you (Workflows).
  • Spec review. Plans and design docs in any format, such as a Markdown plan or an OpenSpec change; a later code review can cite the approved spec (Spec review).
  • Brainstorms. Ideas before there's a design, with a fixed turn budget and a closing summary of options and open decisions (Brainstorms).
  • Parallel work. Subagents in their own worktrees, each with its own review loop, up to N reviews at once (Parallel work).
  • Test evidence. pair test records a check with a fingerprint of the checkout, so the reviewer can credit it instead of re-running it (Test evidence).
  • Live reviewer settings. pair reviewer changes the reviewer's model or effort without a restart (Changing the reviewer).
  • Worktrees. One channel per worktree, so pairs run side by side; pair start --worktree creates or reuses one (Worktrees).
  • Recovery. Resumable author conversations, failed rounds that keep the request on disk for a retry, history, and reset (Author conversations, Maintenance).
  • Guard rails. Reviewers are read-only by instruction, nothing loosens their permissions, and the author can't pick its reviewer's model (Security considerations).
  • Small. One Node CLI with no runtime dependencies; the agents learn it from a Claude skill and an AGENTS.md section, and you ask in your own words.

A review thread, as it looks in manual mode (in auto mode, pair starts the reviewer for each round):

terminal A: claude                         terminal B: codex ("be my reviewer")
  finish task
  pair send request ──▶ ~/.pair/<repo>-<hash>/claude-to-codex/<thread>/001-request.md
  pair wait  ⏳                              pair wait ◀── picks it up
                    002-review.md ◀── pair send review --verdict changes
  verify findings, fix
  pair send response ──▶ 003-response.md
  pair wait  ⏳                              pair wait ◀── re-checks fixes
                    004-review.md ◀── pair send review --verdict approve
  done ✓

The key words MUST, MUST NOT, SHOULD and MAY are used as described in RFC 2119. DESIGN.md specifies the protocol, storage layout, supervision and known limits.

1. Terminology

  • Channel: the directory ~/.pair/<repo>-<hash>/ (under $PAIR_HOME if set). Each git worktree has its own channel, derived from its root.
  • Participant: a name for one side of a pair, such as claude, codex or alice. The CLI that runs it, Claude Code or Codex, is a property of the session, not of the name (Participants).
  • Lane: one direction between two participants, <author>-to-<reviewer>/, such as claude-to-codex/.
  • Thread: one exchange in a lane, stored as numbered messages: request, then alternating review and response. A review closes when the reviewer approves; if findings remain open after PAIR_MAX_ROUNDS rounds (default 3), it is escalated and both agents stop and ask the user. A brainstorm closes as completed.
  • Auto session: one pair start run: the interactive author, the reviewer it starts for each round, and the processes that supervise them.

2. Installation and setup

npm install -g claude-codex-pair     # Node 22 or later; installs the `pair` command

From source: clone the repository and run npm install && npm link.

Both agents' sandboxes MUST be able to write the channel root. pair init prints these snippets with your actual path; for the default root they are:

# ~/.codex/config.toml
[sandbox_workspace_write]
writable_roots = ["/Users/you/.pair"]
// ~/.claude/settings.json
"sandbox": { "filesystem": { "allowWrite": ["~/.pair"] } }

Auto mode needs neither: pair start grants each session its own channel (see Security considerations). The grant above covers every repository's channel, so an agent working in one repository could also write another's; to prevent that, grant each manual session only its channel, the path pair init prints.

The Codex desktop app gives each session its own sandbox and may not apply writable_roots. There, approve Codex's requests to run pair commands outside the sandbox, or, if the app lets you, give the session write access to the channel root.

The agents learn pair from instructions in the worktree: .claude/skills/pair/SKILL.md for Claude Code and a marked section of AGENTS.md for Codex. Claude Code also reads AGENTS.md; the section tells any agent other than Codex to ignore it. pair start writes them where the session runs if they are missing. For manual mode, run pair init once in each worktree. Restart agent sessions that were open before setup.

3. Auto mode

Auto mode runs on macOS and Linux. The CLIs it runs MUST be installed and signed in, and pair start MUST be run in your own terminal, outside an agent session. On Windows, or to run both agents yourself, use manual mode.

pair start claude          # interactive Claude, automatic Codex reviewer
pair start codex           # interactive Codex, automatic Claude reviewer
pair start claude claude   # Claude reviewed by Claude (claude_reviewer)

The first word is the author's CLI, the second the reviewer's (default: the other one). Named participants are in Participants. pair start --as claude and --as codex work as before 0.10.

In a terminal, pair start without a CLI asks instead. The questions are:

  1. whether to resume the conversation pair recorded for this checkout, asked first and only when there is one; Enter resumes it. Resuming reuses that session's settings, such as its CLIs and names, and shows its reviewer model and effort: Enter keeps them, n asks for new ones. Options you type with pair start still win, and a reviewer setting typed there skips that question; in a terminal, pair start --resume reuses the settings without the resume question;
  2. the CLIs;
  3. where to run: this checkout, or a --worktree branch name, with a resume question, also answered yes by Enter, for that worktree's own recorded conversation;
  4. the reviewer's model and effort. The model menu lists Claude's aliases (fable, opus, sonnet, haiku), or the models Codex shows in its own picker, read from $CODEX_HOME/models_cache.json. You can also type any other model ID. For Codex, an ID that isn't in that file, where Codex's hidden models also appear, asks you to confirm it, since a typo is likelier than a model that isn't listed yet. For a Codex model, the effort menu lists only the efforts that model supports.

Enter takes each default. It then prints the command it chose, such as pair: command: pair start claude --worktree feat, and goes on as if you had typed it, with the same summary and Start? [Y/n]. Options you give are kept and not asked again. Ctrl-C or end of input cancels. Without a terminal, or with -y, nothing is asked.

Give the author a task as usual. Each request or response it sends starts the other agent as a non-interactive reviewer for one round, and the review comes back inline to the author's pair send. Follow-up rounds resume the reviewer's session; a new thread starts a fresh one. Round limits and escalation are as in manual mode. Auto mode needs neither the MCP server nor a second terminal.

Before it creates a worktree, writes a file or starts an agent, pair start prints where the session will run, the author's conversation, the reviewer's settings, and whether it will run pair init there:

pair: start auto mode in /Users/you/your-repo-feat (new worktree, branch feat); pair init runs there if its branch lacks the instructions
pair:   author claude · session 3f6c2a1e-5b7d-4c1f-9a2e-0d8b4e6f1a73 (new)
pair:   reviewer codex · model CLI default · effort CLI default
Start? [Y/n]

In a terminal it waits for Enter; anything else, Ctrl-C or end of input cancels, and nothing is started. -y starts without waiting.

3.1. Options

Option Default Meaning
--as NAME, --reviewer NAME each CLI's name The participants' names (Participants)
--worktree NAME current worktree Run in the worktree ../<repo>-NAME (Worktrees)
--resume new conversation Resume the author conversation pair last recorded for the session's worktree (Author conversations)
--reviewer-model MODEL CLI default Reviewer model ID or alias, passed as given (Codex IDs are case-sensitive)
--reviewer-effort LEVEL CLI default Codex: none minimal low medium high xhigh max ultra; Claude: low medium high xhigh max ultracode
-- ARGS... none Options for the interactive author (Forwarded arguments)

Advanced options:

Option Default Meaning
-y, --yes wait for Enter Start without waiting for Enter
--reviewer-args="ARGS" none More reviewer options, space-separated (Forwarded arguments)
--serve-worktrees off Also review subagents' own worktrees of this repository (Parallel work)
--reviewers N 1 (max 8) Review rounds at once, across all served worktrees; needs --serve-worktrees
--claude PATH, --codex PATH first on PATH Absolute path to each executable
--timeout SECONDS 1800 (max 86400) Limit per review round, not counting system sleep; the author has none. pair reviewer --timeout changes it later
--max-reviews N 0 (no limit) Reviewer launches allowed this run, retries and served worktrees included. pair reviewer --max-reviews changes it later
--grace SECONDS 2 (max 30) Wait between termination and forced termination
pair start claude --worktree feature/login --reviewer-effort high -- --model opus
pair start codex --reviewer-model opus --reviewer-args="--max-budget-usd 2"
pair start claude --worktree feature/login --resume

Reviewer overrides apply to every round, including resumed ones; pair edits no CLI configuration. pair status and pair ps show them, with CLI default for omitted ones. After a round, pair status also shows what the reviewer actually ran with when that differs, as in model CLI default (ran gpt-6.1-sol). Pair reads this from the CLI's own session file, so it may be missing if that file is. A model or effort the reviewer rejects fails the round and keeps the request (Control and recovery). pair reviewer changes them while the session runs (Changing the reviewer).

3.2. Forwarded arguments

Arguments after -- are passed to the author before pair's own arguments; --reviewer-args are passed to every reviewer round. --reviewer-args MUST be written with =, because its value starts with a dash. Each list accepts only the options below, each with at most one value; repeat an option for more. Anything else is refused with the supported list.

Author (-- ARGS) Reviewer (--reviewer-args)
Claude --model, --effort, --permission-mode, --add-dir, --allowedTools, --disallowedTools, --mcp-config, --strict-mcp-config, --agent, --plugin-dir, -r/--resume, -c/--continue, --fork-session, -n/--name, --dangerously-skip-permissions, --allow-dangerously-skip-permissions, --verbose, --ide, --chrome, --no-chrome --fallback-model, --max-budget-usd, --strict-mcp-config
Codex resume <id> (first), -m/--model, -c/--config, -p/--profile, -s/--sandbox, -a/--ask-for-approval, --add-dir, -i/--image, --enable, --disable, --local-provider, --search, --oss, --no-alt-screen, --dangerously-bypass-approvals-and-sandbox -c/--config with a model_* key other than model_reasoning_effort

The lists are allowlists because unlisted options can turn the author into a print or background session (-p, --bg), select a Codex subcommand, move the author away from its channel (--cd, --worktree; use pair's --worktree instead), or replace settings pair passes. The reviewer list excludes everything that changes its tools, permissions or sandbox (Security considerations). Codex reviewer options must also work with exec resume.

3.3. Author conversations

pair start opens a new author conversation unless told otherwise:

To continue Claude author Codex author
A specific conversation pair start claude -- --resume <id> pair start codex -- resume <id>
The newest conversation in the session's worktree pair start claude -- --continue not supported
The conversation pair last recorded for the worktree pair start claude --resume pair start codex --resume

The last row uses pair's own --resume, before --; the others pass the CLI's options after --.

Codex is resumed by ID only, with resume as the first author argument. --continue picks the newest conversation in the worktree the session runs in, not where you typed the command. --continue and --resume cannot be combined.

Pair records the author's conversation ID for the worktree. It knows the ID at launch for a new Claude conversation (pair picks it) and for a resume by ID. Otherwise, for a new Codex conversation, --continue, --fork-session, or a resume by name or search term, the CLI picks the conversation and pair learns its ID from the author's first review request. Until then, pair status shows it as unknown.

pair status and pair stop show the last recorded ID and a command that starts the session again in its worktree and resumes it, for example cd /path/to/worktree && pair start claude -- --resume <id>. You can change its options before running it.

pair start --resume uses that record without copying the ID. The record MUST be for the same CLI and have a known ID, the worktree MUST already exist, and the author arguments MUST NOT select a conversation themselves. With a CLI word (pair start claude --resume) or without a terminal, only the conversation is reused: every other option comes from the command line. In a terminal without a CLI word, guided start also reuses that session's recorded options, such as its CLIs, names and reviewer settings, and asks whether to keep the reviewer; options you type still win. The record is recovery data; pair does not check that the conversation still exists.

A conversation started with pair 0.6.1 or earlier may still name an old run's pair command in its recorded instructions. Each launch tells the author to use "$PAIR_BIN" instead; if it still runs the old path, tell it to.

3.4. Control and recovery

From another terminal in the session's worktree:

pair status    # lanes, the running and the last finished round, author conversation, log
pair status --json   # the same for scripts: lanes, instructions and the session's state
pair ps -v     # pair processes by worktree, with full commands
pair reviewer  # change the reviewer's model, effort or time limit (Changing the reviewer)
pair stop      # stop the author, its reviewers and their tools
  • At most one launcher owns a worktree. A registered manual Codex session blocks pair start until pair unregister --as NAME.
  • A reviewer that fails to start, ends without a verdict or times out keeps the request, and the error includes the reviewer's own message. The author retries the round with pair wait --as <author>, with the same reviewer settings; to change them first, see Changing the reviewer. When the reviewer's own message shows a retry won't help (its provider refused the content, it isn't signed in, or its account is used up), the error says so, and the author asks you instead of spending another launch.
  • pair status shows the round running and the last one finished, with its verdict or failure and the tokens its reviewer used, read from the reviewer CLI's own session file (not for a Claude round that compacted: Claude doesn't record the summarizing call). Set PAIR_BELL=1 before pair start to ring the terminal bell when a round finishes. Both cover the session's own worktree; served subagent worktrees appear in the serving list. In pair status --json, auto.mode is running, served, stopped or unavailable; a running session has auto.round (thread, queuedAt, launchedAt) and auto.lastRound (thread, verdict, escalated for a thread that reached its round limit, or failed: attention, retry or unknown, the times, and tokens with input, cachedInput and output when known). Times are epoch milliseconds.
  • With --serve-worktrees, pair stop in the session's worktree also stops reviews queued or running for subagent worktrees; their requests stay on disk (Parallel work).
  • Exiting the author stops its managed processes. If every supervising process is force-killed, a stale socket can remain; pair status names it, and it MUST be inspected and removed by hand.
  • The author has the terminal's streams but no controlling terminal: programs that need /dev/tty, and Ctrl+Z, do not work in auto mode.
  • Agents receive this run's CLI as PAIR_BIN. An interactive Claude author runs managed commands in the background, since a review can outlast the foreground tool timeout.

Process supervision is specified in DESIGN.md.

3.5. Changing the reviewer

pair reviewer changes a running session's reviewer settings without a restart. Run it in your own terminal, in the session's worktree: the author and its reviewer can't, so neither picks the model that judges its work. pair status shows the current settings. When no session runs there, pair reviewer saves the change (all but --thread) in the record of its last conversation, so resuming it, with a bare pair start or the restart command pair status prints, starts with it.

pair reviewer --reviewer-model gpt-6.1-sol --reviewer-effort high   # threads opened from now on
pair reviewer --reviewer-effort default                             # back to the CLI's default
pair reviewer --thread current --reviewer-model gpt-6.1-sol         # the thread whose round failed
pair reviewer --timeout 3600                                        # each round's limit, from the next one
pair reviewer --max-reviews 20                                      # reviewer launches allowed this run; 0: none

A thread keeps the settings of its first round for its follow-up rounds and retries, so a plain change applies to new threads and to the restart command that pair stop prints. --thread current (or the thread's ID) changes only a pending thread whose last round failed, for example after a mistyped model. Its next round starts a new reviewer conversation that reads the thread so far. Then tell the author to retry. A thread that ended (approved, completed or escalated) has no next round; when it was the worktree's last round, pair status marks it finished. The next request opens a new thread with the new-thread settings. A change to the values already set says unchanged. --timeout applies to every round from the next one, a failed thread's retry included; a running round keeps its limit. --max-reviews caps the reviewer launches of this pair start run, every retry and served worktree's round included; pair status shows how many are used. Past the limit pair launches nothing: the request stays on disk, and the error tells the author to ask you. Raise the limit (or remove it with 0), then the author retries with pair wait. A restart counts from zero again, and the restart command pair stop prints keeps the limit.

4. Participants

A pair is two participants: one authors, the other reviews. claude and codex are the default names, each partnered with the other, so nothing changes unless you name others. A name is lowercase letters, digits and underscores, up to 32 characters, starting with a letter. Each pair of names has its own lane, so a participant can have one open thread with each partner.

Auto mode. The words after pair start choose the CLIs: the author's, then the reviewer's, which defaults to the other one. --as and --reviewer choose the names. Each participant is named after its CLI, unless that would give the reviewer the author's name: then it is <cli>_reviewer.

Command Author Reviewer
pair start claude claude (Claude) codex (Codex)
pair start codex codex codex (Codex) codex_reviewer (Codex)
pair start claude --as alice alice (Claude) codex (Codex)
pair start claude claude --as alice --reviewer bob alice (Claude) bob (Claude)

Names don't choose CLIs: pair start claude --reviewer claude is refused (the same participant twice), and pair start claude codex --as alice --reviewer claude runs a Codex reviewer named claude. The exception is the form without CLIs, as before 0.10: --as claude or codex (default: PAIR_AGENT) also chooses the author's CLI. For any other name, pair start asks for the CLIs in a terminal (Auto mode) and refuses without one. When a CLI is given, PAIR_AGENT is ignored, so the command means the same in every shell.

Only the CLIs the pairing uses must be installed. A same-CLI reviewer gets its own conversation per thread, never the author's. The summary, pair status and the restart command show the pairing; it can't change while the session runs.

Manual mode. Each session needs its name and partner. Set them when you start the agent:

PAIR_AGENT=alice PAIR_PARTNER=bob claude     # terminal A: the author
PAIR_AGENT=bob PAIR_PARTNER=alice claude     # terminal B: "be my reviewer"

A Codex session may run its commands in Codex's shared background service, which doesn't see the terminal's environment, so give Codex its variables as configuration instead:

codex -c 'shell_environment_policy.set.PAIR_AGENT="alice"' -c 'shell_environment_policy.set.PAIR_PARTNER="bob"'

Or tell the agent in words: "you are bob; your partner is alice". Without either, a Claude session is claude and a Codex session codex, as before. The agents pass --as on every command and --to on every send; a reply goes to whoever sent the message, as the == next: line of pair wait says. A Codex participant other than codex registers for wake-ups with pair register --as NAME.

Compatibility. Nothing on disk is renamed: existing lanes, history and registrations work as they are. Names other than claude and codex need this version on both sides: an older pair refuses them, its status, history and reset don't see their lanes, and an older pair mcp wakes only codex, so restart Codex after upgrading.

5. Manual mode

Start Claude Code and Codex in separate terminals in the same worktree, after pair init.

  1. In the reviewer's terminal, say "be my reviewer". Claude waits on pair wait in a background command; Codex registers and ends its turn until woken (Waking Codex).
  2. In the author's terminal, finish a task and say "ask codex for a review" (or "ask claude", or the partner's name).
  3. The author verifies each finding, then fixes it or rejects it with a reason, and replies.
  4. The thread ends on approval or escalation.

Spec reviews and brainstorms work the same way (Workflows).

5.1. Waking Codex

A finished background command does not resume Codex, and a polling pair wait costs a model call per check. Codex therefore never polls: pair's MCP server wakes it when a message arrives. Register the server once; init prints the command with your paths:

codex mcp add --env 'PAIR_CODEX=/opt/homebrew/bin/codex' pair -- '/path/to/node_modules/claude-codex-pair/dist/pair.js' mcp

Codex then runs pair register --as <its name> and calls the pair_listen tool before waiting. When a message for it is pending, the server runs codex queue with a fixed note that never contains message text.

  • The command SHOULD point at the installed package, not at a checkout you edit.
  • PAIR_CODEX pins the codex executable, since the server runs outside Codex's sandbox and does not search PATH. init refuses to pin a codex in, or linked into, the worktree, the channel or a temp directory.
  • Codex passes MCP servers only a few environment variables. init adds PAIR_HOME and XDG_STATE_HOME to the command when set; after changing them, run codex mcp remove pair and add the server again.
  • pair_listen needs MCP tool approval: the never approval policy is unsupported. With on-request, approve the first call.
  • Notifications stop after pair unregister --as <its name> ("stop as reviewer"), or when Codex's background service unloads the session, about 1–2 minutes after its last window closes. A message in that gap still starts a turn with no window attached.
  • Without the server, Codex checks once, says it cannot be woken, and checks again only when asked ("check pair").
  • When Codex restarts the server under an open session, for example when its background service updates itself, another server takes over the listener within 10 minutes of losing it, while Codex's background service lists the session as open. It never resumes a session: one closed and opened again later must call pair_listen itself. This works for sessions that called pair_listen with pair 0.10.0 or later; pair status shows "listener recovery armed".
  • The server writes only under ~/.local/state/pair/<repo>-<hash>/ (under $XDG_STATE_HOME if absolute): codex.listen.log, rotated at 256 KB, its claims and its listener records. pair status shows the registration and the last listener event.

6. Workflows

Ask the author in your own words; it runs the pair commands. In Claude Code, /pair <request> loads pair's instructions explicitly; Codex always has them in AGENTS.md. The examples name codex as the reviewer; with a Codex author, say claude, or use your partner's name. Every workflow works in both modes.

Ask the author The reviewer The thread ends
"ask codex for a review" reports findings with severity: approve or changes approved, or escalated after PAIR_MAX_ROUNDS rounds
"ask codex to review the plan in docs/plan.md" checks the document: approve or changes the same
"brainstorm with codex how to …" adds options and questions: continue or complete completed, at the latest on the last turn
"use a subagent per PR, each in its own worktree" (session started with --serve-worktrees) reviews each subagent's worktree, up to --reviewers N at once per subagent, as for a review

For a larger change, chain them: brainstorm the approach, write a plan and have it reviewed, then implement it and cite the spec review in the code review.

6.1. Spec review

A spec, plan or design doc is reviewed like code, in any format: a Markdown plan, an OpenSpec change, an ADR. The request names the document's paths and the commit they're at, or says they're uncommitted, and includes the result of the format's own validator if it has one, such as openspec validate. The reviewer checks the document, not code: ambiguous or contradictory requirements, missing edge cases and error handling, acceptance criteria that can't be tested, scope, and plans the current code can't support. Approval covers that version of the document, not an implementation.

When the author implements a reviewed spec, its code-review request cites it:

## Spec
Thread 2026-11-06T05-19-31-945Z-da0bac (pair history da0bac).
docs/plan.md, approved at abc1234; unchanged since.

The reviewer reads that thread with pair history and reports where the code departs from the spec, or says it can't find it. pair history covers the repository's existing worktrees, so a spec reviewed in one worktree can be cited from another, a served subagent's included; it finds their channels with the caller's PAIR_HOME. Pair parses neither section; this is part of the agents' instructions.

6.2. Brainstorms

A brainstorm is for ideas before there's a design. The author opens it with pair send request --brainstorm, giving the problem, the constraints and what's decided, and may leave its own proposal out of the first message to get independent ideas. The reviewer answers with options, trade-offs and questions and a verdict of continue or complete, and the author replies with pair send response, as in a review:

== pair: brainstorm review from codex · claude-to-codex · round 1 · verdict continue ==
Option A: an in-memory LRU … Option B: HTTP ETags … How stale may a read be?
== next: reply with your answers, objections or your own proposal: pair send response --as claude <file|-> ==

The reviewer gets PAIR_MAX_ROUNDS turns (default 3), fixed when the brainstorm opens. On the last one continue is refused, and the reviewer completes it with the options considered, a recommendation and the open decisions. To stop earlier, tell the author you have enough; it asks the reviewer to complete. A brainstorm never escalates, and pair history lists it as completed.

Both agents MUST run pair 0.8.0 or later: an older pair rejects a brainstorm as a corrupt message instead of reviewing it as code.

6.3. Parallel work

An author MAY split work across subagents, in one of three shapes:

  • One change, several subagents. The author alone runs the pair loop. Its instructions tell it to have each subagent return its changes and validation results without running pair commands, integrate them into the session's worktree, and request review of the combined change, keeping the checkout stable while the reviewer runs. A subagent inherits the author's pair environment, so without that rule it could open a thread of its own: in the shared checkout, against files others are still editing, or in its own worktree, where no auto session serves the request.
  • Separate PRs, reviewed in turn. The author checks out each branch in the session's worktree and finishes that PR's review loop before the next.
  • Separate PRs, reviewed in parallel. Run one pair start --worktree NAME session per PR (Worktrees), or let one session serve its subagents' worktrees (below).

Approval of separate pieces doesn't cover a later merge of their work; review the integrated result as well.

Serving subagent worktrees

Start the session with --serve-worktrees; --reviewers N runs up to N reviews at once (default 1, max 8):

pair start claude --serve-worktrees --reviewers 2

Then ask the author for parallel work, for example: "Use two subagents, each in its own worktree: one fixes the parser bug, the other adds the CSV export. Each runs its own pair review loop and reports the outcome." The author prompt gives the author the rules to pass to each subagent: send requests and responses from its own worktree in the background, keep the worktree unchanged while a review is queued or running, finish the loop, leave the worktree in place, and report approval, escalation or the failure as printed.

  • Enrollment. A worktree's first request enrolls it, after pair checks that it is a worktree of this repository and that the request comes from this session. The session claims that worktree's auto-mode socket, so no other session or reset runs there until this one stops.
  • Queue. Reviews from every worktree, the session's own included, wait in one first-come-first-served queue, and up to N run at once. A retry attaches to its waiting or running round.
  • Failures. A failed round affects only its worktree. A worktree that is removed or replaced, including a replaced .git, fails alone, and its reviewer is stopped.
  • No writes. Pair writes nothing in a served worktree, not even instruction files: the reviewer's rules come in its prompt.

pair status in the session's worktree shows the queue:

  serves subagent worktrees · reviewers 2 · running 2 · queued 0
  running: /Users/you/your-repo/.claude/worktrees/agent-a0b4 (thread 2026-11-06T13-43-14-155Z-66b9d4, pid 30452)
  running: /Users/you/your-repo/.claude/worktrees/agent-ae4d (thread 2026-11-06T13-43-16-364Z-c9eb51, pid 31639)

In a served worktree, pair status names the serving session, and pair reviewer --thread current fixes that worktree's failed round. pair stop, pair start and pair reset are refused there; pair stop in the session's worktree stops everything. Worktrees stay served until the session stops.

Pair never creates, merges or removes worktrees. Claude Code may create subagent worktrees under the main checkout's .claude/worktrees/, based on the default branch rather than the session's branch, and lock them. After the session, check each one's base and changes before opening its PR, then git worktree unlock and git worktree remove it.

6.4. Test evidence

A reviewer treats the request's Validation as the author's claim, so it often runs the same build and tests again, which costs tokens. For a check the author runs with pair test, pair keeps the result tied to the files it ran on, and the reviewer may credit it instead:

pair test 'npm test'          # runs as usual, then records the result
pair send request --as claude --evidence - <<'EOF'
…
EOF

pair test runs the command through the platform shell and exits with the status the shell returns: for npm test | tail -5 that's tail's, so don't pipe a check or add || true. It records the command, its directory, exit status and time, and a fingerprint of the files Git shows: HEAD, plus every changed or untracked file that isn't ignored, with its bytes and exec bit. --evidence on pair send request or pair send response attaches, per command, the latest run that started from the checkout as it is now: at most 10, failures first. With none, the send fails and nothing is sent; without --evidence, nothing changes. When the reviewer's pair wait delivers the message, pair checks the checkout again:

== evidence recorded by pair test · Git-visible files match the checkout now ==
- exit 0: npm test (in the worktree root, took 2m41s, at 2026-11-30T08:40:12.345Z)
== next: review it, then: pair send review --verdict approve|changes --as codex <file|-> ==

The reviewer may credit a check whose files match, unless what it's checking depends on what the fingerprint doesn't cover: ignored files (build output, dependencies), changes Git doesn't show (line endings it normalizes, modes with core.fileMode off, filtered files), the toolchain and the sandbox. It says which checks it credited and which it ran. Evidence from before a change, from a run that changed files, or that pair can't check again counts only as the author's claim, and so does a command whose status a pipe or || decides. Without a commit, with a submodule, or with assume-unchanged or skip-worktree files, pair runs the command but doesn't record it. The attached command is copied into the thread, so keep secrets out of it. An older pair on the reviewer's side delivers the message without its evidence. Windows should work but isn't tested yet.

7. Worktrees

Each worktree has its own channel, so pairs in different worktrees run in parallel without seeing each other's messages. The author and reviewer MUST run in the same worktree, since the reviewer reads the author's files.

In manual mode, a request sent from a worktree where its reviewer neither waits nor is registered, while it does in another worktree of the repository, prints a warning naming that worktree: an author working in a separate worktree probably sent from there by mistake. pair wait marks its channel while it runs, which is how pair can tell, and pair status shows who is waiting.

In auto mode, --worktree NAME runs the session in the git worktree ../<repo>-NAME (slashes become dashes):

  • If the path does not exist, pair creates it on branch NAME with git worktree add. An existing local branch is checked out. A branch found only on remotes is created to track it: on one remote, that remote; on several, the one named by checkout.defaultRemote, and pair refuses if none is. Otherwise a new branch starts at HEAD, so uncommitted changes stay in the current checkout. A tag named NAME is never checked out instead.
  • If the path exists, it MUST be a worktree of this repository. The session runs on whatever it has checked out, which may be a renamed branch or a detached HEAD; the summary shows which. Pair never switches it, and refuses to start if it changes while the summary waits for Enter.
  • If the worktree lacks the instructions, pair runs pair init there; the current checkout is left alone.
  • pair status and pair stop MUST be run in the worktree. The worktree remains after the session; remove it with git worktree remove.

The agents' own directory and worktree options are refused (Forwarded arguments).

In manual mode, start both agents in the worktree:

git worktree add ../your-repo-feature -b feature/x
cd ../your-repo-feature
pair init     # unless AGENTS.md and .claude/skills/pair/ are committed on this branch

If messages do not arrive, compare the channel: line of pair status in each agent. Removing a worktree leaves its channel; delete the directory that pair status reports.

8. Commands

Agents run send and wait; users mostly run start, stop, status, reviewer, history and upgrade. pair help <command> describes each command and its options.

pair start [AUTHOR_CLI [REVIEWER_CLI]] [--as NAME] [--reviewer NAME] [options] [-- AUTHOR_ARGS...]
pair stop
pair reviewer [--reviewer-model MODEL|default] [--reviewer-effort LEVEL|default] [--thread current|ID]
pair reviewer --timeout SECONDS
pair send <request|review|response> --as NAME [--to NAME] [--brainstorm] [--evidence] [--verdict VERDICT] <file|->
                             # approve|changes, or continue|complete in a brainstorm
pair test <command>          # run a check and record its result for send --evidence
pair wait --as NAME [--timeout seconds]   # default 540; prints "no message … yet"
pair status
pair history [thread-id]     # finished threads in this repository's worktrees, or one by any part of its id
pair clean --keep N          # delete all but the N newest finished threads
pair reset [--as NAME] [--dry-run]
pair init | uninit | upgrade
pair prune [PATTERN...] [--dry-run] [--yes]   # delete the channels of worktrees that no longer exist
pair register | unregister [--as NAME]   # run by Codex: let pair_listen notify this session
pair mcp                     # MCP server for Codex (manual mode)
pair ps [-v]
pair help [command]          # same as pair <command> --help

pair status reports the channel, the worktree, the version, each lane's state (the two default lanes, and any other lane in the channel), the instruction files on disk, the Codex registrations, who runs a manual pair wait there, and the auto session:

channel: /Users/you/.pair/your-repo-12345678
worktree: /Users/you/your-repo
version: claude-codex-pair 0.10.0
claude-to-codex: brainstorm awaiting-review (round 1, codex's turn)
codex-to-claude: idle
instructions on disk (does not verify what running agents loaded):
  AGENTS.md (pair section): current
  .claude/skills/pair/SKILL.md: current
codex notifications: no session registered
waiting: nobody
auto mode: claude author, codex reviewer · reviewing · owner 41820 · pair 0.10.0
  author session: 3f6c2a1e-5b7d-4c1f-9a2e-0d8b4e6f1a73 (resumed)
  reviewer for new threads: model gpt-6.1-sol · effort high
  reviewer for thread 2026-11-06T05-19-31-945Z-da0bac: model CLI default (ran gpt-6.1-sol) · effort CLI default (ran xhigh)
  serves subagent worktrees · reviewers 2 · running 1 · queued 0
  running: /Users/you/your-repo (thread 2026-11-06T05-19-31-945Z-da0bac, pid 41907)
  reviewer pid: 41907
  log: /Users/you/.local/state/pair/your-repo-12345678/auto.log

Instruction states are current, stale, missing, unreadable, or newer (written by a newer pair; run pair upgrade). Run pair init for missing or stale, then reload the agents. status and init also report a newer npm release, checked at most daily.

A channel access failure (EACCES, EPERM) names the path and prints the sandbox snippets for it.

9. Maintenance

9.1. Reset

pair reset clears stale pending requests by moving whole lanes to <channel>/resets/<reset-id>/ and printing the path.

pair reset --dry-run      # preview
pair reset                # every lane
pair reset --as claude    # only lanes claude authored

Manual sessions SHOULD be stopped first. Reset refuses while an auto session owns the worktree (--dry-run still works). Backups keep every file, including malformed or partial ones, plus reset.json; unread verdicts in a reset lane are no longer delivered. Source files, history and registrations are unchanged. history and clean ignore backups; delete them by hand. A partial failure names the backup already written.

9.2. Upgrade

Run pair upgrade in your own terminal; agent sandboxes block the network and global installs. It installs the latest release and refreshes this worktree's instructions. Other worktrees refresh on their next send, wait, history or clean. Instruction files are owned by pair and overwritten, except files a newer pair wrote. Restart Claude Code and Codex afterwards. To restart an auto session in the same conversation, run pair stop, then pair start --resume (Author conversations).

pair start helps with both:

  • It shows the update notice when a newer release is out. With PAIR_AUTO_UPGRADE=1, it installs that release with npm first and runs the same command with it; if the install fails, or npm installs it where this pair can't find it, it starts with the pair you have. The npm check runs at most once a day, and not at all with PAIR_NO_UPDATE_CHECK.
  • It refreshes this worktree's instruction files that an older pair wrote before the agents start, so they load the instructions of the pair that starts them.
  • Where auto mode already runs on other pair code (an older version, or another build of this one), pair start in a terminal asks whether to stop that session and start with this pair; its author then ends in its own terminal. Only y stops it. A bare pair start offers to resume that conversation, as after pair stop. Without a terminal, or with --yes, it only says what to run. A session on the same code is refused before the start asks to confirm. pair status and pair ps show the pair version each session runs.

9.3. Uninstall

Run pair uninit in each worktree. It removes the skill (unless edited), the pair section of AGENTS.md (or the file, if nothing else remains) and the Codex registrations, and prints the command to delete message history. pair uninit --purge also deletes the channel (message history) and auto mode's state (the resume record and log), so the next pair start there begins fresh. It is refused while an auto session runs in or serves the worktree; stop any other agents using the channel first. If the repository tracks pair's skill or AGENTS.md section, git status shows changes to those files afterwards, and uninit says so. Check the diff and stage only the changes you mean to commit; pair init puts pair back. Then:

codex mcp remove pair
npm uninstall -g claude-codex-pair

and remove ~/.pair from the sandbox settings.

A worktree deleted without pair uninit --purge leaves its channel and auto state behind. Run pair prune anywhere to delete those of every worktree that no longer exists (--dry-run lists them; name patterns such as pair prune 'old-*' narrow it). It asks first, keeps any an auto session still holds, and lists channels it can't place: pair records a channel's worktree when init or send runs there, so older channels may have no record. A worktree on an unmounted volume also looks deleted, so read the list.

10. Environment

For Codex, set these with -c 'shell_environment_policy.set.NAME="value"' rather than in the terminal (Participants); pair start does this for the agents it launches.

Variable Default Meaning
PAIR_HOME ~/.pair Channel root. Relative paths resolve against the worktree root
PAIR_AGENT none Your participant name: the default for --as (for pair start, only without CLIs)
PAIR_PARTNER the default partner Whom a new request goes to without --to (Participants)
PAIR_MAX_ROUNDS 3 Review rounds before escalation; a brainstorm's turns, fixed when it opens
PAIR_KEEP 100 Finished threads kept; all keeps every thread, 0 none
PAIR_NO_UPDATE_CHECK unset Any value disables the npm release check
PAIR_AUTO_UPGRADE unset Any value: pair start installs a newer release first (Upgrade); needs the npm release check
PAIR_BELL unset Any value: pair start rings the terminal bell when a review round finishes
PAIR_AUTO_SOCKET_DIR /tmp/pair-auto-<uid> Private absolute directory for auto-mode sockets; keep it short

11. Security considerations

  • Managed reviewers. Codex runs with its workspace-write sandbox plus channel access; source edits are forbidden by its instructions, not by the OS. Claude runs with dontAsk, so beyond your configured permissions it may only read, search, and run pair wait, pair send review and pair history (to read a spec review a request cites). It loads only your user settings (--setting-sources user) and no MCP servers (--strict-mcp-config), so a branch's .claude/settings.json can't run hooks or add permissions when a review starts; it's told to read the worktree's CLAUDE.md for the project's conventions. Codex loads a worktree's .codex/config.toml, MCP servers included, unless your own config marks that path untrusted, so pair starts each Codex round in a fresh, empty directory in its state directory, with the worktree and channel added as writable, and tells it where the worktree is and to read its AGENTS.md. If a .codex sits anywhere on that directory's path (say, XDG_STATE_HOME inside a repository that has one), pair refuses the round and says so. Pair itself refuses every reviewer command except wait, send, status and history, and a reviewer never refreshes instruction files. These guard against mistakes and casual prompt injection, not a determined agent: the role comes from an environment variable, and the Codex sandbox can write the channel.
  • No loosening. Auto mode passes neither CLI's permission-bypass flags to reviewers, and --reviewer-args cannot change their tools, permissions or sandbox. --mcp-config is excluded because MCP servers start outside tool permissions.
  • Claude author socket. Pair grants a Claude author only this session's control socket, through --settings; your settings files are unchanged. If managed policy denies it, the request fails with the required setting named and stays on disk.
  • Channel access. In auto mode each agent may write only its own channel: a Claude author or reviewer through --settings (sandbox.filesystem.allowWrite), a Codex author or reviewer through --add-dir. With --serve-worktrees the author's grant is pair's home, since its subagents write their worktrees' channels there. A user-wide grant to all of pair's home, which manual mode needs, would widen this again; auto mode doesn't need it.
  • Terminal output. pair wait, pair history and pair status show agent-written control characters escaped when they print to a terminal, so a message can't drive the terminal; so do pair's errors and warnings on a terminal's stderr, which can quote channel data. Piped output, which agents read, is unchanged.
  • Served worktrees. With --serve-worktrees, the owner reviews a worktree only after checking that it is a git worktree of the same repository, that the request carries this run's ID, and that the owner can claim its socket. Each round re-checks the worktree's identity. Subagents hold the author's environment, so this is workflow routing, not an identity boundary between them.
  • Reviewer output. A failed round's error quotes the reviewer's own message, shortened, with control characters escaped and labeled as reviewer output rather than instructions.
  • MCP server. pair mcp runs outside Codex's sandbox, so it only reads the channel, writes only its state directory, and never forwards message text.
  • Links and special files. Agents can write the channel and the worktree, and a cloned branch can hold symlinks. Pair reads only regular files there, bounded in size, never through a final symlink and never waiting on a FIFO. It refuses a symlinked channel, lane or archive directory, refuses to send a message larger than readers accept (16 MiB with its header), writes messages through new unguessable temporary files. It reads and writes AGENTS.md and SKILL.md only inside the worktree and outside .git, through a link only to a Markdown file, never through a hard link, and replaces them by rename. It never refreshes or overwrites a SKILL.md it didn't write. These close the plain cases; an agent swapping a directory for a link at the right moment is not yet covered.
  • Processes. Pair never signals a process by a saved PID or by executable name.

Appendix A. Example review

Messages from a real run, shortened. The round-1 bug was planted.

== pair: review from codex · claude-to-codex · round 1 · verdict changes ==
### F1 [medium] src/paginate.js:8: Partial last pages are omitted from the page count
`totalPages(5, 2)` returns 2 ... Use `Math.ceil(count / pageSize)`.
### F2 [medium] src/paginate.js:2: Invalid pagination inputs produce unrelated items
`paginate([1, 2, 3, 4, 5], 1, -2)` returns `[1, 2, 3]` ...

== pair: review from codex · claude-to-codex · round 2 · verdict approve ==
F1 and F2 are fixed. I re-read src/paginate.js and ran 41 assertions ... All passed.

About

Claude Code and Codex review each other's work.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages