codex-cli-subagent
SKILL.md
This skill lets you spawn a nested Codex process (a “subagent”) using codex exec so it can work with the same project and AGENTS.md instructions.
filename="$(openssl rand -hex 4)"
codex exec "count the total number of lines of code in this project" 2>>/tmp/${filename}.log
In non-interactive mode, codex exec runs without a TUI and follows the configured approval/sandbox policy (flags and/or ~/.codex/config.toml). By default it runs in read-only mode, so it cannot edit files or run commands that require network access.
When you use this skill, follow these logging rules:
- Before running
codex exec, generate a unique log file name withopenssl rand -hex 4. - By default, append
2>>/tmp/${filename}.logto yourcodex execcommand so only the subagent’s final message is visible to the caller, while stderr is captured for debugging. - If a run fails, behaves unexpectedly, or the user explicitly asks to see what the inner agent is doing, read the log file (for example:
cat /tmp/${filename}.log).
Since the codex exec may run couple hours, set a generous timeout so long-running subagent work can complete:
- Use a timeout of at least 60 minutes for the
Run(orBash) tool unless the user explicitly requests other limit.