From codex-collaboration
Sequential pair-programming loop where Claude produces analysis, Codex validates each finding, and both models must agree before acting. Use for iterative improvement with bilateral consensus.
How this skill is triggered — by the user, by Claude, or both
Slash command
/codex-collaboration:collaborative-loopopusThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Sequential pair-programming loop between Claude and Codex CLI. Claude PRODUCES an analysis with numbered findings, Codex VALIDATES each finding individually (CONFIRM/REJECT), Claude RE-EVALUATES the validation decisions, and only findings where both models agree proceed to implementation. After fixes, Codex reviews the changes and the loop repeats until clean.
Sequential pair-programming loop between Claude and Codex CLI. Claude PRODUCES an analysis with numbered findings, Codex VALIDATES each finding individually (CONFIRM/REJECT), Claude RE-EVALUATES the validation decisions, and only findings where both models agree proceed to implementation. After fixes, Codex reviews the changes and the loop repeats until clean.
Core principle: Claude never acts on its own unvalidated output. Every finding passes through bilateral consensus before implementation.
"collaborate with codex", "have codex review my changes", "drive and review loop", "iterative improvement", "produce-validate-act", "collaborative loop"
collaborative-loop [--max-rounds N] [--type code|plan|architecture|design] [target files...]
| Argument | Default | Description |
|---|---|---|
--max-rounds | 3 | Maximum fix-review iteration rounds |
--type | (auto-detected) | Artifact type override |
| target files | (branch diff) | Specific files to analyze |
Read ${CLAUDE_PLUGIN_ROOT}/skills/shared/prerequisites.md and execute the preflight check.
Invoke /codex:setup via the Skill tool. Two failure modes:
/codex:setup and ABORT.On success, proceed to Step 2.
After /codex:setup succeeds, verify the Codex broker can actually complete work (not just accept connections). /codex:setup --json already reports whether the CLI is installed and auth is valid; the liveness step dispatches a trivial task to confirm end-to-end dispatch works.
Invoke /codex:rescue --fresh via the Skill tool with a minimal prompt such as Reply with OK. Cap the wait at 90 seconds for this probe specifically — the 15-min response-generation threshold does not apply to a liveness probe (if it can't echo "OK" in 90s it's dead). If the task dispatches but hangs past 90 seconds or returns empty output, the runtime's connection is likely dead (WebSocket TTL expired — see "WebSocket Connection Limit" in prerequisites.md). If the Skill tool itself errors (e.g., permission denial, disable-model-invocation), that is NOT a dead runtime — see the "Skill-gate Rejection" and "Skill-tool Fallback" paths in prerequisites.md. Dead-runtime recovery:
/codex:setup — the companion will establish a fresh connectionOnly proceed to Step 2 after the liveness check passes.
The collaborative loop requires BOTH collaborators. If Codex fails at any point during the workflow (script error, empty output):
codex exec/codex:setup, check auth, check OpenAI API status)Codex tasks can legitimately run for 30+ minutes on complex analyses. Do NOT use a hard timeout. Use /codex:status (Skill tool) to assess health — never PID-based checks on Windows (see "Task Health Verification" in ${CLAUDE_PLUGIN_ROOT}/skills/shared/prerequisites.md).
Tier 1 — Task health check (within 60 seconds of dispatch):
After dispatching a Codex task, verify it is making progress within 60 seconds using /codex:status (Skill tool). If status reports the task as failed or the runtime pipe is gone, follow the Auto-Retry Protocol in prerequisites.md.
Tier 2 — Starting-stuck detection (5-minute threshold):
If the task phase stays starting for >5 minutes without advancing to running or showing any log entries, run Diagnostic Escalation from prerequisites.md. This catches dead connections (WebSocket limit, 403 errors) quickly.
Tier 3 — Response-generation awareness (critical):
After tool calls go quiet, Codex is composing its response. Max wait: 15 minutes of silence (reduced from prior guidance — session data shows silence >10 min is almost always a dead task, not slow generation). After 15 minutes, escalate to Direct CLI Fallback. See "Response-Generation Awareness" in prerequisites.md.
When a genuine failure is detected:
/codex:cancel or the companion/codex:setup and retry (max 2 companion retries)codex execCodex failed via both companion (N retries) and direct CLI.
Diagnostics: <specific findings from logs>
Remediation: Check OpenAI API status, verify auth (codex auth login), check network.
Read ${CLAUDE_PLUGIN_ROOT}/skills/shared/artifact-detection.md and follow the detection procedure.
--max-rounds N (default: 3)--type code|plan|architecture|design (default: auto-detect from files)If no target files provided:
main, then master, then git remote show origin defaultgit diff <base>...HEAD --name-only to find changed filesFollow the rules in artifact-detection.md:
| Signal | Type |
|---|---|
Source code extensions (.ts, .py, .js, .go, .rs, .cs, .java, etc.) | code |
*-plan*, *-tasks*, *implementation-plan* | plan |
*-architecture*, *-spec* | architecture |
Other .md in docs/ or plans/ | design |
| Mixed | default to code |
ROUND = 0
MAX_ROUNDS = <from args or 3>
ARTIFACT_TYPE = <detected>
TARGET_FILES = <resolved list>
BASE_BRANCH = <detected>
Claude analyzes target files and produces numbered findings with severity. No implementation yet -- analysis only. Do not modify any files.
For code artifacts, search available skills for the best match:
coder, code-review, feature-devunity-coder, python-coder) then general-purposeFor plan, architecture, and design artifacts, perform structured analysis against focus areas from ${CLAUDE_PLUGIN_ROOT}/skills/shared/review-domains.md. Read the file and use the focus areas for the detected artifact type.
Produce numbered findings, globally ordered by severity:
[1] [critical] [security] src/auth/login.ts:42 -- SQL injection via unsanitized input
Suggested fix: Use parameterized query instead of string concatenation
[2] [high] [correctness] src/api/handler.ts:87 -- Missing null check on response.data
Suggested fix: Add guard clause before accessing .data property
[3] [medium] [performance] lib/cache.ts:15 -- Cache has no TTL, grows unbounded
Suggested fix: Add maxAge option to cache constructor
Every finding must:
[N]critical, high, medium, or minorfile:lineHold findings in conversation context. Do not write intermediate files.
Send Claude's numbered findings to Codex for per-finding validation. Codex independently evaluates each finding and returns CONFIRM or REJECT with evidence.
Pre-dispatch: fresh setup. Before dispatching, re-invoke /codex:setup to verify the runtime is alive. Read the "Fresh Setup Before Dispatch" section in ${CLAUDE_PLUGIN_ROOT}/skills/shared/prerequisites.md. Do NOT reuse the preflight result from Step 1 — the runtime endpoint may have changed since preflight.
IMPORTANT: Use /codex:rescue --fresh via the Skill tool -- NOT /codex:adversarial-review. Adversarial review produces its own independent findings and does not map back per-finding. Only /codex:rescue with a custom prompt supports per-finding CONFIRM/REJECT. Always pass --fresh to prevent the codex plugin from prompting the user about resuming a previous thread.
Skill-gate rejection is NOT a runtime failure. If the user denies the /codex:rescue Skill invocation at the permission prompt, no job was dispatched — do NOT run the Auto-Retry Protocol from prerequisites.md. Instead:
codex exec) as an alternative that doesn't route through the Skill gateUser denial ≠ runtime failure. Retrying the Skill tool without user input would be a permission bypass attempt.
Monitor the task using the Hang Detection procedure from Step 1. Verify task health within 60 seconds, watch for starting-stuck at 5 minutes. Remember: after tool calls go quiet, Codex is likely generating its response (10-30 minutes) — do NOT cancel. Use the Monitor tool to stream events from the task rather than looped status polling; only re-check status on Monitor timeout, an unexpected event, or immediately before retrieving results.
Invoke the gpt-5-4-prompting skill patterns when composing the prompt. Structure the prompt with XML-tagged blocks:
<task> block:
Validate each of Claude's findings independently. For each finding, determine
whether it is a genuine issue (CONFIRM) or a false positive (REJECT). You must
provide evidence from the actual code or specification for each decision.
Also report any issues you find that Claude missed entirely.
Include in the prompt:
${CLAUDE_PLUGIN_ROOT}/skills/shared/review-domains.md for the detected artifact type${CLAUDE_PLUGIN_ROOT}/skills/shared/validation-format.md as <structured_output_contract>Codex returns per validation-format.md:
## Confirmed Findings
- [1] CONFIRM -- evidence from code/spec
- [3] CONFIRM -- evidence from code/spec
## Refined Findings
- [4] REFINE -- agree with issue but severity should be medium, not high: <reasoning>
## Rejected Findings
- [2] REJECT -- evidence why this is a false positive
## New Findings (Missed by Driver)
- [high] [error-handling] src/api/handler.ts:91 -- Unhandled promise rejection
Suggested fix: Add try/catch wrapper
## Status
VALIDATED | PARTIALLY_VALIDATED | REJECTED
## Summary
Brief assessment (confirmed X, refined Y, rejected Z, found W new)
Claude reviews Codex's CONFIRM/REJECT decisions against the original analysis. This is the bilateral consensus gate.
| Codex Says | Claude Agrees? | Action |
|---|---|---|
| CONFIRMED | Yes | Proceed -- act on this finding in Step 5 |
| CONFIRMED | No | Flag for user -- present disagreement, ask for mediation |
| REFINED | Yes | Proceed -- act with Codex's adjusted severity/fix |
| REFINED | No | Flag for user -- present disagreement on the refinement |
| REJECTED | Yes | Drop -- both agree this is not a real issue |
| REJECTED | No | Flag for user -- present disagreement, ask for mediation |
For each CONFIRMED finding: Claude reviews whether the confirmation is sound. If Claude still agrees the finding is real, mark as proceed. If Claude now thinks Codex's confirmation was based on a misunderstanding, mark as flag.
For each REFINED finding: Claude reviews the adjusted severity/fix. If Claude agrees with the refinement, mark as proceed (using Codex's adjusted severity/fix). If Claude disagrees with the refinement, mark as flag.
For each REJECTED finding: Claude reviews whether the rejection is justified. If Claude agrees the finding was a false positive, mark as drop. If Claude still believes the finding is valid despite Codex's rejection, mark as flag.
For new findings from Codex: Claude evaluates each. If Claude agrees it is a real issue, mark as proceed. If Claude disagrees, mark as flag.
Flagged disagreements: Present ALL flagged items to the user with both models' reasoning. Wait for user mediation before continuing. The user may:
Only findings marked proceed (including user-mediated ones) advance to Step 5.
Never silently resolve disagreements. The entire point of bilateral consensus is that ambiguous cases get human judgment.
Filter to confirmed-and-agreed findings only. Claude implements the fixes.
run_in_background: true) when parallelism adds value -- specifically when fixes are independent and span different modules/filesLog dropped findings for the summary but do not act on them:
Dropped (both models agreed not real):
- [2] [high] [correctness] src/api/handler.ts:87 -- reason for drop
After Claude implements fixes, Codex reviews the resulting changes.
Pre-dispatch: fresh setup. Before dispatching, re-invoke /codex:setup to verify the runtime is alive. Same rationale as Step 4 — the runtime endpoint may have changed during Claude's implementation work in Step 5.
Invoke /codex:review --base <ref> via the Skill tool, where <ref> is the commit or ref before Step 5's changes. This uses the codex plugin's native review capability.
Invoke /codex:rescue --fresh via the Skill tool with a review prompt. Compose the prompt using gpt-5-4-prompting patterns:
<task>: Review the changes made to these artifacts. Evaluate whether the fixes correctly address the validated findings without introducing new issues.${CLAUDE_PLUGIN_ROOT}/skills/shared/verdict-format.md as <structured_output_contract>The same rule as Step 4 applies to Step 6: if the user denies /codex:review or /codex:rescue at the permission prompt, no job was dispatched — do NOT run the Auto-Retry Protocol. Instead:
codex exec with the diff and verdict contract inlined) as an alternativeUser denial ≠ runtime failure. Retrying the Skill tool against the same permission state is a bypass attempt.
Codex returns per verdict-format.md:
## Status
APPROVED | MINOR_ISSUES | CHANGES_REQUESTED
## Findings
- [severity] [category] file:line -- description
Fix: concrete suggested fix
## Summary
Brief overall assessment
Parse the verdict status from Codex's response.
APPROVED -- All issues resolved. Present final summary and stop.
MINOR_ISSUES -- Only minor/informational findings remain. Log them in the summary and stop.
CHANGES_REQUESTED -- Actionable findings remain. Continue to next round:
ROUNDTrack findings across rounds. If more than 50% of findings persist (same file:line, same category) across 2 consecutive rounds:
Stall detected: X of Y findings persisted across rounds N and N+1.
These findings may require architectural changes or manual intervention:
- [finding details]
- [finding details]
Please advise: continue with modified approach, or stop here?
When ROUND >= MAX_ROUNDS:
Max rounds (N) reached. Remaining issues:
- [finding details]
- [finding details]
Present at the end of every loop run (whether clean exit, stall, or max rounds):
## Collaborative Loop Summary
Rounds completed: N
Findings resolved: X
Findings dropped (consensus reject): Y
Findings remaining: Z
### Resolved
- [1] [severity] [category] file:line -- fixed in round N
### Dropped
- [2] [severity] [category] file:line -- both models agreed not real
### Remaining (if any)
- [5] [severity] [category] file:line -- description
Claude never acts on unvalidated output. Step 3 produces analysis; Step 4 validates it; Step 4.5 requires bilateral agreement. Only then does Step 5 implement.
Both models must agree before action. The Step 4.5 decision matrix ensures that disagreements are surfaced to the user, never silently resolved.
No intermediate files. Claude holds all state (findings, validations, round tracking) in conversation context. No temp files to manage or clean up.
No self-review fallback. If Codex fails at any point, STOP. Do not substitute Claude reviewing its own work -- that defeats the purpose of bilateral validation.
Parallelism is organic. Claude uses Agent tool subagents when fixes are independent. Codex uses multi_agent = true internally when the prompt includes parallelism instructions. Neither is forced.
Disagreements go to the user. When Claude and Codex disagree on a finding's validity, the user mediates. No model overrides the other.
Do NOT use /codex:adversarial-review for validation. It produces its own independent findings instead of CONFIRM/REJECT on Claude's findings. Only /codex:rescue with a custom prompt provides per-finding validation.
Do NOT act on unvalidated output. Claude's Step 3 analysis is a proposal, not a mandate. Every finding must pass through Steps 4 and 4.5 before implementation.
Do NOT fall back to Claude-only if Codex fails. Self-review provides no additional signal. Stop the loop and report the failure.
Do NOT silently resolve disagreements. If Claude and Codex disagree on a finding, present both perspectives to the user. Never auto-resolve in favor of either model.
Do NOT forget gpt-5-4-prompting patterns. When composing any prompt for Codex (Steps 4, 6), invoke the gpt-5-4-prompting skill to use proper XML-tagged block structure. Codex performs significantly better with structured prompts.
Do NOT skip Step 4.5. The re-evaluation gate is what distinguishes this from a simple "send to Codex and trust the result" workflow. Claude's independent review of Codex's decisions catches validation errors.
Do NOT poll Codex status in a loop. Use the Monitor tool to stream events from the running task — it emits events on state changes without burning context. One manual /codex:status check at 60 seconds after dispatch is fine; after that, let Monitor drive. Repeated bash status polls every few seconds or minutes waste context for no value.
Do NOT use hard timeouts for Codex tasks. Complex validations legitimately take 15-30 minutes. A hard timeout would kill healthy tasks. Use the Hang Detection procedure from Step 1.
Do NOT cancel a task after tool calls go quiet — it may be generating its response. But do NOT wait more than 15 minutes of silence either — escalate to Direct CLI Fallback. See "Response-Generation Awareness" in prerequisites.md.
Do NOT use PID-based liveness checks on Windows — use /codex:status (Skill tool). See "Task Health Verification" in prerequisites.md.
Do NOT reuse stale preflight state for Codex dispatch. The runtime endpoint (named pipe) can change between Step 1 preflight and Steps 4/6 dispatch. Always re-run /codex:setup immediately before dispatching Codex. A 5-second setup call prevents 10+ minutes of debugging zombie tasks.
Do NOT give up when companion retries fail. Always try Direct CLI Fallback (codex exec) before stopping. The companion has a known reliability issue on Windows — direct CLI creates fresh connections and consistently succeeds.
npx claudepluginhub dmitriyyukhanov/claude-plugins --plugin codex-collaborationGuides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Resolves in-progress git merge or rebase conflicts by analyzing history, understanding intent, and preserving both changes where possible. Runs automated checks after resolution.