/peer-planning:execfrom peer-planning
Execute a plan task by task as a two-agent run. An implementation subagent (Opus at medium by default) builds each task, Codex in the adjacent agterm pane reviews the diff before the commit, then Codex is cleared and the next task starts; a task the plan marks for discussion has its approach agreed with Codex first. The agents talk through agterm's pane mailboxes (the mailbox-chat skill), with long content in files, and every step lands in a jsonl event log that a live agterm page shows. Finish with the project's revmux review rounds, its polish step and one run of the whole suite. Use it whenever the user says peer-planning:exec, asks to execute a peer-planning:make plan, or wants plan execution reviewed by Codex task by task, even when they just say "run this plan with Codex".
Ships in peer-planning. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Who does what:
WORK_PATH and asks Codex to run its
commands there.A task closes only when Codex has found nothing left to fix and the commit has passed the project's hooks. A task marked for discussion also needs both agents' agreement on its approach before any code is written.
The "Pair sessions" section of ~/.agents/AGENTS.md governs every exchange with Codex here, in
discussion and in review. There is no turn limit. An exchange goes on while each turn brings
something new (a refutation, a cite, a checked fact or a changed position), and a turn that only
restates the one before it ends the exchange. An addition is priced on four questions: the failure
it prevents, the input, whether that input is realistic, and what breaks without it. A refutation
cites code.
Every message goes through mailbox-chat.py say, which puts it in the other pane's mailbox and
never types into a terminal. The one raw send, approved by the owner, is scripts/codex-clear.sh:
between tasks it types /clear into Codex's pane, then a one-line READY prompt. A mailbox message
cannot deliver a slash command, and after a /clear Codex takes mail only once its new
conversation has run a prompt; until then the mail goes to the cleared thread.
A run keeps its files in RUN_DIR, which is .peer-planning/<plan-stem>/ at the root of the
checkout this session runs in:
msgs/ holds what a chat message cannot carry: code, diffs, an implementer's report, long item
lists. references/codex-messages.md says when a message uses a file;events.jsonl is the event log, one JSON object per line, as references/event-log.md
describes;progress.md is the run's memory in prose, plus one line in a fixed form, the full-suite record
below;monitor.html is the live page over the log;tests.js is the latest pytest invocation seen during the open task, rewritten while it runs
by the peer_planning_pytest pytest plugin. That module is not part of this plugin: it lives
in ~/.local/lib/agterm-pytest/ and is loaded into every pytest Claude starts through the env
block of ~/.claude/settings.json. It finds this run through the session and the checkout; its
docstring has the rules. Without it tests.js is never written and the monitor shows no test
progress. It is telemetry for the monitor only: the implementer's report stays the record of
what passed.The conversation itself stays in chat, where the user reads both agents. The directory stays out of git and outlives the run: it is the record the monitor and later tuning read. Once the run's branch has landed, "Run-record housekeeping" offers to remove it.
/git:finalize-feature-branch skips the full test suite on a pass this record holds for the
branch's head, so the record has one fixed form, a line of its own in progress.md:
FULL-SUITE PASS sha=<40-character SHA> passed=<P> skipped=<S> collected=<C> command=<command>
Its one source is the closing suite stage ("After the last task", step 4). Write it only when that
stage's final message carries a FULL-SUITE: line, and copy its numbers and command as given.
sha is git -C WORK_PATH rev-parse HEAD taken right after the stage, which holds the code the
suite ran on with at most the plan's suite record added. Never write it from a report or from
memory: finalize trusts it in place of a run it watched.
Start from a fresh session, without a goal.
/clear, then this skill again with the same argument; /clear keeps this
agterm session, so Codex stays in the pane next to it. Go on only when the user says so, in
the invocation or in reply./goal. A goal is checked after every turn that ends
with nothing running in the background, which here is every wait on Codex, and its check
re-prompts this session, which then reads Codex's pane against "Waiting". This skill needs no
goal: Codex's messages and the subagents' returns wake it. Stop before any other setup and
tell the user to run /goal clear, or /clear, which removes the goal too, and then this
skill again. A goal's re-prompt is not the user's go-ahead.CLAUDE_CODE_STOP_HOOK_BLOCK_CAP), and any tool call starts that count again, which is
how a refusal becomes a spin.Load the mailbox-chat skill. Its sending and manners rules apply to every message below.
Confirm Codex is there. Run bash ${CLAUDE_SKILL_DIR}/scripts/codex-clear.sh --check.
It reads the right pane without typing and exits 0 only when Codex is idle with an empty
composer and registered for mail. If Codex is not running in the right pane, or is not
registered (its first prompt has not run, or its mailbox-chat hook is missing), stop and say
what the script reported. This skill never starts an agent or opens a pane, and Codex runs with
the model and effort the user started it with.
Resolve the plan. Use the argument, or list docs/plans/*.md outside completed/ and ask
the user to pick one.
Load the rules. Run bash ${CLAUDE_PLUGIN_ROOT}/scripts/resolve-rules.sh. Drop its
SOURCE: line and keep the rest as USER_RULES, the project's .claude/planning-rules.md.
It prints nothing when the project has none; USER_RULES is then "none".
Resolve the executor. The first source that names one wins: the user's invocation text, the
task's own Executor: line, the plan's Execution section, then the default, the implementer
agent definition (Opus at medium).
subagent_type..claude/agents/ or ~/.claude/agents/; worker, for example, is Opus at high).Find the default branch. Take git symbolic-ref --short refs/remotes/origin/HEAD without
its origin/ prefix; if that fails, the first of main and master that exists. Call it
DEFAULT_BRANCH. A new worktree starts from it, and the branch review diffs against it.
Choose where the work happens. Offer a numbered choice: a new worktree (the default) or the current feature branch.
git worktree add -b <name> .claude/worktrees/<name> DEFAULT_BRANCH, where <name> is the
plan's file stem without its date.uv run scripts/setup-worktree.py.WORK_PATH.Open the run directory.
RUN_DIR is $(git rev-parse --show-toplevel)/.peer-planning/<plan-stem>, taken in this
session's own directory rather than in WORK_PATH. Create RUN_DIR/msgs.git check-ignore -q "$RUN_DIR" fails, append /.peer-planning/ to
$(git rev-parse --path-format=absolute --git-common-dir)/info/exclude, the clone's local
ignore file, and tell the user. Never edit the project's .gitignore for it unasked.RUN_DIR/progress.md exists, this is a resumed run: read it and events.jsonl, and
continue from the last entry.progress.md with the plan, WORK_PATH, the branch and the executor.progress.md on every wake-up before acting. A Codex message arrives as a new turn
(hook feedback opening with [peer chat]), and the context may compact in the middle of a
run.Check whether Codex can write long replies.
scripts/reviewer-seat.py, as references/reviewer-seat.md
says: it names the model for the seat and whether the pane must switch, and the clear below
carries the switch. When it names the Opus seat, follow that reference instead of this step.bash ${CLAUDE_SKILL_DIR}/scripts/codex-clear.sh and log codex.clear with its exit code and
no task. make argues the plan with Codex in this same pane, and without the clear the first
review comes from a Codex holding that argument. Handle the exit codes as in "E. Close". A
resumed run decides from events.jsonl, not from progress.md, which step 9 has already
written: skip the clear once the log holds a task.start (an open discussion or review needs
the thread it stands on) or a taskless codex.clear with exit 0. If the last taskless
codex.clear has exit 1, the clear was typed but never confirmed: read the pane and tell
the user, as "E. Close" says, and never re-send blind. Otherwise the setup was interrupted
before the clear took, and it runs now.references/codex-messages.md and end your turn.RUN_DIR/msgs/000-codex-setup.md then holds ready, log codex.ready with
files:=true. If Codex replied "no files", log it with files:=false and never offer it a
file; it answers in chat only. Record which in progress.md.Open the monitor. Log run.start with every field references/event-log.md gives it:
"${CLAUDE_SKILL_DIR}/scripts/log-event.py" "$RUN_DIR" run.start plan=docs/plans/<plan>.md \
tasks:=<N> work_path="$WORK_PATH" branch=<branch> executor=<executor> session="$AGTERM_SESSION_ID"
plan is the plan's path from the repository root, as step 4 listed it, and tasks the
plan's task count. Run-record housekeeping reads plan to tell whether the run has landed,
and the monitor shows the plan, branch and executor from this record, so log-event.py
refuses a run.start missing any of them. Then run
"${CLAUDE_SKILL_DIR}/scripts/open-monitor.py" "$RUN_DIR". It copies the page into
RUN_DIR and shows it as a green-tinted page companion named <plan-stem> monitor, indented
under this session and without selecting it; it closes when this session closes. A resumed run
logs run.start again, so the monitor knows which session and checkout run it now, and makes
the same call: it reloads the monitor already under this session, and closes and reopens one
that sits anywhere else. The page reads the log through events.js and this session's agent status from
tree; its one action on agterm, "Go to the agents", selects this session. Tell the user
where it is, then go to task 1.
The same script opens any run's monitor later, from any session inside the repository:
without an argument it finds the runs in the main checkout and every worktree, and offers
them in agterm's picker. --list prints them instead.
Before any question that asks the user to rule (an approach, a size, a disagreement with Codex
that stalled, a scope call), run the decide:gate skill on it. It checks whether a recorded
ruling, a probe or a rule already answers it, sends a question about users through the persona
panel, checks the card's framing, and records the user's answer as a ruling when it is one. While
the gate is in shadow mode the question still reaches the user; only the judge's verdict is
logged. Inside a run its files go in RUN_DIR/gate/. A typed value or a bare go-ahead on a step
just described is not a ruling and skips the gate.
Log each step as it happens:
"${CLAUDE_SKILL_DIR}/scripts/log-event.py" "$RUN_DIR" review.reply task:=3 round:=1 verdict=must_fix must_fix:=2
references/event-log.md lists every event and its fields. Log when the step happens, never
afterwards from memory: the timestamps are what the log is for. A failed log call is a failed
step; fix it before moving on.
Tasks run strictly one at a time. Later tasks build on earlier commits, and all of them write to the same plan file.
### Task N: section with an unticked
box. If none is left, go to "After the last task".python3 ${CLAUDE_SKILL_DIR}/scripts/branch-overlap.py WORK_PATH --rebase --paths <the paths the task names>
and log branch.check with its behind, rebased and the number of overlaps. Nothing here
asks the user.
git -C WORK_PATH diff <base>...<branch> -- <files> and keep this task's change compatible
with it, touching the shared lines only as far as the task needs, and say so in the report.
Tell Codex the same in the review request.**Discuss:** yes, or when the user's invocation asked for discussion on every task. Log
task.start with discuss:=true or discuss:=false. Without discussion, go to C.discuss.request, and end your turn.discuss.reply.AGREED; log discuss.agreed.discuss.stalled and put the disagreement to the user as a numbered choice, with each
side's cite.ruling, relay it to Codex with the template, and do not debate it
further.**Agreed approach (Claude and Codex, <date>):** followed by bullets. The implementer, the
reviewers and the final report all read it there.references/implementer-prompt.md, the resolved executor as subagent_type,
run_in_background: true, and a description Task N: <title>. Its REPORT_PATH is the next
numbered file in RUN_DIR/msgs/. Log implement.start with its agent id, then end your turn.implement.done and put the decisions and deviations in
progress.md.
SendMessage and the command that
failed, at most twice. After that, stop and report to the user.review.request, and end your turn.Changed: and the paths
Codex saw. Run git -C WORK_PATH status --short yourself and compare the two lists. When they
differ, Codex has most likely run git in its own directory: log review.mismatch, send the
"asking again" message from references/codex-messages.md, and end your turn. A second
mismatch on the same round goes to the user. A verdict is logged only over a matching list.LGTM, log review.reply with must_fix:=0 and go to E.MUST-FIX: N, log review.reply with that count and pass the items on
without opening the cited code. The implementer has that code open, and its prompt has it apply
each item or refute it with a cite; checking them here would pull the code into this session.
REPORT_PATH, in the background. Log fix.start, and fix.done when it returns.REFUTED line names goes into the re-review request as a dispute, with the
implementer's cite.ruling once
they decide. The other items go on.git -C WORK_PATH log -1 --oneline and the task's ticked boxes in the plan, then log commit.references/reviewer-seat.md); when it says
switch, pass --model and --reasoning to the clear and log reviewer.switch. Run
bash ${CLAUDE_SKILL_DIR}/scripts/codex-clear.sh and log codex.clear with its exit code.
task.done and tell the user Task N done: <sha> <subject>. The
next task starts with a fresh implementer and Codex's fresh context.After every message to Codex and every background launch, end your turn. Never poll Codex's pane and never sleep-wait. Codex's reply waits in this pane's mailbox while a turn runs and is handed over only when the turn ends, so ending the turn is what lets the answer in. A turn interrupted with Esc reports no end, and its mail then waits until the next turn completes.
say reports who serves Codex's pane. Anything but "receiver": "codex" means nothing will read
the message: stop and tell the user what it returned. An error means the mailbox refused it;
report it and never re-send blind.
If Codex's message says more is coming, answer it at once: acknowledge what arrived and ask for the rest. Never end a turn waiting on a promised follow-up. Codex may already have ended its own turn, and then both agents wait on each other with nothing to break the silence.
A reply is never owed. If the user asks why nothing arrived, read the pane without typing, then report what it shows.
This session reads the plan, progress.md, the subagents' final messages, Codex's messages and the
discussion files they name, and the few lines a disputed claim cites. Code work, diffs, test
output and the implementers' reports stay out of it: an implementer writes its report for Codex,
and Codex's review items go to the implementer unopened. Keeping them out is how this session
remains coherent across a whole plan.
.claude/peer-planning/review.md if it has
one, otherwise references/review.md, which runs revmux rounds. Substitute WORK_PATH,
DEFAULT_BRANCH, PLAN_FILE_PATH, PROGRESS_FILE_PATH (as RUN_DIR/progress.md) and
REVIEW_PHASE. Then run the loop:
REVIEW_PHASE=comprehensive, and later ones run critical, up to
five iterations, until the playbook ends the phase. An iteration whose findings list is
empty also ends it: nothing changed, so a re-check would review the same diff. Log
stage.start and stage.done for each, with stage=review.references/implementer-prompt.md, the resolved executor as
its subagent_type, and the next numbered RUN_DIR/msgs/NNN-fixer-report.md as its
REPORT_PATH. When it returns, read only its final message and confirm the commit with
git -C WORK_PATH log -1 --oneline. Then append one line to progress.md:
Review iteration N fixer: <report path>, commit <sha>, <n> fixed, <m> false positive. The
fixes and decisions stay in the report, where the next round and the completion report read
them. A COMMIT line that names a failure ends the phase; tell the user.references/review.md, Step 7).git -C WORK_PATH diff DEFAULT_BRANCH...HEAD
and the plan's task list, each in a sentence of what a person would see. Map each to the
plan's numbered stories. A change a story already covers needs nothing.Test: block naming the test it will have).decide:panel) on the drafts, with RUN_DIR/panels/ as
its directory.Test: block as a finding, and confirm
python scripts/check_stories.py --form PLAN_FILE_PATH passes when the project has it.stage.start and stage.done with stage=stories. Unflagged drafts are listed in the
completion report./polish
(.claude/commands/polish.md), inside WORK_PATH. Log stage.start and stage.done with
stage=polish. It is interactive, and the project's polish ends by telling the user to
finalize. Under exec the suite stage comes first: it runs once polish returns, and the
completion report follows it.SUITE_COMMAND: the whole-suite command the plan's
Execution section names, or else the one the project's agent docs name. A plan written before
this stage existed names none. Then spawn a fresh subagent with the "Run the full suite"
prompt from references/implementer-prompt.md, SUITE_COMMAND substituted, the resolved
executor as its subagent_type, and the next numbered RUN_DIR/msgs/NNN-suite-report.md as
its REPORT_PATH. Log stage.start and stage.done with stage=suite.
git -C WORK_PATH log -1 --oneline. When the message carries a FULL-SUITE: line, write the
full-suite record. Then append one line to progress.md:
Suite stage: <report path>, commit <sha or none>, <SUITE line>, record written | not written.Tell the user:
progress.md, and every decision
a review fixer made, from the DECISIONS section of the fixer reports progress.md names;FAILURES section of the suite report), and whether the full-suite record was written;WORK_PATH, the branch and RUN_DIR, and what is left for the user: /git:finalize-feature-branch,
then /git:wrap-up, which archives the plan and removes the worktree, its test database and this
run's record;/clear first). This
one carries the whole run, and every call here pays for it. The run's record is in the plan and
in RUN_DIR (progress.md, events.jsonl), where a fresh session reads what it needs.Then log run.end. The plan is archived the way the project does it; here /git:wrap-up moves it
to docs/plans/completed/ once the branch has landed. Never move it while reviews still read it.
RUN_DIR stays where it is until the branch lands. Then run "Run-record housekeeping" once more: it catches a run from an
earlier session that landed meanwhile. This run's own branch has not landed yet, so it is not
offered.
Each run leaves a run directory, and nothing else removes one. So the skill offers it, once at setup and once after the completion report, and deletes only what the user picks.
Run "${CLAUDE_SKILL_DIR}/scripts/run-records.py" --landed from this session's checkout. It
prints one tab-separated line per landed run: the run directory, its size, the commit that
archived the plan, and the plan's file name. A run has landed when its log holds run.end
and its plan sits under completed/ on the remote's default branch, not at the path
run.start logged. Branch ancestry cannot tell, because finalize squashes the branch. The
script reads origin as it stands and fetches nothing. A line on stderr names a finished run
whose run.start carries no plan path, so the script cannot tell whether it landed; tell the
user, who removes that directory by hand once its branch is in.
If it prints nothing, say nothing about it and move on.
Otherwise offer a numbered choice:
Every option names each run's plan, the commit that archived it and its size. Say in the question that a removed record is gone from the monitor and from later tuning of this skill.
Remove exactly what the user picked, one call per run:
"${CLAUDE_SKILL_DIR}/scripts/run-records.py" --remove RUN_DIR. It refuses any path that is
not a landed run's directory, and it closes the run's <plan-stem> monitor session if one is
open. It removes nothing else: the worktree, the branch and any database belong to the
project's own setup, and a revmux task to revmux's own cleanup.
codex-clear.sh.assets/monitor.html (opens in a new tab)references/codex-messages.md (opens in a new tab)references/event-log.md (opens in a new tab)references/implementer-prompt.md (opens in a new tab)references/review.md (opens in a new tab)references/reviewer-seat.md (opens in a new tab)scripts/branch-overlap.py (opens in a new tab)scripts/codex-clear.sh (opens in a new tab)scripts/log-event.py (opens in a new tab)scripts/open-monitor.py (opens in a new tab)scripts/reviewer-seat.py (opens in a new tab)scripts/run-records.py (opens in a new tab)scripts/run_index.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
Other plugins' skills for the same job
npx claudepluginhub pysilver/cc-tools --plugin peer-planning