codex-collab
Skill1 starsChanged 7 months agoMITView on GitHub
Background dual-agent collaboration with Codex CLI. Sends tasks to Codex via `codex exec` in the background, captures JSONL output, and integrates results without blocking Claude Code. No tmux, no Terminal windows. Use when asked to "codex collab", "dual agent", "pair with codex", "codex tmux", "collaborate with codex", "let codex help", or "spiral coding".
- Deletes or force-pushes
- Installs packages
3 other projects use a version of this.
Adopted by
Most recently taken up by
- xzljq/claude-skillstheir own version, first seen Oct 13, 2026
- zane-gao/codex-collabtheir own version, first seen Oct 11, 2026
- Kevin7Qi/codex-collabtheir own version, first seen Feb 28, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- Kevin7Qi/codex-collab★ 99same name
- zane-gao/codex-collab★ 1same name
- xzljq/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ascii-renderingSkill
- claude-code-dissectSkill
- hermes-agent-dissectSkill
- market-dataSkill
- mogu-visualSkill
- particle-effectsSkill
- podcast-to-mdSkill
- twitter-scraperSkill
- web-searchSkill
- xiaohongshu-to-markdownSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. 0 are common, 17 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
17
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 59
Check that codex is available:
- Very specific: line 67
If codex is NOT_FOUND, stop and tell the user:
- Distinctive: line 74
Use the current working directory or the git repository root:
- Distinctive: line 119
Use single quotes around the prompt text in the echo to avoid shell expansion
- Distinctive: line 142
When you need the result (or are notified the background task completed), read the output files:
- Very specific: line 150
If STILL_RUNNING, the background Bash command hasn't completed yet.
- Distinctive: line 174
If there are errors, check:
- Distinctive: line 193
After receiving Codex's response:
- Distinctive: line 195
Analyze: Read and understand what Codex said
- Distinctive: line 198
If you and Codex agree -> execute the plan (edit files, run tests, etc.)
- Distinctive: line 199
If you disagree -> explain the disagreement to the user, ask for direction
- Distinctive: line 200
If more context needed -> send a follow-up task to Codex (new task ID)
- Distinctive: line 201
If Codex found something you missed -> investigate it yourself first
- Distinctive: line 209
Challenge: Ask Codex to find holes in your implementation
- Distinctive: line 221
When the collaboration is complete:
- Distinctive: line 233
When sending prompts to Codex:
- Distinctive: line 237
One task per message: Don't bundle multiple unrelated questions.
- Very specific: line 253
Codex not in git repo: Ensure -C points to a git repository
- Very specific: line 254
Codex exec fails: Check the .err file for error details
- Very specific: line 265
Non-blocking: ALWAYS use run_in_background: true when sending tasks to Codex.
- Very specific: line 267
No Terminal windows: NEVER use open -a Terminal, osascript, or any command that opens GUI windows.
- Distinctive: line 271
Transparency: Always show the user what you're sending to Codex and what Codex responded.
- Distinctive: line 276
Don't send vague "what do you think?" messages.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/codex-collab — Claude + Codex Background Collaboration
You are running the /codex-collab skill. This sends tasks to Codex CLI
via codex exec --full-auto --json in the background, captures structured
JSONL output, and integrates results — all without blocking Claude Code or
opening any extra windows.
This is NOT the same as codex:codex-rescue (which uses the shared Codex
runtime). This skill runs a standalone Codex process per task.
Architecture
Claude Code (foreground) Codex (background process)
┌──────────────────────┐ ┌──────────────────────┐
│ │ Bash bg │ │
│ Send task ──────────────────────► │ codex exec │
│ │ │ --full-auto --json │
│ Continue working │ │ > output.jsonl │
│ on other things │ │ │
│ │ Read file │ Writes JSONL events │
│ Read results ◄────────────────── │ to output file │
│ │ │ │
│ Integrate & iterate │ └──────────────────────┘
└──────────────────────┘Key advantages over v1 (tmux-based):
- No Terminal windows opened — zero visual clutter
- Non-blocking — Claude Code continues while Codex works
- Structured output — JSONL events, no TUI scraping
- Reliable — no Ink TUI quirks, no tmux send-keys timing issues
Step 0: Preflight
Check that codex is available:
CODEX_BIN=$(which codex 2>/dev/null || echo "")
echo "codex: ${CODEX_BIN:-NOT_FOUND}"
codex --version 2>/dev/null || trueIf codex is NOT_FOUND, stop and tell the user:
- codex:
npm install -g @openai/codexorbun install -g @openai/codex
Step 1: Determine Working Directory
Use the current working directory or the git repository root:
WORK_DIR=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
echo "WORK_DIR: $WORK_DIR"Important: codex exec requires being inside a git repository. If the
working directory is not a git repo, warn the user.
Step 2: Create Session Directory
Each collaboration session gets a directory under /tmp/codex-collab/:
SESSION_ID=$(date +%s)
SESSION_DIR="/tmp/codex-collab/$SESSION_ID"
mkdir -p "$SESSION_DIR"
echo "SESSION_DIR: $SESSION_DIR"Step 3: Send a Task to Codex (Background)
To send a task to Codex, use the Bash tool with run_in_background: true.
This is the key difference from v1 — Claude Code is NOT blocked.
The command pattern:
TASK_ID=1 # increment for each task in the session
echo '<prompt_text>' | codex exec \
--full-auto \
--json \
--ephemeral \
-C "$WORK_DIR" \
> "$SESSION_DIR/task_${TASK_ID}.jsonl" \
2> "$SESSION_DIR/task_${TASK_ID}.err"
echo "CODEX_EXIT=$?" >> "$SESSION_DIR/task_${TASK_ID}.status"Critical rules for the prompt:
- Use single quotes around the prompt text in the echo to avoid shell expansion
- For prompts containing single quotes, use a heredoc instead:
codex exec --full-auto --json --ephemeral -C "$WORK_DIR" \ > "$SESSION_DIR/task_${TASK_ID}.jsonl" \ 2> "$SESSION_DIR/task_${TASK_ID}.err" \ << 'PROMPT' Your prompt text here, can contain any characters PROMPT echo "CODEX_EXIT=$?" >> "$SESSION_DIR/task_${TASK_ID}.status"
Always use run_in_background: true for the Bash tool call so Claude Code
can continue working while Codex processes the task.
Tell the user:
Codex 任务 #N 已在后台启动,你可以继续其他工作。稍后我会检查结果。
Step 4: Check Task Status
When you need the result (or are notified the background task completed), read the output files:
# Check if task is done
cat "$SESSION_DIR/task_${TASK_ID}.status" 2>/dev/null || echo "STILL_RUNNING"If STILL_RUNNING, the background Bash command hasn't completed yet. You'll be
notified automatically when it finishes — do NOT poll or sleep.
Step 5: Extract the Response
Once the task is complete, read the JSONL output:
cat "$SESSION_DIR/task_${TASK_ID}.jsonl"Parse the JSONL events. The key event types:
{"type":"thread.started","thread_id":"..."}— session started{"type":"turn.started"}— a turn began{"type":"item.completed","item":{"type":"agent_message","text":"..."}}— Codex's response text{"type":"item.completed","item":{"type":"tool_call",...}}— Codex executed a tool{"type":"item.completed","item":{"type":"tool_output",...}}— tool output{"type":"turn.completed","usage":{...}}— turn finished with token usage
Extract the agent_message text from item.completed events. That is
Codex's response.
If there are errors, check:
cat "$SESSION_DIR/task_${TASK_ID}.err"Present the response to the user:
Codex 回复 (任务 #N):
────────────────────────────────────────
<extracted response>
────────────────────────────────────────Step 6: Spiral Collaboration Loop
After receiving Codex's response:
- Analyze: Read and understand what Codex said
- Synthesize: Combine Codex's insight with your own analysis
- Act or Iterate:
- If you and Codex agree -> execute the plan (edit files, run tests, etc.)
- If you disagree -> explain the disagreement to the user, ask for direction
- If more context needed -> send a follow-up task to Codex (new task ID)
- If Codex found something you missed -> investigate it yourself first
Collaboration patterns:
- Divide and conquer: You handle file A, send Codex to review file B
- Verify: You implement, send Codex to review your changes
- Brainstorm: You propose approach A, ask Codex for alternatives
- Debug: You share error context, ask Codex for diagnosis
- Challenge: Ask Codex to find holes in your implementation
For each iteration, increment the task ID and go back to Step 3.
Important: Since each codex exec is a fresh process, you must include
sufficient context in each prompt. Codex does NOT remember previous tasks.
Include relevant file paths, previous decisions, and constraints.
Step 7: Cleanup
When the collaboration is complete:
rm -rf "$SESSION_DIR"Tell the user: "Codex 协作已完成,临时文件已清理。"
Prompt Composition Guidelines
When sending prompts to Codex:
- Be an operator, not a collaborator. Give Codex clear, scoped tasks.
- Provide context inline. Tell Codex which files to look at by path.
- One task per message. Don't bundle multiple unrelated questions.
- Be specific about output format. Tell Codex what you want back: a diff, a list of issues, a yes/no verdict, etc.
- Include the working directory context. Codex runs with
-C $WORK_DIRso it can read files in the repo, but explicit paths help.
Example prompts:
- "Review src/auth.ts for security issues. Focus on token handling. List each issue with file:line and severity."
- "What's the simplest way to add rate limiting to the /api/chat endpoint? Return a concrete implementation plan."
- "Find all places where we catch errors but don't log them. Return file paths and line numbers."
- "Read the diff in CHANGES.md and write a changelog entry for it."
Error Handling
- Codex not in git repo: Ensure
-Cpoints to a git repository - Codex exec fails: Check the
.errfile for error details - Timeout:
codex exechas no built-in timeout. If a task seems stuck (background process not completing after 10+ minutes), inform the user and consider killing the process - Multiple concurrent tasks: Each task gets its own files in
$SESSION_DIR, so multiple background tasks can run simultaneously without conflict
Important Rules
- Non-blocking: ALWAYS use
run_in_background: truewhen sending tasks to Codex. Claude Code should NEVER block waiting for Codex. - No Terminal windows: NEVER use
open -a Terminal,osascript, or any command that opens GUI windows. Everything runs headlessly. - No tmux: This skill does NOT use tmux. All interaction is through
codex execand file I/O. - Transparency: Always show the user what you're sending to Codex and what Codex responded. No hidden conversations.
- No blind trust: Codex's suggestions should be verified. Don't apply changes without understanding them first.
- Keep it focused: Each Codex task should have a clear purpose. Don't send vague "what do you think?" messages.
- Context per task: Each
codex execis stateless. Include all necessary context in each prompt.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

