Dispatch stateless coding agents (Claude Code or Codex) via Bash. Use when you're stuck, need a second opinion, or need parallel research on a hard problem. They have no memory — you must provide all context.
You can shell out to Claude Code (claude) and Codex (codex) as stateless sub-agents via Bash. They have filesystem and tool access (scope depends on sandbox/approval settings) but zero memory — every session starts from scratch.
Default to run_in_background: true on the Bash call so you can keep working while they run. Check results later with TaskOutput. Don't sit idle waiting for a subagent.
Claude Code and Codex are highly optimized coding agents, but are re-born with each new session. Think of them like a brilliant intern that showed up today. Provide them with the right instructions and context to help them succeed and avoid having to re-learn things that you've learned.
You are the experienced manager with persistent memory of the user's preferences, the codebase, past decisions, and hard-won lessons. Give them context, not a plan. They won't know anything you don't tell them:
If a subagent needs clarification or asks a question, respond in the same session (see Session Resumption below) — don't start a new session or you'll lose the conversation context.
Different agents have different strengths. Track what works in your memory over time — your own observations are more valuable than these defaults.
Codex:
gpt-5.3-codex — Frontier reasoning. Best for the hardest debugging and complex tasks.
gpt-5.4 — Latest frontier model. Fast and general-purpose.
Claude Code:
opus — Excellent writer. Best for docs, refactors, open-ended tasks, and vague instructions.
gpt-5.3-codex, Opus) are slower and more expensive — use for tasks that justify itgpt-5.4) are good for quick checks and simple tasks--max-budget-usd N (Claude Code) to cap spend on exploratory tasks--allowedTools "Read Grep Glob" (no Bash) and shorter timeouts for research tasksTASK: [one-sentence summary]
CONTEXT:
- Repo: [path]
- Key files: [list specific files and what they contain]
- Architecture: [brief relevant context]
WHAT TO DO:
[what you need done — be precise, but let them figure out the approach]
CONSTRAINTS:
- [any preferences, patterns to follow, things to avoid]
- [what you've already tried, if dispatching because stuck]
OUTPUT:
[what you want back — a diff, a list of files, a root cause analysis, etc.]
src/agent/message.ts lines 40-80" not "look at the message handling code"Run Claude Code and Codex simultaneously on the same question via separate Bash calls in a single message (use run_in_background: true). Compare results for higher confidence.
Use run_in_background: true on the Bash call to dispatch async. Continue your own work, then check results with TaskOutput when ready.
For hard problems, use the strongest available models:
codex exec "YOUR PROMPT" -m gpt-5.3-codex --full-auto -C /path/to/repo
Have one agent write code or create a plan, then dispatch another to review:
# Codex has a native review command:
codex review --uncommitted # Review all local changes
codex exec review "Focus on error handling and edge cases" -m gpt-5.4 --full-auto
# Claude Code — pass the diff inline:
claude -p "Review the following diff for correctness, edge cases, and missed error handling:\n\n$(git diff)" \
--model opus --dangerously-skip-permissions
Write your plan or analysis to a file, then ask a subagent to critique it:
claude -p "Read /tmp/my-plan.md and critique it. What am I missing? What could go wrong?" \
--model opus --dangerously-skip-permissions -C /path/to/repo
--allowedTools, (3) switching to Codex which handles large repos better--dangerously-skip-permissions prevents this. If Codex errors, start a fresh exec session.claude -p "YOUR PROMPT" --model MODEL --dangerously-skip-permissions
| Flag | Purpose |
|---|---|
-p / --print | Non-interactive mode, prints response and exits |
--dangerously-skip-permissions | Skip approval prompts (prevents stale approval errors on timeout) |
--model MODEL | Alias (sonnet, opus) or full name (claude-sonnet-4-6) |
--effort LEVEL | low, medium, high — controls reasoning depth |
--append-system-prompt "..." | Inject additional system instructions |
--allowedTools "Bash Edit Read" | Restrict available tools |
--max-budget-usd N | Cap spend for the invocation |
-C DIR | Set working directory |
--output-format json | Structured output with session_id, cost_usd, duration_ms |
codex exec "YOUR PROMPT" -m gpt-5.3-codex --full-auto
| Flag | Purpose |
|---|---|
exec | Non-interactive mode |
-m MODEL | gpt-5.3-codex (frontier), gpt-5.4 (fast), gpt-5.3-codex-spark (ultra-fast), gpt-5.2-codex, gpt-5.2 |
--full-auto | Auto-approve all commands in sandbox |
-C DIR | Set working directory |
--search | Enable web search tool |
review | Native code review — codex review --uncommitted or codex exec review "prompt" |
Both CLIs persist full session data (tool calls, reasoning, files read) to disk. The Bash output you see is just the final summary — the local session file is much richer.
Claude Code: ~/.claude/projects/<encoded-path>/<session-id>.jsonl
<encoded-path> = working directory with / replaced by - (e.g. /Users/foo/repos/bar becomes -Users-foo-repos-bar)--output-format json to get the session_id in the responseCodex: ~/.codex/sessions/<year>/<month>/<day>/rollout-*-<session-id>.jsonl
session id: <uuid>grep "^session id:" output | awk '{print $3}'Use session resumption to continue a line of investigation without re-providing all context:
Claude Code:
claude -r SESSION_ID -p "Follow up: now check if..." # Resume by ID
claude -c -p "Also check..." # Continue most recent
claude -r SESSION_ID --fork-session -p "Try differently" # Fork (new ID, keeps history)
Codex:
codex exec resume SESSION_ID "Follow up prompt" # Resume by ID (non-interactive)
codex exec resume --last "Follow up prompt" # Resume most recent (non-interactive)
codex resume SESSION_ID "Follow up prompt" # Resume by ID (interactive)
codex resume --last "Follow up prompt" # Resume most recent (interactive)
codex fork SESSION_ID "Try a different approach" # Fork session (interactive)
Note: codex exec resume works non-interactively. codex resume and codex fork are interactive only.
Don't run history-analyzer after every dispatch — your reflection agent already captures insights naturally, and single-session analysis produces overly detailed notes.
Do use history-analyzer for bulk migration when bootstrapping memory from months of accumulated history (e.g. during /init). See the initializing-memory skill's historical session analysis reference.
Direct uses for session files:
Set Bash timeouts appropriate to the task:
timeout: 120000 (2 min)timeout: 300000 (5 min)timeout: 600000 (10 min)