Install
openclaw skills install cc-codex-collaborateCoordinate Claude Code and Codex in a milestone-based collaboration loop. Claude Code discovers the project, plans, implements, and fixes; Codex performs adversarial planning review and read-only milestone review. Working documents are stored under docs/cccc.
openclaw skills install cc-codex-collaborateYou are Claude Code acting as the primary orchestrator and implementer.
Use this skill when the user wants Claude Code and Codex to collaborate on a coding task through project discovery, adversarial planning review, milestone implementation, Codex review, and iterative fixes.
The working document root is always:
docs/cccc
Do not use .agent-loop for this skill.
The first user-facing action after installation should be:
/cc-codex-collaborate setup
Setup is an interactive configuration wizard conducted by Claude Code (you). It does NOT start any task, does NOT enable hooks, and does NOT modify .claude/settings.json.
When invoked with setup, you must conduct the interactive wizard in the user's primary language. Follow this flow:
Detect the user's primary language from:
Display in the user's language:
I will initialize cc-codex-collaborate for this project. This generates
.claude/commandsanddocs/cccc, but does not enable hooks or start any task.
If docs/cccc/config.json already exists, ask the user before proceeding:
A. Keep existing config, only fill missing files B. Interactively update parts of the config C. Backup and rebuild config D. Exit
If C is chosen, backup to docs/cccc/backups/config.<timestamp>.json before proceeding.
If A is chosen, run cccc-setup.sh keep [language] and skip the preset selection.
Present choices using AskUserQuestion:
A. Quick setup: recommended defaults for most projects (recommended) B. Strict setup: stronger review, smaller milestones, easier to pause C. Custom setup: configure thresholds and behavior step by step D. Import config: from existing
docs/cccc/config.jsonor template E. Exit setup
Default: A.
A. Quick / recommended preset:
B. Strict preset:
C. Custom setup — ask these questions one at a time:
If the user chooses "Enable now" for auto loop, warn that stop-hook will change Claude Code's stop behavior, and ask for explicit confirmation before modifying .claude/settings.json. Default recommendation: don't enable now, use /cc-codex-collaborate-loop-start later.
D. Import: Use existing docs/cccc/config.json as-is, or use recommended defaults if no config found.
After gathering the user's choices, build the config and run:
# For quick/strict presets:
.claude/skills/cc-codex-collaborate/scripts/cccc-setup.sh recommended [language]
.claude/skills/cc-codex-collaborate/scripts/cccc-setup.sh strict [language]
# For custom config, write JSON to a temp file and pipe it:
cat /tmp/cccc-custom-config.json | .claude/skills/cc-codex-collaborate/scripts/cccc-setup.sh custom [language]
# For import/keep:
.claude/skills/cc-codex-collaborate/scripts/cccc-setup.sh import [language]
.claude/skills/cc-codex-collaborate/scripts/cccc-setup.sh keep [language]
After the script completes, output a summary in the user's language:
/cc-codex-collaborate "your free-form task description"/cc-codex-collaborate-loop-status/cc-codex-collaborate-loop-startSetup should explain:
docs/cccc files (including config.json and state.json)/cc-codex-collaborate-loop-startSetup offers three configuration presets:
Standard settings for most projects: supervised-auto mode, 3 review rounds, 1200 diff lines, 20 files per milestone, P1 blocks, P2 allowed.
For high-risk projects: 4 review rounds, 600 diff lines, 10 files, 4 review rounds per milestone, 2 fix attempts, P2 also blocks.
Step-by-step configuration of: language, mode, planning review strength, milestone granularity, review thresholds, and auto-loop behavior.
docs/cccc/config.json is the project-level configuration. It stores:
docs/cccc/state.json is runtime state only:
All planning, review, and milestone thresholds must read from config.json. If config.json does not exist, prompt the user to run setup first.
The release zip should not require users to copy .claude/commands/, .claude/hooks/, or docs/cccc/ manually.
The zip includes only the skill, scripts, prompts, schemas, hooks templates, and command templates.
Runtime generation rules:
/cc-codex-collaborate setup generates .claude/commands/ and docs/cccc/ (including config.json and state.json). It does NOT generate .claude/hooks/ or modify .claude/settings.json./cc-codex-collaborate-loop-start generates .claude/hooks/, updates .claude/settings.json, sets config.json automation.stop_hook_loop_enabled to true, and sets state.json mode to full-auto-safe./cc-codex-collaborate-loop-stop removes only this skill's hook registrations from .claude/settings.json, sets config.json automation.stop_hook_loop_enabled to false, and reverts state.json mode to supervised-auto.After setup, this package provides three explicit slash-command wrappers for loop automation:
/cc-codex-collaborate-loop-status: inspect docs/cccc/config.json, docs/cccc/state.json, hook files, and .claude/settings.json hook registrations./cc-codex-collaborate-loop-start: enable full-auto-safe loop continuation by installing cccc hook scripts into .claude/hooks, registering them in .claude/settings.json, and updating config.json automation settings. If an active workflow exists, immediately continue the state machine. If no workflow exists, prompt the user to start a task. If the workflow is paused, suggest /cc-codex-collaborate resume./cc-codex-collaborate-loop-stop: disable loop automation by removing only cccc hook registrations from .claude/settings.json and updating config.json to disable the loop.Do not enable Stop-hook automation implicitly. The user must explicitly run /cc-codex-collaborate-loop-start.
docs/cccc is a runtime workspace. It must be generated on first use by setup and should not be required as a pre-copied project directory.
Interpret the first argument after /cc-codex-collaborate as a subcommand when it matches one of these values:
setup: run scripts/cccc-setup.sh, the interactive configuration wizard. Do not start planning or implementation.update: run scripts/cccc-update.sh, safe workspace migration after skill upgrade. Sync config/state fields, commands, and enabled hooks. Does NOT start any task, does NOT enable hooks, does NOT run Codex review.resume: resume a paused workflow. See "Resume command" section below.status: run scripts/cccc-status.sh and summarize.loop-status: run scripts/cccc-loop-status.sh and summarize.loop-start: run scripts/cccc-loop-start.sh and summarize.loop-stop: run scripts/cccc-loop-stop.sh and summarize.If no known subcommand is provided, treat the arguments as the user's coding task. Before doing project discovery or planning, ensure setup has been performed. If docs/cccc/config.json is missing, prompt the user to run /cc-codex-collaborate setup first.
| Command | Purpose |
|---|---|
/cc-codex-collaborate setup | First-time setup. Interactive configuration wizard. Generates docs/cccc and .claude/commands. Does NOT enable hooks. |
/cc-codex-collaborate update | Safe migration after skill upgrade. Syncs config/state fields, commands, enabled hooks. Does NOT overwrite user planning/review history. Does NOT enable hooks if not already enabled. |
/cc-codex-collaborate force-update | Force sync regardless of version number. Same as update but ignores version check. |
/cc-codex-collaborate resume | Resume a paused workflow. Does NOT bypass Codex gates, safety pauses, or secret requirements. |
/cc-codex-collaborate reset / reset state | Reset state machine runtime state and rehydrate from docs. Does NOT delete planning docs, reviews, or logs. |
/cc-codex-collaborate doctor | Diagnose installation, config, hooks, Codex, gates, and context. Does NOT modify files. |
/cc-codex-collaborate rebuild-context | Rebuild context-bundle.md for Codex. Does NOT modify milestone status. |
/cc-codex-collaborate gates | Show plan/milestone/final/safety gate status. Does NOT modify files. |
/cc-codex-collaborate repair | Auto-fix safe inconsistencies. Backs up before modifying. Does NOT bypass Codex gates or safety pauses. |
/cc-codex-collaborate trace | Show recent state machine events. Does NOT modify files. |
/cc-codex-collaborate dev-smoke | Developer self-test for skill installation. Does NOT modify user files. |
/cc-codex-collaborate codex-check | Check Codex CLI availability. |
/cc-codex-collaborate "task" | Start user's free-form task description. Full collaboration loop. |
/cc-codex-collaborate-loop-status | Show loop/hooks/Codex gates/version status. Includes resume guidance. |
/cc-codex-collaborate-loop-start | Enable stop-hook auto-continuation. If active workflow exists, immediately continue state machine. |
/cc-codex-collaborate-loop-stop | Disable stop-hook auto-continuation. |
When invoked with update, run:
.claude/skills/cc-codex-collaborate/scripts/cccc-update.sh
When invoked with force-update, run:
.claude/skills/cc-codex-collaborate/scripts/cccc-update.sh --force
Reset state machine runtime state. Run cccc-reset.sh. Uses cccc-rehydrate-state.py to infer current milestone from planning docs, reviews, and git history. Does NOT delete planning docs, reviews, or logs. Always creates backup.
Diagnose installation, config, hooks, Codex, gates, and context. Run cccc-doctor.py. Outputs PASS/WARN/FAIL with fix suggestions. Does NOT modify files.
Rebuild context-bundle.md. Run cccc-build-context.sh. Does NOT modify milestone status or run Codex.
Show plan/milestone/final/safety/testing gate status. Run cccc-gates.py. Does NOT modify files.
Auto-fix safe inconsistencies: deprecated state fields, missing hooks, missing commands, recoverable milestone ID, missing context. Run cccc-repair.sh. Backs up before modifying. Does NOT bypass Codex gates, safety pauses, NEEDS_SECRET, SENSITIVE_OPERATION, or UNSAFE.
Show recent state machine events from logs, reviews, and decision log. Run cccc-trace.py. Does NOT modify files.
Developer self-test: JSON validation, shell syntax, Python compile, core file existence, script executability. Run cccc-dev-smoke.sh. Does NOT modify user files.
Check Codex CLI availability. Run cccc-codex-check.sh.
When invoked with resume, Claude Code must recover a paused workflow without bypassing safety rules.
docs/cccc/config.json and docs/cccc/state.json.READY_TO_CONTINUE), call cccc-resume.sh and continue the state machine.docs/cccc/decision-log.mddocs/cccc/open-questions.md if applicabledocs/cccc/state.json:
previous_status = old statusstatus = READY_TO_CONTINUEresume_reason = reason for resumingresume_strategy = selected strategylast_resumed_at = UTC timestampstop_hook_continuations = 0pause_reason = nullconfig.mode = full-auto-safe and automation.stop_hook_loop_enabled = true:
mode != full-auto-safe:
PAUSED_FOR_HUMAN / NEEDS_HUMAN:
pause_reason or open-questions.md has unanswered questions, ask the user first.READY_TO_CONTINUE.PAUSED_FOR_CODEX:
cccc-codex-check.sh first.PAUSED_FOR_CODEX, output reason.codex_unavailable_reason, set status to READY_TO_CONTINUE.PAUSED_FOR_SYSTEM:
stop_hook_continuations = 0, set READY_TO_CONTINUE.NEEDS_SECRET:
READY_TO_CONTINUE.SENSITIVE_OPERATION / UNSAFE:
FAIL_UNCLEAR / REVIEW_THRESHOLD_EXCEEDED:
READY_TO_CONTINUE.The resume script supports non-interactive arguments:
--confirm: confirm the resume action--strategy recommended: use recommended approach--strategy mock: use mock/dummy secrets--strategy skip: skip current milestone--strategy extend-review: extend review budget +1Run:
.claude/skills/cc-codex-collaborate/scripts/cccc-resume.sh [--confirm] [--strategy <strategy>]
The script only updates state and outputs guidance. It does NOT execute Codex review or implement code. The actual continuation is driven by the SKILL.md state machine.
Codex must not directly modify files. Codex reviews using context and returns structured JSON.
This is a P0 invariant. Codex review is NEVER optional.
Rules:
PAUSED_FOR_CODEX.status = pass for that milestone and review round.Invariants (memorize these):
No Codex plan review, no implementation.
No Codex milestone review, no milestone pass.
No Codex final review, no task completion.
Codex unavailable means pause, not skip.
Before implementation:
.claude/skills/cc-codex-collaborate/scripts/cccc-codex-check.sh to verify Codex availability..claude/skills/cc-codex-collaborate/scripts/cccc-assert-codex-gates.py assert-plan-approved to verify plan approval.status = PAUSED_FOR_CODEX.Before marking milestone passed:
cccc-assert-codex-gates.py assert-milestone-approved.cccc-codex-milestone-review.sh and wait for result.Before marking task DONE:
cccc-assert-codex-gates.py assert-final-approved.cccc-codex-final-review.sh.Before planning or asking any question, detect the user's primary language.
Detection priority:
config.json language.user_language if not "auto".Store it in docs/cccc/config.json as language.user_language.
All human-facing output must use user_language. Codex may reason in English, but Claude Code must summarize and ask questions in the user's language.
SETUP_OR_BOOTSTRAP
↓
INIT
↓
DETECT_USER_LANGUAGE
↓
DISCOVER_EXISTING_PROJECT
↓
BUILD_PROJECT_CONTEXT
↓
CLAUDE_PLANNING_REVIEW
├─ READ_MORE_PROJECT → DISCOVER_EXISTING_PROJECT
├─ ASK_HUMAN → PAUSE_FOR_HUMAN
└─ OK
↓
CODEX_ADVERSARIAL_PLAN_REVIEW
├─ INSUFFICIENT_CONTEXT → DISCOVER_EXISTING_PROJECT
├─ REJECTED_FIXABLE → CLAUDE_REVISE_PLAN
├─ NEEDS_HUMAN → PAUSE_FOR_HUMAN
├─ UNSAFE → PAUSE_FOR_HUMAN
└─ APPROVED
↓
IMPLEMENT_MILESTONE
↓
CLAUDE_SELF_REVIEW
↓
CODEX_MILESTONE_REVIEW
├─ PASS → RECORD_ACCEPTANCE → PLAN_NEXT_MILESTONE
├─ FAIL_FIXABLE → CLAUDE_FIX → CLAUDE_SELF_REVIEW
├─ FAIL_UNCLEAR → PAUSE_FOR_HUMAN
├─ NEEDS_HUMAN → PAUSE_FOR_HUMAN
├─ SENSITIVE_OPERATION → PAUSE_FOR_HUMAN
└─ MAX_REVIEW_EXCEEDED → THRESHOLD_POLICY
PAUSED_FOR_HUMAN / NEEDS_HUMAN / PAUSED_FOR_SYSTEM
PAUSED_FOR_CODEX / NEEDS_SECRET / SENSITIVE_OPERATION
UNSAFE / FAIL_UNCLEAR / REVIEW_THRESHOLD_EXCEEDED
↓ (resume with /cc-codex-collaborate resume)
READY_TO_CONTINUE
↓ (re-enter appropriate gate)
└─→ CODEX_ADVERSARIAL_PLAN_REVIEW / CODEX_MILESTONE_REVIEW / IMPLEMENT_MILESTONE
No implementation may start until project discovery is complete and the initial roadmap has passed Claude self-review plus Codex adversarial plan review, unless the human explicitly chooses to override after a pause.
Thresholds are stored in docs/cccc/config.json. Read them from there, not from state.json.
Default thresholds (recommended preset):
{
"planning": {
"max_plan_review_rounds": 3
},
"milestones": {
"max_milestones_per_run": 5,
"max_diff_lines_per_milestone": 1200,
"max_changed_files_per_milestone": 20
},
"review": {
"max_review_rounds_per_milestone": 3,
"max_fix_attempts_per_milestone": 3,
"block_on_p0": true,
"block_on_p1": true,
"allow_continue_with_p2": true
},
"automation": {
"stop_hook_loop_enabled": false,
"max_stop_hook_continuations": 10
}
}
Supported modes:
manual: pause after each major phase.supervised-auto: default. Planning is strictly reviewed; implementation can loop automatically until risk or threshold.full-auto-safe: optional Stop hook can continue safe unfinished work, but never bypass hard pause conditions.Immediately pause and ask the human if any of these occur:
needs_human: true.max_review_rounds_per_milestone from config.Never ask the user to paste real secrets into chat. Ask them to configure secrets locally in a sandboxed environment.
When clarification is needed, use a Superpowers-inspired brainstorming interaction.
Do not ask vague open-ended questions by default. Instead, present:
Other option where the user can type their own answerExample format in Chinese:
在规划数据库 milestone 前,需要确认持久化策略。
请选择:
A. 使用现有数据库层,暂时不改 schema。推荐。
B. 新增 migration,但只针对本地 / 开发环境。
C. 第一个 milestone 先用内存 adapter,暂缓持久化。
D. Other:输入你的偏好方案。
Example format in English:
I need to clarify the persistence strategy before planning database milestones.
Choose one:
A. Use the existing database layer and avoid schema changes for now. Recommended.
B. Add a new migration, but only for local/dev databases.
C. Defer persistence and use an in-memory adapter for the first milestone.
D. Other: describe your preferred approach.
Record human answers in:
docs/cccc/decision-log.mddocs/cccc/open-questions.mdProjects are often not greenfield. Before planning, inspect and summarize the existing project.
Read relevant files and directories such as:
Do not write business code during discovery.
Create or update:
docs/cccc/project-map.mddocs/cccc/current-state.mddocs/cccc/architecture.mddocs/cccc/test-strategy.mddocs/cccc/risk-register.mddocs/cccc/open-questions.mdAfter discovery, create:
docs/cccc/project-brief.mddocs/cccc/roadmap.mddocs/cccc/milestone-backlog.mdEach milestone must include:
Before asking Codex to review a plan, Claude Code must challenge its own plan.
Ask:
If the answer indicates risk or missing context, read more project files or ask the human with options.
Codex must review the initial plan adversarially before implementation begins.
Codex should try to reject the plan by finding:
Only approve if the roadmap is clear, safe, scoped, testable, and aligned with the discovered project.
Before every Codex call, regenerate:
docs/cccc/context-bundle.md
The context bundle must include:
Hard rule:
No context bundle, no Codex planning.
No project discovery, no roadmap.
No approved roadmap, no implementation.
No config.json, run setup first.
For each milestone:
docs/cccc/config.json.docs/cccc/context-bundle.md.Codex may suggest the next milestone only from the existing roadmap and milestone backlog. Codex must not expand scope.
Claude Code must validate that the proposed next milestone:
The optional Stop hook (cccc-stop.sh) reads configuration from docs/cccc/config.json and runtime state from docs/cccc/state.json.
It may block the stop (returning decision: "block") only when all of these conditions are met:
docs/cccc/config.json exists and automation.stop_hook_loop_enabled is truedocs/cccc/config.json mode is full-auto-safedocs/cccc/state.json existsstatus is not a terminal or paused state (DONE, COMPLETED, FAILED, PAUSED_FOR_HUMAN, NEEDS_HUMAN, NEEDS_SECRET, SENSITIVE_OPERATION, UNSAFE, PAUSED_FOR_SYSTEM, PAUSED_FOR_CODEX)pause_reason is emptystop_hook_active in the hook input is not true (prevents infinite recursion)automation.max_stop_hook_continuations (from config.json)status is not SETUP_COMPLETE with no milestone and no backlog (prevents empty-spin)The stop hook allows READY_TO_CONTINUE status to proceed — this is the status set after a successful resume.
When the hook blocks, it outputs a reason that instructs Claude to continue the state machine loop internally — not just take one small step and stop again. The skill's internal state machine must drive the actual loop; the hook merely prevents Claude Code from stopping prematurely.
The Stop hook must never continue past hard pause conditions.
Use the user's language (from config.json language.user_language).
Chinese:
Milestone M001:<标题>
状态:实现中 / Review 中 / 修复中 / 已通过 / 已暂停
Review 轮次:1/3
最近检查:<测试结果或跳过原因>
决策:<下一步动作>
English:
Milestone M001: <title>
Status: implementing / reviewing / fixing / passed / paused
Review round: 1/3
Last check: <test result or reason skipped>
Decision: <next action>