codex-exec-subagent
Launch focused Codex subagents via `codex exec` (single, resumed, or batched), capture outputs to files, and aggregate results as if using The Agent subagents.
SKILL.mdskills/codex-exec-subagent/SKILL.md
GitHubCodex Exec Subagent
Overview
Use this skill when you want to delegate focused tasks to one or more separate Codex instances using codex exec, then merge their outputs in a parent run.
This is the Codex equivalent of spawning "The Agent" subagents:
- each subagent is an isolated
codex execprocess - each subagent has a strict prompt contract
- each subagent writes artifacts the parent can review
When to Use
- "Spawn a subagent for this repo task."
- "Run two parallel Codex workers and summarize."
- "Use Codex exec like The Agent subagents."
- "Delegate investigation/edit/review to separate Codex instances."
Verified Commands (Research)
Read references/codex-exec-reference.md for verified option details from:
codex exec --helpcodex exec resume --helpcodex exec review --help
Prerequisites
codexis installed and onPATH.- Run from the target repo root, or set
SUBAGENT_CWD. - Keep sandbox at
workspace-writeby default.
Workflow
- Define subagent scope:
- one clear task per subagent
- explicit file boundaries
- explicit output format
- Launch execution:
- single run:
bash scripts/run_subagent.sh <name> "<prompt>" - batch run:
bash scripts/run_subagent_batch.sh references/tasks.tsv - resume thread:
codex exec resume <session_id> "<prompt>" - review mode:
codex exec review --uncommitted "<prompt>"
- Capture and inspect artifacts:
.codex/subagents/<timestamp>_<name>.md- optional
.codex/subagents/<timestamp>_<name>.jsonlwhenSUBAGENT_JSON=1
- Parent synthesis:
- compare outputs across subagents
- resolve conflicts with repo evidence
- keep final decisions centralized in the parent run
Safety Defaults
- Use
-s workspace-writeunless a stricter mode is required. - Avoid
--dangerously-bypass-approvals-and-sandboxunless externally sandboxed. - Use
-C <DIR>to pin working root. - Use
--skip-git-repo-checkonly when intentionally running outside a repo.
Command Patterns
Single delegated run:
bash scripts/run_subagent.sh resolver_audit "Inspect resolver fallback behavior and return findings."
Single delegated run with JSON event capture:
SUBAGENT_JSON=1 bash scripts/run_subagent.sh resolver_audit "Inspect resolver fallback behavior and return findings."
Batch delegated runs (serial default):
bash scripts/run_subagent_batch.sh references/tasks.tsv
Batch delegated runs (parallel):
SUBAGENT_BATCH_MODE=parallel bash scripts/run_subagent_batch.sh references/tasks.tsv
Resume most recent subagent thread:
codex exec resume --last "Continue and finalize with tests."
Run review mode:
codex exec review --uncommitted "Focus on regressions and missing tests."
Batch File Format
references/tasks.tsv format:
# name<TAB>prompt<TAB>cwd(optional)
resolver_audit Inspect resolver fallback behavior and return findings. .
cli_contract Audit CLI compatibility wrappers and propose minimal fixes. .
Subagent Prompt Template
Use this to keep outputs consistent:
You are a focused subagent.
Task: <one clear task>
Constraints:
- Scope only: <files/modules>
- Follow AGENTS.md and local conventions.
- Do not refactor unrelated code.
- If blocked, state exactly what is missing.
Output format:
1) Findings
2) Proposed changes
3) Risks/tests
Script Inputs
SUBAGENT_CWD: working directory for child run (default current directory)SUBAGENT_ROOT: artifact directory (default.codex/subagents)SUBAGENT_SANDBOX:read-only|workspace-write|danger-full-access(defaultworkspace-write)SUBAGENT_MODEL: optional model overrideSUBAGENT_PROFILE: optional profile overrideSUBAGENT_JSON=1: emit--jsonand store JSONL eventsSUBAGENT_BATCH_MODE=parallel: run TSV entries concurrentlySUBAGENT_UNSAFE=1: add dangerous bypass flag (avoid unless externally sandboxed)