| description |
|---|
Delegate a coding task to OpenAI Codex agent for autonomous execution |
You are delegating a coding task to a headless Codex agent. Codex will do the actual implementation work.
- Identify the task from conversation context
- Read CLAUDE.md and inject context directly into the prompt
- Execute Codex and report results
Review the conversation history and identify:
- What coding task does the user want accomplished?
- What files/areas of the codebase are involved?
- What does "done" look like?
Restate the task clearly. If unclear, ask the user to clarify.
- Read CLAUDE.md if it exists - extract relevant project context
- Use Read/Grep/Glob to find relevant code patterns
- Note any conventions or styles to follow
Write a detailed task specification that INCLUDES the CLAUDE.md context directly:
# Project Context
[Paste relevant sections from CLAUDE.md here]
# Task
[Clear description based on conversation context]
# Relevant Files
[List key files Codex should know about]
# Requirements
- [specific requirement 1]
- [specific requirement 2]
# Success Criteria
- [how to know it's done correctly]
Do NOT:
- Tell Codex how to implement (let it decide)
- Over-constrain the solution
DO:
- Include CLAUDE.md context directly in the prompt
- Be specific about requirements
- State clear success criteria
Run Codex with your formulated task:
codex exec --full-auto "YOUR_TASK_WITH_CONTEXT_HERE" 2>&1The --full-auto flag enables:
--sandbox workspace-write- Can modify files in the workspace-a on-request- Model decides when to ask for approval
[The task you identified from context]
[Summary of CLAUDE.md context you included]
- Files created/modified
- Summary of changes
- Did it meet the success criteria?
- Any issues encountered?
[List with brief descriptions]
- Any remaining tasks
- Things to review
- YOU identify the task from conversation context
- Inject CLAUDE.md content DIRECTLY into the prompt (don't create AGENTS.md)
- If Codex fails, report what happened and suggest fixes
- You can run Codex multiple times with refined prompts