duet
Two CLI agents in conversation. One Python file. Stdlib only.
duet runs two command-line coding agents in alternating turns until they
agree. By default that is Claude and Codex; Gemini, Copilot, and OpenCode are
also supported, and you can pair two agents from the same backend. One agent
plans or reviews while the other implements; each keeps its own session memory
across turns, and every run leaves a transcript you can inspect.
Use it four ways
1. Inside Claude Code — /duet
The fastest path if you already live in Claude Code.
/plugin marketplace add volkan/duet
/plugin install duet@volkan-duet
/duet
Plain /duet runs Claude Code's real /review, then loops Codex and Claude in
a worktree until they converge. Pass any upstream command as the kickoff:
/duet 'npm test 2>&1' --turns 4. The plugin shells out to the duet CLI, so
install that first (see below) and make sure command -v duet passes in Claude
Code's shell. Custom topology flags such as --no-worktree and
--allow-worktree-fallback replace the plugin defaults without emitting
conflicting CLI flags. Full guide:
docs/CLAUDE_CODE_PLUGIN.md.
If Claude Code disambiguates plugin commands with namespaces, /duet:duet is
the same command.
Autonomous handoff example:
While the handoff runs, Claude Code shows the shell in auto mode and exposes
the exact duet command under shell details:
Copy-ready version:
/loop /goal Create a temporary todo.md from the plan above and the remaining
tasks in todo_codex.md.
1. Use /duet:duet with max reasoning to confirm the plan.
2. After the plan is confirmed, implement it.
3. Once the first implementation is done, use /duet:duet with max reasoning
for code review.
4. Use /duet:duet with max reasoning to review the second plan, then implement
it.
5. When the process is complete and all checks are green, merge the approved
changes.
P.S. I will not be around, so handle decisions without me. If you need another
opinion, use /duet:duet to discuss it with Codex.
2. Inside Codex — $duet
codex plugin marketplace add volkan/duet
codex plugin add duet@volkan-duet
Start a new Codex thread and invoke $duet, or just ask Codex to use duet in
plain language. Like the Claude Code plugin, the skill shells out to the duet
CLI, so install that first (see below) and make sure command -v duet passes in
Codex's shell. Full guide:
docs/CODEX_PLUGIN.md.
3. Inside OpenCode — /duet
OpenCode custom commands are drop-in files — no marketplace step:
mkdir -p ~/.config/opencode/command
cp plugins/duet-opencode/command/duet.md ~/.config/opencode/command/duet.md
Then invoke /duet in the OpenCode TUI (or opencode run --command duet "..."
non-interactively). Like the other plugins it shells out to the duet CLI, so
install that first and make sure command -v duet passes in OpenCode's shell.
The command runs on OpenCode's build agent; plain /duet runs the same
claude -p /review --model sonnet kickoff, and
/duet 'npm test 2>&1' --turns 4 seeds from any command. Custom worktree
overrides are constructed conditionally, matching the Claude and Codex entry
points. Full guide:
docs/OPENCODE_PLUGIN.md.
(duet can also drive OpenCode as a backend — --partner opencode:coder — so
OpenCode can be one of the two looped agents too.)
4. From the terminal — duet
pipx install duet-cli # recommended; the command it installs is `duet`
duet --task "Fix the failing test" --cwd ~/code/myrepo
pipx is the recommended install. Two other persistent options put duet on
PATH the same way:
uv tool install duet-cli
python3 -m pip install --user duet-cli
The PyPI package is duet-cli (bare duet on PyPI is Google's async library).
Add the [yaml] extra for --config foo.yaml support — pipx install 'duet-cli[yaml]', uv tool install 'duet-cli[yaml]', or python3 -m pip install --user 'duet-cli[yaml]'. One-shot, no install:
uvx --from duet-cli duet --task "..." — note this is ephemeral and does not put
duet on PATH, so the /duet and $duet plugins need a persistent install
(pipx install duet-cli, uv tool install duet-cli,
python3 -m pip install --user duet-cli, or make install) instead.
Examples
Each command teaches one capability. The partner agent speaks first.
Review loop — Codex reviews at max effort, Claude applies only the fixes Codex asks for, in an isolated worktree:
duet --task "Review the latest commit; fix only what the reviewer requests." \
--lead claude:coder --partner codex:reviewer \
--reasoning max --worktree --worktree-for lead --turns 6
Seed from another tool's output — drive the loop from Claude Code's real
/review, a test run, or any command:
duet --recipe review --cwd ~/workspace/project
The review recipe uses recap mode, claude:reviewer + codex:coder, six
turns, claude -p /review --model sonnet, and strict worktree isolation.
Claude agents use the stable sonnet alias unless an explicit slot model
overrides it. The recipe also sets
--on-turn-timeout continue, so when the coder turn times out the reviewer
still gets the timeout block plus the worktree diff to review instead of the
run dying reviewless. Explicit flags override recipe values.
Deterministic automation — discover the run without parsing terminal prose, then poll the curated status schema:
control_dir=$(mktemp -d)
duet --recipe review --run-info-file "$control_dir/run.json" &
duet_pid=$!
while [ ! -s "$control_dir/run.json" ]; do sleep 0.1; done
run_dir=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["run_dir"])' "$control_dir/run.json")
duet --status "$run_dir" --json
wait "$duet_pid"
Deep planner, fast coder — Claude plans at high effort while Codex coder turns drop to low for latency:
duet --reasoning high --codex-fast \
--task "Fix the issue" --cwd ~/workspace/project
Use --no-codex-fast to override a config or continued run that enabled it.
Verify gate — a convergence proposal only counts if make test exits 0;
any failure feeds back into the next turn:
duet --task "Fix the issue" \
--lead claude:coder --partner codex:reviewer \
--verify-cmd 'make test' --worktree --worktree-for lead
Resume a plan — plan with Codex in its own session, then hand the session
id to duet; Codex implements with the plan in context while Claude reviews
(--resume-claude <id> does the inverse):
duet --resume-codex <codex-session-id> --worktree --reasoning max \
--task "Implement the plan from your Codex planning session."
Reusable configs ship under examples/ — pr-review.yaml (deep review of
HEAD) and codex-test-fix.yaml (Codex planner diagnoses failing checks, Codex
coder fixes them). Run one with duet --config examples/pr-review.yaml.
How it works
Each agent keeps its own conversation memory across turns (Claude via
--resume, Codex via codex exec resume, Gemini, Copilot, and OpenCode via
their JSON session ids). On each turn duet sends one agent's latest reply to the
other.
To converge, an agent must include an LGTM rationale: explaining why the work
is done, followed by the sentinel <<<LGTM>>> on its own line — a bare
sentinel is ignored, and both agents must agree in back-to-back turns. The
loop also stops on --turns, a per-turn timeout, or Ctrl-C. With
--on-turn-timeout continue (the review recipe's default) a single turn
timeout is handed to the partner instead of ending the run; two consecutive
timeouts still stop. Without --timeout, the per-turn budget scales with the
reasoning level (900s → 1800s at xhigh/max). After a normal
stop, duet opens a force> prompt so you can push another round.
Every run writes a directory with transcript.md, state.json, per-turn
stderr logs, and the wt/ worktree when --worktree is on. Inspect a run with
duet --status <run-id> --json (or omit --json for the human view), list runs
with duet --list, stop one exact live run with duet --stop <run-id>, and
start a fresh run
from saved state with duet --continue <run> --task "next thing".
--stop is graceful. It lets the current agent turn finish before duet records
force_stop. Use --stop <run-id> --immediate to terminate that run's active
child and record force_stop now. Both forms validate the saved supervisor PID
and process-start identity. They never use a process-name match or signal a
different duet run.
If status remains awaiting_force, press Enter in the original terminal.
Some platforms do not wake the blocking force> input after an external signal.
- Backends:
claude,codex,gemini,copilot,opencode - Roles:
planner,coder,reviewer,triage-reviewer, or a custom one - Reasoning:
--reasoning minimal|low|medium|high|xhigh|max
Limits / future
Timeout continuation applies only to automatic loop turns. Seed extraction
and forced turns still stop on timeout. A final-turn timeout also stops because
no partner turn remains, and two consecutive timeouts stop the run. Poll
duet --status <run-id> --json to watch the current budget instead of assuming
a deep-reasoning turn is stuck.
Documentation
docs/USAGE.md is the
full reference: every flag, reasoning levels, session memory, output layout,
--status / --stop / --continue, the force prompt, Codex sandbox and network rules,
and worktree mode.
Contributing
Contributor guidance is in CLAUDE.md; Codex entry notes are in AGENTS.md. CI runs on every PR and is advisory until marked required — see .github/BRANCH_PROTECTION.md.
Metadata
Release files for duet-cli 0.2.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| duet_cli-0.2.12.tar.gz | 91.4 kB | With provenance | Details for duet_cli-0.2.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| duet_cli-0.2.12-py3-none-any.whl | Python 3 | none | any | Details for duet_cli-0.2.12-py3-none-any.whl |
Total release size: 154.9 kB
Release files / duet_cli-0.2.12.tar.gz
| Download URL | duet_cli-0.2.12.tar.gz |
|---|---|
| Size | 91.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2b55f62d20c8852e6991436ef471c76955beeca857bbde3bf1f0af2fcb24699
|
|
BLAKE2b-256 checksum How to use checksums |
0b59b641ac56e068562ae20f09a9752b061d9c655cd70e6b90b9e5b67f84d005
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency logRelease files / duet_cli-0.2.12-py3-none-any.whl
| Download URL | duet_cli-0.2.12-py3-none-any.whl |
|---|---|
| Size | 63.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
865252bf7e2735aadf6dc2ccc93e30a45c3485b30074489b85e26022164325d3
|
|
BLAKE2b-256 checksum How to use checksums |
dbdc1d35297688a54c70df09d7b774aff180b7b44ab5a5fcfbb91c04512a10bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency logSecurity for duet-cli 0.2.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for duet_cli-0.2.12.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.