Sub
Overview
Run a subtask through codex exec and fold its output back into the primary task without losing context.
Workflow
1) Parse the /sub command
- •Treat
/sub <prompt>as a command. - •If the prompt is missing, ask the user for the prompt text.
- •Preserve the prompt as provided unless the user requests edits.
2) Execute the subtask
- •Prefer the bundled script to run and stream output:
- •Locate this skill directory by the path of
SKILL.md. - •Run:
python3 <skill_dir>/scripts/codex_exec.py --prompt "<prompt>". - •If the prompt contains
$or other shell-sensitive text, write it to a temp file and pass--prompt-file <path>to avoid shell expansion.
- •Locate this skill directory by the path of
- •The wrapper has no overall timeout, but it will terminate if there is no stdout
for 120s. Override with
--idle-timeout <seconds>or set--idle-timeout 0to disable. - •If the script is unavailable, run
codex exec "<prompt>"directly.
3) Monitor and capture output
- •Let the command run to completion.
- •Capture the full output (stdout + stderr) and note the exit code.
- •If the command fails, surface the error output and decide whether to retry, adjust the prompt, or proceed without the subtask.
4) Continue the main task
- •Summarize the subtask result in 1-3 sentences.
- •Continue the higher-level task using the subtask output as inputs.
- •If the subtask returned actionable artifacts (files, commands, or decisions), apply them directly or ask for confirmation when needed.
Resources
scripts/
- •
scripts/codex_exec.py: Runcodex execwith a prompt and stream output for monitoring and reuse. - •
scripts/test_codex_exec.py: Unit tests for the wrapper script.