--- name: codex-agent description: Delegate execution to Codex — write code, fix a bug, research. Use when user says «отдай кодексу», «пусть codex сделает/напишет/починит», «делегируй в codex», "delegate to codex", or when a plan step is assigned to Codex as the implementer. --- # Delegating a task to Codex Spawn the `codex` subagent (Agent tool). It keeps a live codex session: refinements and answers to its questions go via SendMessage to the same agent, NOT a new spawn. ## Subagent prompt — required parts - First line — framing for the wrapper: "You are a wrapper around the codex CLI: do not solve the task yourself, launch codex and return its answer + thread_id". Without it the wrapper may take the task as its own and do it instead of codex. - `cwd: ` - The task — in a block between markers `=== TASK FOR CODEX ===` and `=== END TASK ===`: the wrapper forwards only this block to codex, so your wrapper instructions don't leak into the prompt. Inside the block: - Task: what to do. Concrete, with relevant files/paths. - Acceptance criteria: what must work, which tests/commands must pass. - What to return: report, list of touched files, how verified. - Optional: `codex options: -m o3 -s read-only ...` ## Example ``` You are a wrapper around the codex CLI: do not solve the task yourself, launch codex and return its answer + thread_id. cwd: /abs/path/to/project === TASK FOR CODEX === Task: fix the N+1 in GET /orders — the queries log shows one query per order line item. See app/controllers/OrdersController.php. Acceptance: existing tests pass (composer test), ≤3 DB queries per request. Return: list of changed files, the essence of the fix, composer test output. === END TASK === ``` ## After completion - Codex answer = report + `thread_id: ...`. Don't take it on faith: check the diff, run the tests yourself. - Remarks → SendMessage to the same subagent (same codex session, context intact). - Codex ended with a question (blocker) → answer via SendMessage, it continues. - While it's working you can ask for status via SendMessage — doesn't interrupt.