Skip to content

Rubbish0-A/codex-delegate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

codex-delegate banner

codex-delegate

The lightweight Claude Code + Codex CLI collaboration plugin.

Zero dependencies. Pure Bash. Git-safe. Battle-tested on Windows.

English | ไธญๆ–‡

Claude thinks. Codex executes. Neither steps on the other's work.


Why This Plugin?

Claude Code has no built-in Codex integration. You can run codex exec via Bash, but that's a raw subprocess with no safety net โ€” no git protection, no output capture, no timeout, no structured handoff.

OpenAI ships an official plugin (codex-plugin-cc), but it's a heavy Node.js/TypeScript stack with 15+ library files, an app-server broker layer, and npm install required.

codex-delegate takes a different approach: 3 Bash scripts, 1 skill, 1 command. That's it. No build step. No runtime dependencies. Clone and go.

Comparison

Raw Bash OpenAI Official Plugin codex-delegate
Install complexity N/A npm install + app server Clone only
Runtime deps None Node.js 18+ None (pure Bash)
Git safety None None Auto-stash, HEAD record, rollback info
Timeout protection None None Configurable CODEX_TIMEOUT
Interrupt safety None None trap cleanup + stash warning
Test-fix cycle Manual None Built-in (run โ†’ fix โ†’ re-run, max N rounds)
Collaboration modes None None Cautious / Quick / Diagnosis
Delegation judgment None Basic Teaches Claude WHEN to delegate, not just HOW
Output capture stdout only Structured -o file + stdout dual-channel
Background jobs Manual /codex:status/result/cancel Via Claude Code native
Adversarial review None /codex:adversarial-review Via review prompt customization
Review gate (Stop hook) None Built-in Not included
Session resume Manual --resume Not included
Windows tested Fragile Unknown Tested on Windows 11 + Git Bash
Bilingual No English only Chinese + English triggers
Codebase size 0 ~3000 lines (TS/MJS) ~300 lines (Bash)

Where codex-delegate wins

1. Git Safety โ€” No Other Plugin Does This

Every Codex invocation is wrapped in a safety harness:

  • Pre-flight: detect dirty working tree โ†’ auto-stash with timestamp tag
  • Record HEAD for rollback reference
  • Post-flight: print git diff --stat, new files, rollback commands
  • On interrupt: trap ensures stash warning is printed, temp files cleaned

2. Test-Fix Cycle โ€” A Dedicated Workflow

run-codex-testfix.sh automates the most tedious debugging loop:

Round 1: run tests โ†’ 4 failures โ†’ Codex fixes โ†’ re-run
Round 2: 1 failure remains โ†’ Codex fixes โ†’ re-run
Round 3: all pass โœ“

No other Codex plugin has this as a first-class feature.

3. Collaboration Modes โ€” Claude Stays In Control

Mode Flow When
Cautious (default) Codex proposes (read-only) โ†’ Claude reviews โ†’ Codex executes Multi-file changes, unfamiliar code
Quick Codex executes directly Simple renames, formatting
Diagnosis Codex reads only, Claude decides Bug investigation

The official plugin has "rescue" (fire-and-forget delegation). codex-delegate has a review checkpoint before execution.

4. Lightweight & Portable

codex-delegate/          openai/codex-plugin-cc/
โ”œโ”€โ”€ scripts/ (3 files)   โ”œโ”€โ”€ scripts/lib/ (15 files)
โ”œโ”€โ”€ skills/ (1 SKILL)    โ”œโ”€โ”€ agents/ hooks/ prompts/ schemas/
โ”œโ”€โ”€ commands/ (1 cmd)    โ”œโ”€โ”€ commands/ (7 commands)
โ””โ”€โ”€ 300 lines total      โ””โ”€โ”€ ~3000 lines + npm deps

Where the official plugin wins

  • Background job management: /codex:status, /codex:result, /codex:cancel โ€” proper job lifecycle
  • Adversarial review: Devil's advocate mode that challenges design decisions
  • Review gate: Stop hook that blocks Claude from completing until Codex approves
  • Session resume: --resume to continue a previous Codex thread

Choose codex-delegate if you want safety, simplicity, and test-fix automation. Choose the official plugin if you want background job control and review gates.


Features

Feature Description
Smart delegation Claude learns WHEN to delegate via SKILL.md โ€” not every task goes to Codex
Git safety harness Auto-stash, HEAD recording, diff output, rollback commands, interrupt protection
Test-fix cycle Automated run โ†’ fix โ†’ re-run loop with configurable max rounds
Cross review Codex reviews Claude's code independently for bugs, security, performance
Bug diagnosis Read-only analysis mode โ€” Codex investigates, Claude decides
Timeout protection Configurable CODEX_TIMEOUT (default 300s) prevents indefinite hangs
Dual trigger Natural language ("ไบค็ป™ codex") or slash command (/codex <task>)
Bilingual Chinese + English trigger phrases and documentation

Install

Quick Start

# 1. Register marketplace
/plugin marketplace add Rubbish0-A/codex-delegate

# 2. Install
/plugin install codex-delegate@codex-delegate

# 3. Reload
/reload-plugins

Prerequisites

  • Codex CLI installed (npm install -g @openai/codex)
  • OpenAI API key or ChatGPT subscription configured in Codex
  • Git (for safety features)

Full setup guide with API proxy configuration: skills/delegate-to-codex/references/setup-guide.md


Usage

Natural Language

"ๆŠŠ่ฟ™ไธช็™ปๅฝ•ๆŽฅๅฃ็š„ๅ‚ๆ•ฐๆ ก้ชŒไบค็ป™ codex ๅฎž็Žฐ"
"่ฎฉ codex ไฟฎไธ€ไธ‹ src/auth/ ไธ‹้ข็š„ๆต‹่ฏ•"
"็”จ codex review ไธ€ไธ‹ๅฝ“ๅ‰็š„ๆ”นๅŠจ"
"codex ๆŸฅไธ€ไธ‹่ฟ™ไธชๆŽฅๅฃไธบไป€ไนˆ่ฟ”ๅ›ž 500"

Slash Command

/codex implement user registration with input validation
/codex fix the failing tests in src/auth/
/codex review
/codex review check for SQL injection vulnerabilities

Workflow Examples

Cross Review (Claude writes โ†’ Codex reviews)

You: "ๅธฎๆˆ‘ๅฎž็Žฐ็”จๆˆทๆณจๅ†ŒๆŽฅๅฃ"
Claude: [writes code]
Claude: "ไปฃ็ ๅ†™ๅฎŒไบ†๏ผŒ่ฆไธ่ฆ่ฎฉ Codex ๅšไธชไบคๅ‰ๅฎกๆŸฅ๏ผŸ"
You: "ๅฅฝ"
โ†’ Codex reports 2 HIGH + 3 MEDIUM issues
โ†’ Claude analyzes each finding with you

Test-Fix Cycle

You: "ๆต‹่ฏ•่ท‘ไธ่ฟ‡๏ผŒ่ฎฉ codex ไฟฎไธ€ไธ‹"
โ†’ Round 1: 4 failures โ†’ Codex fixes โ†’ re-run
โ†’ Round 2: 1 failure โ†’ Codex fixes โ†’ re-run  
โ†’ Round 3: All pass โœ“
โ†’ Claude reviews the fixes before reporting

Bug Diagnosis (read-only)

You: "่ฟ™ไธชๆŽฅๅฃ่ฟ”ๅ›ž 500๏ผŒ่ฎฉ codex ๆŸฅไธ€ไธ‹"
โ†’ Codex reads code without modifying anything
โ†’ Reports: root cause is unhandled null in db.query()
โ†’ Claude evaluates and discusses fix options with you

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  User                         โ”‚
โ”‚  "ไบค็ป™ codex"  /  /codex <task>              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            Claude (Brain)                     โ”‚
โ”‚                                               โ”‚
โ”‚  SKILL.md teaches:                            โ”‚
โ”‚  โ€ข WHEN to delegate (judgment criteria)       โ”‚
โ”‚  โ€ข HOW to delegate (collaboration modes)      โ”‚
โ”‚  โ€ข Conflict prevention rules                  โ”‚
โ”‚  โ€ข Post-delegation verification               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚ Bash tool
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Safety Scripts (Bash)                 โ”‚
โ”‚                                               โ”‚
โ”‚  Pre-flight:                                  โ”‚
โ”‚  โœ“ codex CLI check                            โ”‚
โ”‚  โœ“ git stash uncommitted changes              โ”‚
โ”‚  โœ“ record HEAD for rollback                   โ”‚
โ”‚                                               โ”‚
โ”‚  Execute:                                     โ”‚
โ”‚  โœ“ timeout protection (CODEX_TIMEOUT)         โ”‚
โ”‚  โœ“ stdin closed (< /dev/null)                 โ”‚
โ”‚  โœ“ output captured (-o file + stdout)         โ”‚
โ”‚                                               โ”‚
โ”‚  Post-flight:                                 โ”‚
โ”‚  โœ“ git diff --stat                            โ”‚
โ”‚  โœ“ rollback commands                          โ”‚
โ”‚  โœ“ stash restore reminder                     โ”‚
โ”‚                                               โ”‚
โ”‚  On interrupt:                                โ”‚
โ”‚  โœ“ trap cleanup (temp files + stash warning)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          Codex CLI (Hands)                    โ”‚
โ”‚                                               โ”‚
โ”‚  codex exec --full-auto --ephemeral          โ”‚
โ”‚  Sandboxed execution (workspace-write)        โ”‚
โ”‚  Results returned to Claude                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Configuration

Environment Variables

Variable Default Description
CODEX_TIMEOUT 300 (task/review), 600 (testfix) Max seconds before killing Codex process

Codex Model / Effort

Edit ~/.codex/config.toml:

model = "gpt-5.4"
model_reasoning_effort = "xhigh"

Plugin Structure

codex-delegate/
โ”œโ”€โ”€ .claude-plugin/
โ”‚   โ”œโ”€โ”€ plugin.json              # Plugin manifest
โ”‚   โ””โ”€โ”€ marketplace.json         # Marketplace discovery
โ”œโ”€โ”€ commands/
โ”‚   โ””โ”€โ”€ codex.md                 # /codex slash command
โ”œโ”€โ”€ skills/
โ”‚   โ””โ”€โ”€ delegate-to-codex/
โ”‚       โ”œโ”€โ”€ SKILL.md             # Core: teaches Claude delegation logic
โ”‚       โ””โ”€โ”€ references/
โ”‚           โ”œโ”€โ”€ codex-cli-reference.md
โ”‚           โ”œโ”€โ”€ setup-guide.md
โ”‚           โ””โ”€โ”€ workflow-patterns.md
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ run-codex-task.sh        # Task execution (full-auto / read-only)
โ”‚   โ”œโ”€โ”€ run-codex-review.sh      # Code review
โ”‚   โ””โ”€โ”€ run-codex-testfix.sh     # Test-fix cycle (max N rounds)
โ””โ”€โ”€ README.md

Troubleshooting

Problem Solution
[ERROR] codex CLI not found npm install -g @openai/codex
401 Unauthorized Configure OPENAI_API_KEY or run codex login
Codex hangs on stdin Already fixed in v1.4.1+ (< /dev/null)
Timeout on large projects Increase: export CODEX_TIMEOUT=600
Plugin not loaded Complete marketplace registration, then /reload-plugins
Codex made wrong changes Rollback: git checkout -- . && git clean -fd
Stash lost after interrupt Check: git stash list โ€” auto-stashes are tagged with timestamps

Changelog

v1.4.2 (2026-04-14)

  • Add codex CLI pre-flight check
  • Add trap cleanup for temp files and stash safety on interrupt
  • Add configurable timeout (CODEX_TIMEOUT env var)
  • Convert FLAGS from string to bash array for safe expansion
  • Add -o output capture to codex review
  • Add SCRIPT_COMPLETED guard to avoid duplicate stash warnings

v1.4.1 (2026-04-14)

  • Close stdin (< /dev/null) on all codex invocations to prevent hang

v1.4.0

  • Flexible collaboration modes (Cautious / Quick / Diagnosis)

v1.3.0

  • Fix plugin discovery, update install guide

v1.2.1

  • Optimize for lightweight, practical, quality

License

MIT


3 scripts. 300 lines. Zero dependencies. Full git safety.

Made for developers who want Claude and Codex to collaborate โ€” without the complexity.

About

Claude Code + Codex CLI intelligent collaboration plugin

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages