| name | codex-orchestrator |
| description | Spawn specialized OpenAI Codex CLI subagents for code review, debugging, architecture analysis, security audits, refactoring, and documentation via AGENTS.md persona injection (gpt-5.5, gpt-5.5-pro, gpt-5-mini). Triggers on 'delegate to Codex', 'Codex subagent', 'code review agent', 'security audit', 'refactor with Codex'. |
Codex Orchestrator
Spawn specialized Codex CLI subagents for focused development tasks. Each profile injects a custom AGENTS.md persona that shapes the agent's behavior, focus areas, and output format.
Architecture
Claude Code (orchestrator)
↓ invokes skill
codex-orchestrator scripts
↓ spawns via Bash
Codex CLI with AGENTS.md
↓ executes
Specialized subagent task
Prerequisites
Verify Codex CLI is installed and configured:
~/.claude/skills/codex-orchestrator/scripts/codex-status.sh
Required:
- Codex CLI:
npm install -g @openai/codex
- API Key:
export OPENAI_API_KEY=sk-...
Auto-Update
The skill automatically checks for Codex CLI updates on each invocation and updates if needed. This prevents issues caused by outdated CLI versions.
To manually check/update:
~/.claude/skills/codex-orchestrator/scripts/codex-version-check.sh
~/.claude/skills/codex-orchestrator/scripts/codex-version-check.sh --auto-update
Available Profiles
| Profile | Purpose | Use When |
|---|
reviewer | Code quality, bugs, performance | Pre-commit review, PR assessment |
debugger | Root cause analysis, fixes | Investigating bugs, tracing issues |
architect | System design, component boundaries | Planning changes, evaluating architecture |
security | OWASP, vulnerabilities, secrets | Security audits, compliance checks |
refactor | Code cleanup, modernization | Reducing tech debt, improving structure |
docs | API docs, READMEs, comments | Documentation tasks |
planner | ExecPlan design documents | Multi-hour tasks, complex features, significant refactors |
syseng | Infrastructure, DevOps, CI/CD, monitoring | Deployment, containers, observability, production ops |
builder | Greenfield implementation, new features | Creating new code from specs, incremental feature development |
researcher | Read-only Q&A, codebase analysis | Questions, analysis, comparisons (no file changes) |
chat | Open-ended conversation | General questions, brainstorming, discussion (read-only, ephemeral) |
Quick Execution
Execute a one-shot task with a specific profile:
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh <profile> "<prompt>"
Examples:
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh reviewer "Review src/auth.ts for security issues"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh debugger "Debug the login timeout on slow networks"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh architect "Design a caching layer for the API"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh security "Audit the payment module for vulnerabilities"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh reviewer "Fix all lint errors"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh planner "Create an ExecPlan for adding WebSocket support"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "Implement user authentication with JWT"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "continue"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "What are the tradeoffs of event sourcing vs CRUD?"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "Explain quantum error correction" --api --model gpt-5.5
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "What is the tallest mountain?" --api --session /tmp/chat.json
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "And the deepest ocean?" --api --session /tmp/chat.json
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "Tell me about CQRS" --api --model gpt-5.5 --stream
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh researcher "Explain the authentication flow in this project"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh researcher "What are the latest React Server Component patterns?" --web-search
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh researcher "What are the latest React patterns?" --search
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh reviewer "Review this mockup for UX issues" --image screenshot.png
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "continue" --resume
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh researcher "What is 2+2?" --json | head -5
Session Management
For more control, use the Python session manager:
python3 ~/.claude/skills/codex-orchestrator/scripts/codex-session.py list
python3 ~/.claude/skills/codex-orchestrator/scripts/codex-session.py start debugger "Trace the null pointer in UserService"
python3 ~/.claude/skills/codex-orchestrator/scripts/codex-session.py interactive architect
python3 ~/.claude/skills/codex-orchestrator/scripts/codex-session.py info security
Profile Selection Guide
Review Tasks
- reviewer for general code quality and bugs
- security for vulnerability-focused review
- refactor for cleanup opportunities
Investigation Tasks
- debugger for bug investigation
- architect for understanding system behavior
- researcher for questions and analysis (read-only, no changes)
- chat for open-ended conversation and brainstorming (read-only, ephemeral)
Creation Tasks
- architect for design decisions
- builder for new feature implementation
- docs for documentation
- refactor for implementation improvements
- planner for multi-hour implementation plans
Chaining Patterns
Review → Debug → Fix
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh reviewer "Review src/api/ for bugs"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh debugger "Debug the race condition found in cache.ts"
Planner → Architect → Builder
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh planner "Create ExecPlan for new authentication system"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh architect "Review the auth system ExecPlan for design issues"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "Implement milestone 1 from the auth ExecPlan"
Architect → Builder → Reviewer
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh architect "Design a caching layer for the API"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "Implement the caching layer from architect's design"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh reviewer "Review the new caching implementation"
Architect → Review → Refactor
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh architect "Design repository layer extraction"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh reviewer "Review the proposed repository pattern"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh refactor "Extract repository pattern from services"
Syseng → Architect → Planner
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh syseng "Evaluate current deployment for scaling to 10x traffic"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh architect "Design infrastructure to support 10x scale"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh planner "Create ExecPlan for infrastructure scaling"
Security → Syseng
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh security "Audit the Kubernetes cluster configuration"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh syseng "Implement security recommendations from audit"
Researcher → Architect → Builder
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh researcher "How does the current caching work? What are its limitations?"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh architect "Design a new caching layer addressing the limitations"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "Implement the caching layer from architect's design"
Script Options
codex-exec.sh Options
| Option | Description |
|---|
--model <model> | Override model (default: per-profile, see below) |
--reasoning <level> | Override reasoning effort: minimal, low, medium, high, xhigh |
--sandbox <mode> | read-only, workspace-write, danger-full-access |
--no-approve | Force read-only sandbox (no file writes) |
--web-search | Enable Exa web search (injects guide into AGENTS.md) |
--search | Enable native Codex web search (model-level tool, works in all sandboxes) |
--json | Output JSONL event stream (pipe to jq, logs, etc.) |
--image <file> | Attach image to prompt (vision input) |
--resume | Resume previous exec session (builder "continue" workflow) |
--with-mcp | (no-op, kept for compatibility; manage MCPs in ~/.codex/config.toml) |
--api | Use OpenAI API directly (API billing, not Codex subscription) |
--session <file> | Session file for multi-turn API chat (requires --api) |
--system <prompt> | System prompt for API chat (requires --api) |
--stream | Stream API response tokens (requires --api) |
Model & Reasoning Defaults
Each profile has a default model and reasoning effort. User flags override these.
| Profile Type | Profiles | Model | Reasoning |
|---|
| Coding | builder, reviewer, debugger, refactor, syseng, security, docs | gpt-5.5 | high |
| Planning | planner, architect | gpt-5.5 | high |
| Research | researcher | gpt-5.5 | medium |
| Chat | chat | gpt-5.4 | medium |
Reasoning effort levels: none < minimal < low < medium < high < xhigh
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "Implement auth module"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh planner "Create ExecPlan for caching"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh reviewer "Style check" --model gpt-5-mini
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh builder "Quick lint fix" --reasoning medium
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh planner "Design distributed cache" --model gpt-5.5 --reasoning high
API Mode (Direct OpenAI API)
The --api flag bypasses Codex CLI entirely and calls the OpenAI API directly via gpt-api-chat.py. Billing goes to your OPENAI_API_KEY, not the Codex subscription.
When to use API mode:
- Access models not in your Codex subscription (e.g.
gpt-5.5)
- Multi-turn conversations with session persistence
- Streaming responses
- Custom system prompts
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "Explain X" --api --model gpt-5.5
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "What is X?" --api --session /tmp/session.json
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "Tell me more" --api --session /tmp/session.json
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "Describe Y" --api --model gpt-5.5 --stream
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh chat "Analyze this" --api --system "You are a security analyst"
~/.claude/skills/codex-orchestrator/scripts/codex-exec.sh researcher "What are the latest React patterns?" --api --model gpt-5.5
Supported models: gpt-5.5, gpt-5.5-pro, gpt-5.4, gpt-5-mini, o3, o4-mini, o3-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4o, gpt-4o-mini, gpt-4-turbo
Three-way mode (Claude + GPT): Within a Claude Code session, invoke gpt-api-chat.py via Bash, read GPT's response, synthesize perspectives, and steer the conversation. Use --session to maintain GPT's context across turns.
Requires: OPENAI_API_KEY in environment (loaded from ~/.config/env/secrets.env)
Testing
Run the test suite to verify installation:
~/.claude/skills/codex-orchestrator/scripts/test-codex.sh
~/.claude/skills/codex-orchestrator/scripts/test-codex.sh --quick
Reference Documentation
For detailed information:
references/codex-cli.md - Complete CLI command reference
references/agents-md-format.md - AGENTS.md syntax and best practices
references/subagent-patterns.md - Delegation patterns and examples
Troubleshooting
"Codex CLI not found"
npm install -g @openai/codex
"Authentication error"
export OPENAI_API_KEY=sk-...
codex login
"Model not supported with ChatGPT account"
Older model names (codex-mini, o3, o4-mini) have been deprecated. Current models: gpt-5.5, gpt-5.5-pro, gpt-5-mini, gpt-5-nano. Previous generation (gpt-5.4, gpt-5.4-pro, gpt-5.3-codex, gpt-5.2) still works but is superseded.
Set an API key instead of using codex login:
export OPENAI_API_KEY=sk-...
"Profile not found"
Available profiles: reviewer, debugger, architect, security, refactor, docs, planner, syseng, builder, researcher, chat
Check profile exists:
ls ~/.claude/skills/codex-orchestrator/agents/
"Codex produced no output"
The researcher/chat profiles capture output to a temp file. If Codex exits without writing to it, the script warns and exits 1. Common causes:
- Codex session too short to produce a response
- Model returned empty response (retry)
- AGENTS.md was missing (check for stale
.AGENTS.md.codex-backup.* files in working directory)
Poor Results
- Narrow the task scope
- Provide more context in the prompt
- Try a different profile
- Use
--model gpt-5.5-pro for complex tasks