Field guide / 19 min
Scale from subagents to safe automation
Parallelize independent evidence, then move stable workflows into codex exec and CI.
Subagents protect the main thread from noisy exploration and can run independent read-heavy work in parallel. For non-interactive workflows, codex exec defaults to a read-only sandbox, streams progress to stderr, and prints the final message to stdout; JSONL and output schemas support machine consumers. GitHub Actions should use the official action and narrow privileges.
Verified terminal sequence
- ›
/agent - $
codex exec "summarize the repository structure" - $
codex exec --ephemeral "triage this repository" - $
codex exec --json "summarize the repo structure" | jq - $
codex exec resume --last "continue the task"
Working principles
Parallelize independence
Start with exploration, tests, triage, and review; simultaneous writes need explicit file ownership and coordination.
Children inherit boundaries
Subagents inherit the parent sandbox and live runtime overrides, so permission design happens before spawning.
Automate stable contracts
Move a workflow into codex exec only after prompts, inputs, permissions, output shape, and failure handling are repeatable.
Field procedure
- 01
Delegate bounded reads
Ask for one agent per independent concern, wait for them, and require concise evidence summaries.
- 02
Inspect agent threads
Use /agent to review status and results rather than flooding the main context with raw logs.
- 03
Prototype with codex exec
Begin read-only and ephemeral; pipe bounded context and keep instructions in the prompt argument.
- 04
Add machine output
Use --json for event streams or --output-schema for a stable final object. Resume only when repository state remains compatible.
- 05
Harden CI
Use openai/codex-action@v1, trusted triggers, minimal permissions, isolated secrets, and a separate job for repository writes.
PASS / FAIL
Acceptance checklist
- Subtasks are independent and bounded.
- Parent permissions are least privilege.
- Automation handles non-zero exit and malformed output.
- Repository write credentials are isolated from the Codex job.
WATCH / REJECT
Failure patterns
- Spawning agents for tightly coupled writes.
- Using deprecated --full-auto in new scripts.
- Exposing API keys job-wide to repository-controlled code.