Codex System — Planning, Design & Complex Implementation
Codex CLI handles planning, design, and complex code implementation.
Detailed rules: .claude/rules/codex-delegation.md
Two Roles of Codex
- Planning & Design
-
Architecture design, module composition
-
Implementation plan creation (step breakdown, dependency ordering)
-
Trade-off evaluation, technology selection
-
Code review (quality and correctness analysis)
- Complex Implementation
-
Complex algorithms, optimization
-
Debugging with unknown root causes
-
Advanced refactoring
-
Multi-step implementation tasks
When to Consult (MUST)
Situation Trigger Examples
Planning "Create a plan" "Architecture"
Design decisions "How to design?"
Complex implementation "How to implement?" "How to build?"
Debugging "Why doesn't this work?" "Error" "Debug"
Trade-off analysis "Which is better?" "Compare"
Refactoring "Refactor" "Simplify"
Code review "Review" "Check"
When NOT to Consult
-
Simple file edits, typo fixes
-
Tasks that simply follow explicit user instructions
-
git commit, test execution, lint
-
Codebase analysis → general-purpose subagent (Opus 1M context)
-
External information retrieval → general-purpose subagent (Opus, WebSearch/WebFetch)
-
Multimodal processing → Gemini CLI (PDF/video/audio/images)
How to Consult
Subagent Pattern (Recommended)
Task tool parameters:
-
subagent_type: "general-purpose"
-
run_in_background: true (optional)
-
prompt: | Consult Codex about: {topic}
codex exec --model gpt-5.4 --sandbox read-only --full-auto " {question for Codex} " 2>/dev/null
Return CONCISE summary (key recommendation + rationale).
Direct Call (responses up to ~50 lines)
codex exec --model gpt-5.4 --sandbox read-only --full-auto "Brief question" 2>/dev/null
Having Codex Implement Code
codex exec --model gpt-5.4 --sandbox workspace-write --full-auto " Implement: {task description} Requirements: {requirements} Files: {file paths} " 2>/dev/null
Sandbox Modes
Mode Use Case
read-only
Design, review, debug analysis
workspace-write
Implementation, fixes, refactoring
Task Templates
Implementation Planning
codex exec --model gpt-5.4 --sandbox read-only --full-auto " Create an implementation plan for: {feature}
Context: {relevant architecture/code}
Provide:
- Step-by-step plan with dependencies
- Files to create/modify
- Key design decisions
- Risks and mitigations " 2>/dev/null
Design Review
codex exec --model gpt-5.4 --sandbox read-only --full-auto " Review this design approach for: {feature}
Context: {relevant code or architecture}
Evaluate:
- Is this approach sound?
- Alternative approaches?
- Potential issues?
- Recommendations? " 2>/dev/null
Debug Analysis
codex exec --model gpt-5.4 --sandbox read-only --full-auto " Debug this issue:
Error: {error message} Code: {relevant code} Context: {what was happening}
Analyze root cause and suggest fixes. " 2>/dev/null
Language Protocol
-
Ask Codex in English
-
Receive response in English
-
Execute based on advice
-
Report to user in the user's language
Why Codex?
-
Deep reasoning: Complex analysis and problem-solving
-
Planning expertise: Architecture and implementation strategies
-
Code mastery: Complex algorithms, optimization, debugging
-
Consistency: Same project context via context-loader skill