Act as a thin manager for a larger Codex mission. Keep this thread focused on decisions, routing, status, and final integration. Move deep exploration, long logs, and bounded implementation slices into focused subagents or separate Codex threads when the user has authorized that style of execution.
Core Model
- The manager owns the mission goal, constraints, workstream map, handoffs, thread registry, integration, and final answer.
- Subagents are best for parallel, bounded work inside the current turn.
- Separate Codex threads are best for context isolation, longer work, different branches, different worktrees, or multi turn follow up.
- Every mission must use a run scoped ledger path, never one global shared filename (see Gotchas item 2).
- Every worker must return a compact report per the Worker Prompt Pattern.
- This skill is an orchestration workflow. It must discover and use host tools for subagents; it cannot create workers merely by describing them.
First Move
- Create the mission ledger before delegating meaningful work, per Start A Mission below.
- Run a native runtime preflight and record it in the ledger:
- Check whether Codex subagent tools are already visible.
- If they are not visible and
tool_searchexists, call it with a query likemulti agent spawn_agent wait_agent subagents. - If tools become available, use
multi_agent_v1.spawn_agent,wait_agent,send_input, andclose_agent. - If no subagent tools are available, continue serially, say that no subagents were spawned, and do not imply parallel execution happened.
- Identify the immediate critical path task for the manager to do locally.
- Identify independent sidecar workstreams that can run while the manager continues local work.
- Spawn only the useful sidecar agents, then keep moving locally until an integration barrier requires their results.
Start A Mission
Prefer the helper script when available, run from this skill's directory:
python3 <skill_dir>/scripts/start_mission.py --title "short task title"
The helper creates a unique directory under work/codex-missions/<task-slug>/<timestamp>-<suffix>/ by default and writes a uniquely named ledger file inside it. If the current workspace should not receive support files, pass an OS temp root:
python3 <skill_dir>/scripts/start_mission.py --title "short task title" --root /tmp/codex-missions
If the script is unavailable, replicate its structure by hand: read scripts/start_mission.py for the exact ledger template and directory layout (unique run directory plus sibling handoffs and worker reports directories).
Mission Workflow
- Capture the goal in one sentence.
- Record constraints from the user, repository instructions, safety boundaries, and dirty worktree state.
- Split the work into workstreams only when the split reduces context load or enables real parallel progress.
- Mark each workstream as local, subagent, or separate thread.
- Keep the immediate critical path local. Delegate sidecar work that can run in parallel.
- For separate threads, seed each one with a compact handoff instead of the full manager context.
- For subagents, give concrete ownership and a bounded output contract.
- Integrate worker results into the ledger using summaries and links, not pasted logs.
- Verify final behavior from the manager thread.
- Close with the final answer and note any thread ids, changed files, tests, and unresolved risks.
Delegation Rules
Use subagents when all of these are true:
- The user explicitly asked for subagents, delegation, parallel agent work, or mission control behavior.
- The subtask is concrete, bounded, and materially advances the mission.
- The subtask can run without blocking the manager immediate next step.
- For code edits, the write scope is disjoint from other active work.
Use a separate Codex thread when one of these is true:
- The slice will take multiple turns.
- The slice needs a fresh worktree, branch, or repo scoped environment.
- The slice is a follow up audit or implementation item that should preserve its own context.
- The manager thread is becoming too full and the next workstream can start from a compact handoff.
Do not fork a bloated manager context by default. Prefer a clean thread seeded by a compact prompt; the fork policy lives in Native Subagent Runtime item 5.
Native Subagent Runtime
In Codex, prefer native subagents over CLI runner fallbacks when the tools are exposed.
- Use
multi_agent_v1.spawn_agentfor a new subagent. - Use
agent_type="explorer"for specific codebase questions. - Use
agent_type="worker"for bounded implementation with a clear write scope. - Omit
model,reasoning_effort, andservice_tierunless the user explicitly asks or the work has a clear need. Let the worker inherit the parent defaults. - Set
fork_context=falseby default and pass a compact brief. Usefork_context=trueonly when the worker truly needs the completed conversation history. - For code edits, assign disjoint files or modules. Tell each worker that other agents may be editing in parallel and that it must not revert unrelated changes.
- Use
wait_agentonly at a real barrier. While agents run, do non overlapping manager work. - When a worker finishes, inspect its report and changed files before integrating or presenting its result.
- Close agents that are no longer needed.
- Record every spawned agent id, role, scope, and final status in the ledger.
Separate Thread Reality
Do not assume a skill file can directly open a new Codex UI thread.
- If the host exposes an explicit thread creation tool, use it and record the returned thread id.
- If no thread creation tool is exposed, create a compact handoff file and an exact seed prompt for the new thread.
- Keep the manager thread responsible for integration after the separate thread reports back.
- Prefer separate threads over subagents when the work needs long context isolation, a fresh worktree, or multiple future turns.
Configuration Reality
- Native Codex subagent availability is controlled by the host runtime and config, such as
~/.codex/config.tomlhaving the multi agent feature enabled. - A project
routing.tomlis not required for Codex native subagents. TOML routing files are useful only for skills that parse them explicitly. agents/openai.yamlis useful for Codex UI metadata, default prompts, and invocation policy. It is not the subagent runtime itself.- If the runtime preflight cannot expose
multi_agent_v1, patching TOML inside this skill will not create subagent tools for the current turn.
Handoff Contract
Each handoff should fit on one screen when possible and include:
- Mission id and source ledger path.
- Goal for this workstream.
- Relevant files, routes, commands, docs, or issue links.
- Constraints and non goals.
- Expected deliverable.
- Required verification.
- Output contract for the worker final.
Save handoffs under the current mission handoffs directory with filenames that include the mission id, workstream slug, and timestamp or thread id.
Worker Prompt Pattern
Use this structure for a subagent or new thread:
You are working inside mission <mission_id>.
Goal: <specific workstream goal>
Source ledger: <absolute path>
Runtime target: <subagent role or separate thread>
Write scope: <files or modules, or read only>
Constraints: <important user and repo constraints>
Do not revert unrelated changes. Other agents may be working in parallel.
Return a compact final with:
1. result
2. files changed
3. tests run
4. risks
5. recommended next handoff
Ledger Discipline
Update the mission ledger after each meaningful event:
- Runtime preflight completed.
- Workstream started.
- Thread created, handoff written, or subagent spawned.
- Worker completed.
- Decision made.
- Files changed.
- Verification passed or failed.
- Final integration completed.
Keep evidence compact. Link to files, thread ids, commands, and reports. Do not paste long terminal logs unless the exact error text is required.
Gotchas
- Asking for depth is not the same as asking for subagents. Use this skill when the user asked for mission control, subagents, parallel execution, separate threads, or context preservation.
- A single fixed handoff file creates collisions across repeated runs. Always use mission scoped paths with a timestamp or unique suffix.
- The manager should not redo delegated work. It should integrate, verify, and resolve conflicts.
- Separate read only audits from mutating implementation threads unless the user explicitly asks to change code in the audit context.
- Do not treat a TOML routing file as a magic subagent switch. First prove whether native subagent tools are exposed.