Codex CLI Orchestrator - Cross-AI Task Delegation
CRITICAL — SELF-INVOCATION PROHIBITED
This skill dispatches to the OpenAI CLI binary (codex). If the agent currently reading this skill is itself running inside Codex (detection signals listed in the self-invocation guard in ROUTER.md), the skill MUST refuse to load and return the documented error message instead of generating any codex invocation.
A running CLI skill never dispatches itself. The cli-X skills are for cross-AI delegation only — never self-invocation.
Orchestrate OpenAI's Codex CLI for tasks that benefit from a second AI perspective, real-time web search, deep codebase analysis, built-in code review workflows, or parallel code generation.
Core Principle: Use Codex for what it does best. Delegate, validate, integrate. The calling AI stays the conductor.
1. WHEN TO USE
Activation Triggers
- Cross-AI Validation — code review second perspective, security audit alternative analysis, bug detection,
/review diff-aware workflow.
- Web Research — current internet info via the top-level
--search flag (codex --search exec …), latest library versions, API changes, community solutions.
- Codebase Architecture Analysis — onboarding to unfamiliar codebases, cross-file dependency mapping, architecture docs from code.
- Parallel Task Processing — offloading generation, simultaneous code generations, background docs/test generation.
- Agent-Delegated Tasks — specialized profile matches (
.codex/agents/*.toml), session management (resume, fork), multi-strategy planning.
- Specialized Generation — explicit Codex requests, test suite generation, code translation, batch docs (JSDoc, README, API), visual input via
--image/-i.
When NOT to Use
- You ARE Codex already. If your runtime is Codex (detection signal:
$CODEX_SESSION_ID or any CODEX_* env var set, codex in process ancestry, or ~/.codex/state/<id>/lock present), this skill refuses to load. Self-invocation creates a circular dispatch loop and burns tokens for no value.
- Simple, quick tasks where CLI overhead is not worth it, or tasks needing an immediate response (rate limits may delay).
- Context already loaded and understood by the current agent.
- Interactive refinement requiring the full-screen TUI (use
codex directly instead).
- Tasks where Codex CLI is not installed.
2. SMART ROUTING
The cli-external-orchestration hub routes an OpenAI dispatch here: the prompt names Codex, the Codex CLI, codex exec or a web-research or second-opinion handoff, and the hub's cli-codex mode signal selects this packet.
A session already running inside Codex never routes here; the self-invocation guard refuses it.
The hub ROUTER.md names the two leaves a dispatch starts from.
Inside this packet the ALWAYS tier loads first: references/cli-reference.md for the subcommands, flags and sandbox modes, and assets/prompt-quality-card.md for the fast-path prompt framework.
Intent-mapped references load after those, one set per intent.
Read ROUTER.md before selecting skill-local resources; open only the matched files.
Keep every path inside this skill folder, and load a file only when it exists.
When nothing matches, report UNKNOWN_FALLBACK with the checklist from the machine router instead of guessing.
3. HOW IT WORKS
Prerequisites
Install with npm i -g @openai/codex, or with brew install --cask codex.
cli-codex authenticates through ChatGPT OAuth only. Run codex login and complete the browser flow, which requires a ChatGPT Plus/Pro/Business/Edu/Enterprise account. The skill does not use an OpenAI API key.
The ALWAYS-loaded cli-reference.md holds the full install, auth, flag, sandbox, session and troubleshooting tables. This section keeps only the routing decisions and dispatch-critical gotchas.
Execution Ownership
This packet owns user-facing routing, the command -v codex availability probe, prompt construction, and the self-invocation guard.
Research and review lineages delegate process construction and execution to the already-shipped deep-loop runtime at ../../system-deep-loop/runtime/scripts/fanout-run.cjs, using executor kind cli-codex.
That runner accepts only the research and review loop types, so a single build or doc dispatch uses the child dispatch envelope in providers-and-models.md §5.
The runtime is the single Codex execution adapter. Do not add a packet-local wrapper, command builder, or spawn path. Direct codex exec snippets below are operator reference and manual-testing examples; research and review lineages use the shared runtime, and a one-shot dispatch uses the child envelope.
Provider Auth Pre-Flight (ChatGPT OAuth)
MANDATORY before any first dispatch in a session. cli-codex authenticates through ChatGPT OAuth only. If codex login has not been completed on this machine, a dispatch fails with 401 Unauthorized or not authenticated mid-round-trip. Run this check once per session, cache the result, and re-run it only if a dispatch fails with an auth error.
# One-shot pre-flight: capture ChatGPT OAuth status for routing
CODEX_AUTH=$(codex login status 2>&1)
echo "$CODEX_AUTH" | grep -qi "logged in\|chatgpt-oauth" && CODEX_OAUTH_OK=1 || CODEX_OAUTH_OK=0
Decision tree (apply in order — first match wins):
| State |
CODEX_OAUTH_OK |
Action |
| OAuth ready |
1 |
Proceed with codex exec --model gpt-6-luna -c model_reasoning_effort="medium" -c service_tier="fast" |
| Not logged in |
0 |
ASK user to run codex login — surface the command, do NOT dispatch. Never substitute an API key or a different model. |
User prompt template — not logged in:
Codex is not authenticated on this machine. cli-codex uses ChatGPT OAuth only.
Run `codex login` (browser flow; requires a ChatGPT Plus/Pro/Business/Edu/Enterprise account),
then confirm when login finishes — the skill will retry the original dispatch.
Error-recovery contract. If a dispatch returns an auth error after pre-flight passed (OAuth expired or revoked), invalidate the cache, rerun codex login, and re-check before retrying. Never substitute a model the user didn't approve.
Default Invocation (Skill Default)
Default model + effort + tier: gpt-6-luna · medium reasoning · fast service tier. Balances speed, cost, and quality for the typical delegation.
A ChatGPT-account login accepts only the models its plan lists, so pass -m <model> explicitly when in doubt.
Fan-out fallback: a deep-loop lineage that pins no model runs GPT Luna. The family is named here on purpose, without a version or an effort tier, so this line does not go stale when the family ships a point release; the runner resolves the current id. A drift test keeps the two in the same family.
codex exec \
--model gpt-6-luna \
-c model_reasoning_effort="medium" \
-c service_tier="fast" \
-c approval_policy=never \
--sandbox workspace-write \
"<prompt>" </dev/null
The trailing </dev/null is not optional in a non-interactive dispatch; Rule 6 below explains what a backgrounded codex does to an inherited stdin.
User override (honor explicit user phrasing verbatim):
| User says |
Resolve to |
| (nothing specified) |
--model gpt-6-luna -c model_reasoning_effort="medium" -c service_tier="fast" |
| "Use gpt 6 luna high fast" |
--model gpt-6-luna -c model_reasoning_effort="high" -c service_tier="fast" |
| "Use gpt 6 luna low" |
--model gpt-6-luna -c model_reasoning_effort="low" -c service_tier="fast" (fast stays unless user drops it) |
| "Use gpt 6 luna xhigh" |
--model gpt-6-luna -c model_reasoning_effort="xhigh" -c service_tier="fast" |
| "Use gpt 6 luna max" |
--model gpt-6-luna -c model_reasoning_effort="max" -c service_tier="fast" |
| "Use gpt 5.6 terra high" |
--model gpt-5.6-terra -c model_reasoning_effort="high" -c service_tier="fast" |
| "Use gpt 6.1 terra high" |
--model gpt-6.1-terra -c model_reasoning_effort="high" -c service_tier="fast" |
| "Use gpt 6 sol ultra" |
--model gpt-6-sol -c model_reasoning_effort="ultra" -c service_tier="fast" |
Honor whichever dimensions the user names. Model stays on gpt-6-luna and service tier stays on fast unless the user explicitly names a different model or tier; keep the reasoning effort within the chosen model's ceiling (see Model Selection below and the roster in references/providers-and-models.md).
Model Selection
gpt-6-luna at medium on the fast service tier (-c service_tier="fast") is the skill default for cross-AI delegation.
Alternates are gpt-5.5 (≤ xhigh), and gpt-5.6-terra, gpt-6.1-terra and gpt-6-sol (≤ ultra).
references/providers-and-models.md holds the full roster, the per-model effort ceilings and the 8-level effort ladder.
Set effort with -c model_reasoning_effort="<level>". There is no --reasoning-effort flag.
Selection Strategy: default gpt-6-luna medium; raise to high / xhigh for architecture, security, and complex planning; take the default model to max, or switch to gpt-6-sol, when the task wants reasoning past xhigh; drop to low / minimal for trivial lookups. Per-task rationale table: cli-reference.md §5.
Codex Agent Delegation
The calling AI is the conductor; Codex profiles in $CODEX_HOME/<name>.config.toml shape HOW Codex processes the task (sandbox, reasoning). Route with -p <name> when the task matches a specialization. Full roster and invocation patterns: agent-delegation.md.
| Task Type |
Profile |
| Code review / security audit |
review |
| Architecture exploration |
context |
| Technical research |
research (+ top-level --search) |
| Documentation generation |
write |
| Fresh-perspective debugging |
debug |
| Multi-strategy planning |
ai-council |
Git diff review uses the built-in subcommand (no -p): codex exec review "..." --commit HEAD. Profiles may override model, model_reasoning_effort, sandbox_mode, approval_policy. The .codex/agents/*.toml files define personas for the interactive multi-agent TUI, NOT the -p flag.
Dispatch-Critical Gotchas
The full flag glossary, sandbox modes, unique capabilities (/review, --search, codex mcp, session resume/fork, --image, codex cloud), essential command examples, and troubleshooting table are in the ALWAYS-loaded cli-reference.md. Six gotchas break a dispatch or make a child misreport its result. Honor them at routing time:
codex exec defaults to --sandbox read-only — file-modification tasks silently no-op (the agent plans changes but cannot write them). Pass --sandbox workspace-write; for headless no-prompt execution use top-level -a never before exec or -c approval_policy=never.
--search is a top-level flag, not an exec flag. Enable live web search as codex --search exec …, because it precedes the subcommand.
On codex ≥ 0.144 codex exec --search hard-fails with unexpected argument '--search', and older 0.125 builds accepted it, so treat any exec … --search example as stale.
Without it, codex exec has no web access and answers from training data only. Every dispatch needing live data (latest versions, repo facts, advisories) MUST use codex --search exec ….
- Always pass
-c service_tier="fast" explicitly — this routes through the fast tier instead of whatever the caller's ~/.codex/config.toml defaults to. Explicit means reproducible regardless of who runs it.
- No
--reasoning-effort, --reasoning, or --quiet flag exists — set effort with -c model_reasoning_effort="<level>"; capture the last message with -o file.txt; capture stderr with 2>&1.
--sandbox workspace-write blocks local IPC sockets, so a child cannot run checks that start tsx. spec-kit's npm --prefix runtime/cli run check fails there with listen EPERM, and it also fails with TMPDIR pointed elsewhere. It passes outside the sandbox. That was observed 2026-09-24 on codex-cli 0.156.1.
Tell the child which checks to leave to you, run them in the orchestrating session after it returns, and read that EPERM as a sandbox limit, not a code failure.
- A read-only dispatch can exit 0 having read nothing. The agent personas name Claude Code tools, and
codex exec has only its shell. A child given an inlined persona that denies Bash, with no tool-mapping line above it (Rule 17), can conclude it has no tool it may use.
That was observed 2026-11-14 on codex-cli 0.167.2 with the context persona: the run exited 0 and its report ended FILES READ: none. The same prompt read its file on codex-cli 0.169.0, so the failure is intermittent.
Ask every read-only child to end its report with a FILES READ: line, and treat FILES READ: none, or a report that names no file, as a failed dispatch whatever the exit status.
4. RULES
✅ ALWAYS
- Verify Codex CLI is installed before first invocation (
command -v codex).
- Delegate research and review lineages to
../../system-deep-loop/runtime/scripts/fanout-run.cjs with executor kind cli-codex. It rejects every other loop type, so a single build or doc dispatch uses the child dispatch envelope in providers-and-models.md §5. Never build a second adapter in this packet.
- Use
--sandbox read-only for review/analysis/research; --sandbox workspace-write for code generation/file modification — codex exec defaults to read-only, so omitting it causes silent no-op on edit tasks. For unattended approval, put top-level -a never before exec or set -c approval_policy=never.
- Validate Codex-generated code (XSS, injection, eval, syntax checks via
node --check, tsc --noEmit, etc.) before applying.
- Capture stderr (
2>&1) so rate-limit messages and errors surface.
- Redirect codex stdin from
/dev/null on EVERY non-interactive dispatch, not only inside a while read loop. Pattern: codex exec "$PROMPT" > "$LOG" 2>&1 </dev/null &.
Without </dev/null, the backgrounded codex process inherits the loop's stdin, the file after done < input.jsonl, and silently consumes the remaining lines. The loop then exits after 3-6 iterations with no error.
See references/integration-patterns.md#background-execution → "Silent Stdin Consumption".
- Specify model + effort + service tier explicitly — never rely on caller environment. Default:
--model gpt-6-luna -c model_reasoning_effort="medium" -c service_tier="fast". Honor user overrides verbatim. Use high/xhigh for reasoning-heavy tasks (architecture, security, deep planning).
- Route to the appropriate
-p <profile> when the task matches a specialization (see Section 3 routing table); use codex exec review (built-in subcommand) for git diff reviews.
- Pass the spec folder to the delegated agent in the prompt: if the calling AI has an active Gate-3 spec folder, include
Spec folder: <path> (pre-approved, skip Gate 3). If none, ASK the user before delegating — the delegated agent cannot answer Gate 3 in non-interactive mode.
- Prompt construction & model-craft (cli- family precedence).* Compose every dispatch prompt via the 2-tier rule canonical in
../../sk-prompt/assets/cli-prompt-quality-card.md:
- Fast path (default). Build from the local
assets/prompt-quality-card.md, which delegates the framework table + CLEAR check to the canonical card.
- Deep path (escalation). Dispatch
@prompt-improver via the Task tool (never load full sk-prompt inline) when any canonical Tier 2 trigger applies — the trigger list lives in ../../sk-prompt/assets/cli-prompt-quality-card.md under "Tier 2 — Deep path"; do not re-enumerate it here.
- Never inject user-level voice/personalization content into AI-orchestrated Codex delegations. Codex CLI reads user-level voice from
~/.codex/AGENTS.md, the human's global settings, loaded automatically.
When an AI delegates via codex exec, the calling AI's own voice rules govern the response. Do NOT read ~/.codex/AGENTS.md and paste it into delegation prompts.
Keep delegations focused on task/model/sandbox/effort/(spec-folder pre-approval).
If the user asks how to make Codex sound more like Claude in their own sessions, point to ~/.codex/AGENTS.md, not any repo asset.
- Code Standards Loading (surface-aware contract). When you dispatch for code review or code generation, instruct the dispatched session to work these four steps in order.
- Load
sk-code.
- Let
sk-code emit a surface tag matching the detected stack from markers and target files.
- Load the selected surface resources and run its verification commands.
- Add
code-review only for formal findings-first review output.
Fallback: if the surface cannot be determined confidently, ask for the runtime surface and verification command set. NEVER hardcode obsolete sibling code skills in dispatch prompts.
- Design Standards Loading (measured-reference contract). When you dispatch for design or UI work, instruct the dispatched session to work these three steps in order.
- Load
sk-design-md-generator.
- Extract a measured Style Reference DESIGN.md from the live source before building UI. It carries named color tokens, a type scale, components and Quick-Start CSS/Tailwind.
- Build against those measured tokens and run the extraction's validate step to confirm hex/section fidelity.
Fallback: if there is no live source to measure, ask for the reference URL or the exact tokens to build against. NEVER treat
mcp-figma or sk-design-md-generator as a taste, visual-direction, or critique authority. The extraction measures real CSS. It does not judge design.
- Pass the design reference manifest to the dispatched session. When you dispatch design or UI work, inline a
DESIGN_DISPATCH_MANIFEST v1 block in the prompt, because the child cannot resolve skill paths and the manifest must travel in the payload rather than by reference. The block carries these fields:
styleReferenceExtracted, set true;
- the live
source that was measured;
- the measured design tokens, type scale and components the child must build against;
loadedFiles;
proofDemandBack.
If the manifest cannot be assembled, because no Style Reference was extracted or no live source was there to measure, ASK before launching the child rather than starting a silent design dispatch. The child returns the demanded proof. The parent reconciles it on the return path.
- Single-dispatch discipline (operator-gated, session-scoped). The default is ONE cli-* dispatch at a time across the cli-* family (cli-codex, cli-opencode, cli-claude-code). Wait for the dispatched agent's work to return, verify outputs exist, then SIGKILL only the dispatch THIS skill started.
- Capture the PID at launch with
codex exec ... & CODEX_PID=$!, then kill that captured PID directly plus its own orphan children with kill -9 "$CODEX_PID" 2>/dev/null; pkill -9 -P "$CODEX_PID" 2>/dev/null, then apply the same PID-scoped gtimeout cleanup.
- Never use a blanket
pkill -9 -f "codex exec --model" pattern. That matches and kills EVERY running codex exec process on the machine, including the operator's unrelated codex sessions.
- Launch the next dispatch, this skill or a sibling, only after the prior one is dead and RSS has dropped.
- Within a deep-flow session (deep-review / deep-research), the operator authorizes the whole multi-iteration session at start. Iterations chain back-to-back with kill-between as the safety mechanism, not a per-iteration confirmation prompt.
- Exception (cross-skill parallel). When the operator explicitly authorizes N parallel dispatches, run N concurrently, but still SIGKILL each by its own captured PID as its work returns.
Set AI_SESSION_CHILD=1 in the dispatched child's env AND state the exemption in the prompt. The variable makes the waiver true. It does not make it observable.
The reader being waived is a model, and a model cannot see an environment variable, so a child given only the variable still stops to ask the documentation-scope question and writes nothing, at exit code zero.
Copy the preamble from shared/references/child-dispatch-preamble.md to the top of every non-interactive prompt.
A session may be launched through the per-session worktree wrapper (.skilled/bin/worktree-session.sh). A dispatched codex exec is an orchestrated sub-session, not a new top-level session, so it must SHARE the parent's worktree rather than allocate its own.
The wrapper checks AI_SESSION_CHILD, plus a git --git-common-dir structural backstop, and exec's in place when the variable is set. Pattern: AI_SESSION_CHILD=1 codex exec ... </dev/null. This is harmless when the wrapper is not in use.
See .skilled/bin/README.md → "Worktree session isolation".
Agent-persona injection (attach identity, not just the task). Every dispatch composes {resolved agent persona + task prompt}. It never sends a bare task.
- Resolve the persona from the ACTIVE runtime's agent directory per AGENTS.md §9 (
.skilled/agents/<name>.md, .claude/agents/<name>.md, etc.), and never hardcode one runtime.
- Map each subtask to the RIGHT agent (
code→code, review→review, design→design, research→deep-research, docs→markdown), not to one default.
- Codex has no native persona surface.
.codex/agents/*.toml is TUI-only, and codex exec and -p <profile> load sandbox/effort config rather than a persona. So INLINE the persona block into the prompt payload on every dispatch, using the same in-payload pattern as the DESIGN_DISPATCH_MANIFEST in Rule 14, because the child cannot resolve agent paths by reference.
- Put a tool-mapping line directly above the inlined persona. The personas name Claude Code tools (Read, Grep, Glob, Bash) and Codex has only its shell, so the child must be told which shell commands stand in for them. Copy this text unchanged:
TOOL MAPPING: the persona below names tools this runtime does not have. Use your shell for them, read-only: Read = `cat` or `sed -n`, Grep = `rg`, Glob = `find` or `ls`, and `wc` for counts. A persona line that denies Bash does not forbid these read commands. Run no other command.
The text names read commands only. A dispatch that writes keeps the line and states its write surface in the task, under --sandbox workspace-write.
- A persona-less dispatch runs the leaf as a generic assistant, silently dropping the agent's tool-scope, verification gates, and output contract.
Canonical contract:
../../sk-prompt/assets/cli-prompt-quality-card.md "Persona Injection". Native precedent: orchestrate.md "Agent Loading Protocol". Rare exceptions (focused summary for a small-context model, pure-mechanical command) are declared at the dispatch site.
- Never dispatch
codex exec from inside a running codex session. A codex process cannot spawn another codex from inside its own sandbox.
The nested child dies at startup with failed to initialize in-process app-server client: Operation not permitted, observed 2026-09-02 on codex-cli 0.151.0 under --sandbox workspace-write.
The parent reads that as a failed iteration rather than a route violation. So when codex is itself the executor of a deep-loop fan-out lineage or any other orchestrating session, it must do each iteration's work in-process with its own tools and never dispatch a second codex.
Grep that exact message to confirm you are hitting this and not a model or network fault.
⛔ NEVER
- Use
--sandbox danger-full-access without explicit user approval (full shell beyond workspace = damage risk). A no-prompt approval policy does not remove the need for explicit scope approval.
- Trust Codex output blindly for security-sensitive code, send sensitive data (API keys, passwords, credentials) in prompts, or hammer the API with rapid sequential calls.
- Use Codex for tasks where context is already loaded — direct action by the calling AI is faster.
- Assume Codex output is correct without verification — cross-reference codebase and project standards.
- Build or maintain a packet-local Codex execution adapter; the deep-loop runtime is the execution authority.
⚠️ ESCALATE IF
- Codex CLI is not installed and user has not acknowledged (provide
npm i -g @openai/codex).
- Rate limits are persistently exceeded (suggest checking the ChatGPT OAuth account's plan and usage limits).
- Codex output conflicts with existing code patterns (present both perspectives; user decides).
- Task requires
--sandbox danger-full-access (describe risks; get explicit user approval). A no-prompt approval policy still requires explicit scope approval.
Memory Handback Protocol
When the calling AI needs to preserve session context from a Codex CLI delegation, run the canonical procedure: extract the MEMORY_HANDBACK section, build structured JSON, scrub secrets, and invoke generate-context.js via --stdin/--json/temp-file. The continuity writer is the last step, and nothing is handed to an index.
Full procedure and caveats: system-spec-kit/references/cli/memory-handback.md. Codex-specific Memory Epilogue template: assets/prompt-templates.md §13.
printf '%s' "$JSON_PAYLOAD" | node .skilled/skills/system-spec-kit/runtime/cli/dist/continuity/generate-context.js --stdin [spec-folder]
5. REFERENCES
Core References
Templates and Assets
Shared (cli-* family)
External
Reference Loading Notes
- Load only references needed for current intent.
ROUTER.md is the single routing authority.
cli-reference.md is ALWAYS loaded as baseline.
6. SUCCESS CRITERIA
Task Completion
- Codex CLI invoked with correct subcommand, flags, model, and sandbox mode.
- Output captured, validated, and integrated appropriately; no security vulnerabilities introduced.
- Rate limits handled gracefully (retry or fallback strategy).
- Appropriate Codex profile and sandbox level matched to task type (read-only for review, workspace-write for generation).
- Orchestrated execution delegated to the shared deep-loop runtime without a packet-local adapter.
Skill Quality
- All 8 sections present with integer numbering.
- Smart routing covers all intent signals with UNKNOWN_FALLBACK.
- Reference files provide deep-dive content without duplication.
7. INTEGRATION POINTS
Framework Integration
This skill operates within the behavioral framework defined in AGENTS.md.
Key integrations:
- Gate 2: Skill routing via
skill_advisor.py
- Tool Routing: Per AGENTS.md Section 5 decision tree
- Continuity: Context preserved by
/speckit:save, which writes through generate-context.js
- Execution: Shared deep-loop runtime (
../../system-deep-loop/runtime/scripts/fanout-run.cjs)
Tool roles: Bash dispatches the CLI; Read/Glob/Grep validate output.
8. REFERENCES AND RELATED RESOURCES
The router discovers reference, asset, and script docs dynamically (Section 5 is the authored index). Start with the ALWAYS-loaded references/cli-reference.md and assets/prompt-quality-card.md, then load task-specific resources per ROUTER.md.
Related skills: cli-claude-code for extended reasoning, cli-opencode for full OpenCode runtime dispatch, sk-code for code-quality contracts, mcp-code-mode for external MCP work, and system-spec-kit for packet handback.
1---2name: cli-codex3description: "Codex CLI executor for OpenAI-backed coding, repo analysis, PR review, web research, and cross-model validation."4allowed-tools: [Bash, Read, Glob, Grep]5version: 1.9.16.06metadata:7 source: https://skillmd.com/skills/michelkerkmeester/cli-codex8---910# Codex CLI Orchestrator - Cross-AI Task Delegation1112> **CRITICAL — SELF-INVOCATION PROHIBITED**13>14> This skill dispatches to the OpenAI CLI binary (`codex`). If the agent currently reading this skill is itself running inside Codex (detection signals listed in the self-invocation guard in [`ROUTER.md`](./ROUTER.md)), the skill MUST refuse to load and return the documented error message instead of generating any `codex` invocation.15>16> A running CLI skill never dispatches itself. The cli-X skills are for **cross-AI delegation only** — never self-invocation.1718Orchestrate OpenAI's Codex CLI for tasks that benefit from a second AI perspective, real-time web search, deep codebase analysis, built-in code review workflows, or parallel code generation.1920**Core Principle**: Use Codex for what it does best. Delegate, validate, integrate. The calling AI stays the conductor.2122---2324## 1. WHEN TO USE2526### Activation Triggers2728- **Cross-AI Validation** — code review second perspective, security audit alternative analysis, bug detection, `/review` diff-aware workflow.29- **Web Research** — current internet info via the top-level `--search` flag (`codex --search exec …`), latest library versions, API changes, community solutions.30- **Codebase Architecture Analysis** — onboarding to unfamiliar codebases, cross-file dependency mapping, architecture docs from code.31- **Parallel Task Processing** — offloading generation, simultaneous code generations, background docs/test generation.32- **Agent-Delegated Tasks** — specialized profile matches (`.codex/agents/*.toml`), session management (resume, fork), multi-strategy planning.33- **Specialized Generation** — explicit Codex requests, test suite generation, code translation, batch docs (JSDoc, README, API), visual input via `--image`/`-i`.3435### When NOT to Use3637- **You ARE Codex already.** If your runtime is Codex (detection signal: `$CODEX_SESSION_ID` or any `CODEX_*` env var set, `codex` in process ancestry, or `~/.codex/state/<id>/lock` present), this skill refuses to load. Self-invocation creates a circular dispatch loop and burns tokens for no value.38- Simple, quick tasks where CLI overhead is not worth it, or tasks needing an immediate response (rate limits may delay).39- Context already loaded and understood by the current agent.40- Interactive refinement requiring the full-screen TUI (use `codex` directly instead).41- Tasks where Codex CLI is not installed.4243---4445## 2. SMART ROUTING4647The `cli-external-orchestration` hub routes an OpenAI dispatch here: the prompt names Codex, the Codex CLI, `codex exec` or a web-research or second-opinion handoff, and the hub's `cli-codex` mode signal selects this packet.48A session already running inside Codex never routes here; the self-invocation guard refuses it.49The hub [`ROUTER.md`](../ROUTER.md) names the two leaves a dispatch starts from.50Inside this packet the `ALWAYS` tier loads first: `references/cli-reference.md` for the subcommands, flags and sandbox modes, and `assets/prompt-quality-card.md` for the fast-path prompt framework.51Intent-mapped references load after those, one set per intent.52Read [`ROUTER.md`](./ROUTER.md) before selecting skill-local resources; open only the matched files.53Keep every path inside this skill folder, and load a file only when it exists.54When nothing matches, report `UNKNOWN_FALLBACK` with the checklist from the machine router instead of guessing.5556---5758## 3. HOW IT WORKS5960### Prerequisites6162Install with `npm i -g @openai/codex`, or with `brew install --cask codex`.63cli-codex authenticates through **ChatGPT OAuth only**. Run `codex login` and complete the browser flow, which requires a ChatGPT Plus/Pro/Business/Edu/Enterprise account. The skill does not use an OpenAI API key.64The ALWAYS-loaded [cli-reference.md](./references/cli-reference.md) holds the full install, auth, flag, sandbox, session and troubleshooting tables. This section keeps only the routing decisions and dispatch-critical gotchas.6566### Execution Ownership6768This packet owns user-facing routing, the `command -v codex` availability probe, prompt construction, and the self-invocation guard.69Research and review lineages delegate process construction and execution to the already-shipped deep-loop runtime at `../../system-deep-loop/runtime/scripts/fanout-run.cjs`, using executor kind `cli-codex`.70That runner accepts only the `research` and `review` loop types, so a single build or doc dispatch uses the child dispatch envelope in [providers-and-models.md](./references/providers-and-models.md) §5.7172The runtime is the single Codex execution adapter. Do not add a packet-local wrapper, command builder, or spawn path. Direct `codex exec` snippets below are operator reference and manual-testing examples; research and review lineages use the shared runtime, and a one-shot dispatch uses the child envelope.7374### Provider Auth Pre-Flight (ChatGPT OAuth)7576**MANDATORY before any first dispatch in a session.** cli-codex authenticates through ChatGPT OAuth only. If `codex login` has not been completed on this machine, a dispatch fails with `401 Unauthorized` or `not authenticated` mid-round-trip. Run this check once per session, cache the result, and re-run it only if a dispatch fails with an auth error.7778```bash79# One-shot pre-flight: capture ChatGPT OAuth status for routing80CODEX_AUTH=$(codex login status 2>&1)81echo "$CODEX_AUTH" | grep -qi "logged in\|chatgpt-oauth" && CODEX_OAUTH_OK=1 || CODEX_OAUTH_OK=082```8384**Decision tree** (apply in order — first match wins):8586| State | CODEX_OAUTH_OK | Action |87|-------|----------------|--------|88| OAuth ready | 1 | Proceed with `codex exec --model gpt-6-luna -c model_reasoning_effort="medium" -c service_tier="fast"` |89| Not logged in | 0 | **ASK user** to run `codex login` — surface the command, do NOT dispatch. Never substitute an API key or a different model. |9091**User prompt template — not logged in:**9293```94Codex is not authenticated on this machine. cli-codex uses ChatGPT OAuth only.95Run `codex login` (browser flow; requires a ChatGPT Plus/Pro/Business/Edu/Enterprise account),96then confirm when login finishes — the skill will retry the original dispatch.97```9899**Error-recovery contract.** If a dispatch returns an auth error after pre-flight passed (OAuth expired or revoked), invalidate the cache, rerun `codex login`, and re-check before retrying. Never substitute a model the user didn't approve.100101### Default Invocation (Skill Default)102103**Default model + effort + tier**: `gpt-6-luna` · `medium` reasoning · `fast` service tier. Balances speed, cost, and quality for the typical delegation.104A ChatGPT-account login accepts only the models its plan lists, so pass `-m <model>` explicitly when in doubt.105106> **Fan-out fallback:** a deep-loop lineage that pins no model runs **GPT Luna**. The family is named here on purpose, without a version or an effort tier, so this line does not go stale when the family ships a point release; the runner resolves the current id. A drift test keeps the two in the same family.107108```bash109codex exec \110 --model gpt-6-luna \111 -c model_reasoning_effort="medium" \112 -c service_tier="fast" \113 -c approval_policy=never \114 --sandbox workspace-write \115 "<prompt>" </dev/null116```117118The trailing `</dev/null` is not optional in a non-interactive dispatch; Rule 6 below explains what a backgrounded codex does to an inherited stdin.119120**User override** (honor explicit user phrasing verbatim):121122| User says | Resolve to |123|-----------|------------|124| (nothing specified) | `--model gpt-6-luna -c model_reasoning_effort="medium" -c service_tier="fast"` |125| "Use gpt 6 luna high fast" | `--model gpt-6-luna -c model_reasoning_effort="high" -c service_tier="fast"` |126| "Use gpt 6 luna low" | `--model gpt-6-luna -c model_reasoning_effort="low" -c service_tier="fast"` (fast stays unless user drops it) |127| "Use gpt 6 luna xhigh" | `--model gpt-6-luna -c model_reasoning_effort="xhigh" -c service_tier="fast"` |128| "Use gpt 6 luna max" | `--model gpt-6-luna -c model_reasoning_effort="max" -c service_tier="fast"` |129| "Use gpt 5.6 terra high" | `--model gpt-5.6-terra -c model_reasoning_effort="high" -c service_tier="fast"` |130| "Use gpt 6.1 terra high" | `--model gpt-6.1-terra -c model_reasoning_effort="high" -c service_tier="fast"` |131| "Use gpt 6 sol ultra" | `--model gpt-6-sol -c model_reasoning_effort="ultra" -c service_tier="fast"` |132133Honor whichever dimensions the user names. Model stays on `gpt-6-luna` and service tier stays on `fast` unless the user explicitly names a different model or tier; keep the reasoning effort within the chosen model's ceiling (see Model Selection below and the roster in [references/providers-and-models.md](references/providers-and-models.md)).134135### Model Selection136137`gpt-6-luna` at `medium` on the `fast` service tier (`-c service_tier="fast"`) is the skill default for cross-AI delegation.138Alternates are `gpt-5.5` (≤ `xhigh`), and `gpt-5.6-terra`, `gpt-6.1-terra` and `gpt-6-sol` (≤ `ultra`).139[references/providers-and-models.md](references/providers-and-models.md) holds the full roster, the per-model effort ceilings and the 8-level effort ladder.140Set effort with `-c model_reasoning_effort="<level>"`. There is **no `--reasoning-effort` flag**.141142**Selection Strategy**: default `gpt-6-luna medium`; raise to `high` / `xhigh` for architecture, security, and complex planning; take the default model to `max`, or switch to `gpt-6-sol`, when the task wants reasoning past `xhigh`; drop to `low` / `minimal` for trivial lookups. Per-task rationale table: [cli-reference.md](./references/cli-reference.md) §5.143144### Codex Agent Delegation145146The calling AI is the conductor; Codex profiles in `$CODEX_HOME/<name>.config.toml` shape HOW Codex processes the task (sandbox, reasoning). Route with `-p <name>` when the task matches a specialization. Full roster and invocation patterns: [agent-delegation.md](./references/agent-delegation.md).147148| Task Type | Profile |149|-----------|---------|150| Code review / security audit | `review` |151| Architecture exploration | `context` |152| Technical research | `research` (+ top-level `--search`) |153| Documentation generation | `write` |154| Fresh-perspective debugging | `debug` |155| Multi-strategy planning | `ai-council` |156157Git diff review uses the built-in subcommand (no `-p`): `codex exec review "..." --commit HEAD`. Profiles may override `model`, `model_reasoning_effort`, `sandbox_mode`, `approval_policy`. The `.codex/agents/*.toml` files define personas for the interactive multi-agent TUI, NOT the `-p` flag.158159### Dispatch-Critical Gotchas160161The full flag glossary, sandbox modes, unique capabilities (`/review`, `--search`, `codex mcp`, session resume/fork, `--image`, `codex cloud`), essential command examples, and troubleshooting table are in the ALWAYS-loaded [cli-reference.md](./references/cli-reference.md). Six gotchas break a dispatch or make a child misreport its result. Honor them at routing time:162163- **`codex exec` defaults to `--sandbox read-only`** — file-modification tasks silently no-op (the agent plans changes but cannot write them). Pass `--sandbox workspace-write`; for headless no-prompt execution use top-level `-a never` before `exec` or `-c approval_policy=never`.164- **`--search` is a top-level flag, not an `exec` flag.** Enable live web search as `codex --search exec …`, because it precedes the subcommand.165 On codex ≥ 0.144 `codex exec --search` hard-fails with `unexpected argument '--search'`, and older 0.125 builds accepted it, so treat any `exec … --search` example as stale.166 Without it, `codex exec` has no web access and answers from training data only. Every dispatch needing live data (latest versions, repo facts, advisories) MUST use `codex --search exec …`.167- **Always pass `-c service_tier="fast"` explicitly** — this routes through the fast tier instead of whatever the caller's `~/.codex/config.toml` defaults to. Explicit means reproducible regardless of who runs it.168- **No `--reasoning-effort`, `--reasoning`, or `--quiet` flag exists** — set effort with `-c model_reasoning_effort="<level>"`; capture the last message with `-o file.txt`; capture stderr with `2>&1`.169- **`--sandbox workspace-write` blocks local IPC sockets, so a child cannot run checks that start `tsx`.** spec-kit's `npm --prefix runtime/cli run check` fails there with `listen EPERM`, and it also fails with `TMPDIR` pointed elsewhere. It passes outside the sandbox. That was observed 2026-09-24 on codex-cli 0.156.1.170 Tell the child which checks to leave to you, run them in the orchestrating session after it returns, and read that EPERM as a sandbox limit, not a code failure.171- **A read-only dispatch can exit 0 having read nothing.** The agent personas name Claude Code tools, and `codex exec` has only its shell. A child given an inlined persona that denies Bash, with no tool-mapping line above it (Rule 17), can conclude it has no tool it may use.172 That was observed 2026-11-14 on codex-cli 0.167.2 with the `context` persona: the run exited 0 and its report ended `FILES READ: none`. The same prompt read its file on codex-cli 0.169.0, so the failure is intermittent.173 Ask every read-only child to end its report with a `FILES READ:` line, and treat `FILES READ: none`, or a report that names no file, as a failed dispatch whatever the exit status.174175---176177## 4. RULES178179### ✅ ALWAYS1801811. Verify Codex CLI is installed before first invocation (`command -v codex`).1822. Delegate research and review lineages to `../../system-deep-loop/runtime/scripts/fanout-run.cjs` with executor kind `cli-codex`. It rejects every other loop type, so a single build or doc dispatch uses the child dispatch envelope in [providers-and-models.md](./references/providers-and-models.md) §5. Never build a second adapter in this packet.1833. Use `--sandbox read-only` for review/analysis/research; `--sandbox workspace-write` for code generation/file modification — `codex exec` defaults to `read-only`, so omitting it causes silent no-op on edit tasks. For unattended approval, put top-level `-a never` before `exec` or set `-c approval_policy=never`.1844. Validate Codex-generated code (XSS, injection, eval, syntax checks via `node --check`, `tsc --noEmit`, etc.) before applying.1855. Capture stderr (`2>&1`) so rate-limit messages and errors surface.1866. **Redirect codex stdin from `/dev/null` on EVERY non-interactive dispatch**, not only inside a `while read` loop. Pattern: `codex exec "$PROMPT" > "$LOG" 2>&1 </dev/null &`.187 Without `</dev/null`, the backgrounded codex process inherits the loop's stdin, the file after `done < input.jsonl`, and silently consumes the remaining lines. The loop then exits after 3-6 iterations with no error.188 See `references/integration-patterns.md#background-execution` → "Silent Stdin Consumption".1897. **Specify model + effort + service tier explicitly** — never rely on caller environment. Default: `--model gpt-6-luna -c model_reasoning_effort="medium" -c service_tier="fast"`. Honor user overrides verbatim. Use `high`/`xhigh` for reasoning-heavy tasks (architecture, security, deep planning).1908. Route to the appropriate `-p <profile>` when the task matches a specialization (see Section 3 routing table); use `codex exec review` (built-in subcommand) for git diff reviews.1919. **Pass the spec folder to the delegated agent** in the prompt: if the calling AI has an active Gate-3 spec folder, include `Spec folder: <path> (pre-approved, skip Gate 3)`. If none, ASK the user before delegating — the delegated agent cannot answer Gate 3 in non-interactive mode.19210. **Prompt construction & model-craft (cli-* family precedence).** Compose every dispatch prompt via the 2-tier rule canonical in `../../sk-prompt/assets/cli-prompt-quality-card.md`:193 1. **Fast path (default).** Build from the local `assets/prompt-quality-card.md`, which delegates the framework table + CLEAR check to the canonical card.194 2. **Deep path (escalation).** Dispatch `@prompt-improver` via the Task tool (never load full `sk-prompt` inline) when any canonical **Tier 2** trigger applies — the trigger list lives in `../../sk-prompt/assets/cli-prompt-quality-card.md` under "Tier 2 — Deep path"; do not re-enumerate it here.19511. **Never inject user-level voice/personalization content into AI-orchestrated Codex delegations.** Codex CLI reads user-level voice from `~/.codex/AGENTS.md`, the human's global settings, loaded automatically.196 When an AI delegates via `codex exec`, the calling AI's own voice rules govern the response. Do NOT read `~/.codex/AGENTS.md` and paste it into delegation prompts.197 Keep delegations focused on task/model/sandbox/effort/(spec-folder pre-approval).198 If the user asks how to make Codex sound more like Claude in *their own* sessions, point to `~/.codex/AGENTS.md`, not any repo asset.19912. **Code Standards Loading (surface-aware contract).** When you dispatch for code review or code generation, instruct the dispatched session to work these four steps in order.200 - Load `sk-code`.201 - Let `sk-code` emit a surface tag matching the detected stack from markers and target files.202 - Load the selected surface resources and run its verification commands.203 - Add `code-review` only for formal findings-first review output.204 Fallback: if the surface cannot be determined confidently, ask for the runtime surface and verification command set. NEVER hardcode obsolete sibling code skills in dispatch prompts.20513. **Design Standards Loading (measured-reference contract).** When you dispatch for design or UI work, instruct the dispatched session to work these three steps in order.206 - Load `sk-design-md-generator`.207 - Extract a measured Style Reference DESIGN.md from the live source before building UI. It carries named color tokens, a type scale, components and Quick-Start CSS/Tailwind.208 - Build against those measured tokens and run the extraction's validate step to confirm hex/section fidelity.209 Fallback: if there is no live source to measure, ask for the reference URL or the exact tokens to build against. NEVER treat `mcp-figma` or `sk-design-md-generator` as a taste, visual-direction, or critique authority. The extraction measures real CSS. It does not judge design.21014. **Pass the design reference manifest to the dispatched session.** When you dispatch design or UI work, inline a `DESIGN_DISPATCH_MANIFEST v1` block in the prompt, because the child cannot resolve skill paths and the manifest must travel in the payload rather than by reference. The block carries these fields:211 - `styleReferenceExtracted`, set true;212 - the live `source` that was measured;213 - the measured design tokens, type scale and components the child must build against;214 - `loadedFiles`;215 - `proofDemandBack`.216 If the manifest cannot be assembled, because no Style Reference was extracted or no live source was there to measure, ASK before launching the child rather than starting a silent design dispatch. The child returns the demanded proof. The parent reconciles it on the return path.21715. **Single-dispatch discipline (operator-gated, session-scoped).** The default is ONE cli-* dispatch at a time across the cli-* family (cli-codex, cli-opencode, cli-claude-code). Wait for the dispatched agent's work to return, verify outputs exist, then SIGKILL only the dispatch THIS skill started.218 - Capture the PID at launch with `codex exec ... & CODEX_PID=$!`, then kill that captured PID directly plus its own orphan children with `kill -9 "$CODEX_PID" 2>/dev/null; pkill -9 -P "$CODEX_PID" 2>/dev/null`, then apply the same PID-scoped `gtimeout` cleanup.219 - **Never use a blanket `pkill -9 -f "codex exec --model"` pattern.** That matches and kills EVERY running `codex exec` process on the machine, including the operator's unrelated codex sessions.220 - Launch the next dispatch, this skill or a sibling, only after the prior one is dead and RSS has dropped.221 - **Within a deep-flow session** (deep-review / deep-research), the operator authorizes the whole multi-iteration session at start. Iterations chain back-to-back with kill-between as the safety mechanism, not a per-iteration confirmation prompt.222 - **Exception (cross-skill parallel).** When the operator explicitly authorizes N parallel dispatches, run N concurrently, but still SIGKILL each by its own captured PID as its work returns.22316. **Set `AI_SESSION_CHILD=1` in the dispatched child's env AND state the exemption in the prompt.** The variable makes the waiver true. It does not make it observable.224 The reader being waived is a model, and a model cannot see an environment variable, so a child given only the variable still stops to ask the documentation-scope question and writes nothing, at exit code zero.225 Copy the preamble from [`shared/references/child-dispatch-preamble.md`](../shared/references/child-dispatch-preamble.md) to the top of every non-interactive prompt.226 A session may be launched through the per-session worktree wrapper (`.skilled/bin/worktree-session.sh`). A dispatched `codex exec` is an orchestrated sub-session, not a new top-level session, so it must SHARE the parent's worktree rather than allocate its own.227 The wrapper checks `AI_SESSION_CHILD`, plus a `git --git-common-dir` structural backstop, and exec's in place when the variable is set. Pattern: `AI_SESSION_CHILD=1 codex exec ... </dev/null`. This is harmless when the wrapper is not in use.228 See `.skilled/bin/README.md` → "Worktree session isolation".22923017. **Agent-persona injection (attach identity, not just the task).** Every dispatch composes `{resolved agent persona + task prompt}`. It never sends a bare task.231 - Resolve the persona from the ACTIVE runtime's agent directory per AGENTS.md §9 (`.skilled/agents/<name>.md`, `.claude/agents/<name>.md`, etc.), and never hardcode one runtime.232 - Map each subtask to the RIGHT agent (`code`→code, `review`→review, `design`→design, research→`deep-research`, docs→`markdown`), not to one default.233 - **Codex has no native persona surface.** `.codex/agents/*.toml` is TUI-only, and `codex exec` and `-p <profile>` load sandbox/effort config rather than a persona. So **INLINE** the persona block into the prompt payload on every dispatch, using the same in-payload pattern as the `DESIGN_DISPATCH_MANIFEST` in Rule 14, because the child cannot resolve agent paths by reference.234 - **Put a tool-mapping line directly above the inlined persona.** The personas name Claude Code tools (Read, Grep, Glob, Bash) and Codex has only its shell, so the child must be told which shell commands stand in for them. Copy this text unchanged:235 ```text236 TOOL MAPPING: the persona below names tools this runtime does not have. Use your shell for them, read-only: Read = `cat` or `sed -n`, Grep = `rg`, Glob = `find` or `ls`, and `wc` for counts. A persona line that denies Bash does not forbid these read commands. Run no other command.237 ```238 The text names read commands only. A dispatch that writes keeps the line and states its write surface in the task, under `--sandbox workspace-write`.239 - A persona-less dispatch runs the leaf as a generic assistant, silently dropping the agent's tool-scope, verification gates, and output contract.240 Canonical contract: `../../sk-prompt/assets/cli-prompt-quality-card.md` "Persona Injection". Native precedent: `orchestrate.md` "Agent Loading Protocol". Rare exceptions (focused summary for a small-context model, pure-mechanical command) are declared at the dispatch site.24124218. **Never dispatch `codex exec` from inside a running codex session.** A codex process cannot spawn another codex from inside its own sandbox.243 The nested child dies at startup with `failed to initialize in-process app-server client: Operation not permitted`, observed 2026-09-02 on codex-cli 0.151.0 under `--sandbox workspace-write`.244 The parent reads that as a failed iteration rather than a route violation. So when codex is itself the executor of a deep-loop fan-out lineage or any other orchestrating session, it must do each iteration's work in-process with its own tools and never dispatch a second codex.245 Grep that exact message to confirm you are hitting this and not a model or network fault.246247### ⛔ NEVER2482491. Use `--sandbox danger-full-access` without explicit user approval (full shell beyond workspace = damage risk). A no-prompt approval policy does not remove the need for explicit scope approval.2502. Trust Codex output blindly for security-sensitive code, send sensitive data (API keys, passwords, credentials) in prompts, or hammer the API with rapid sequential calls.2513. Use Codex for tasks where context is already loaded — direct action by the calling AI is faster.2524. Assume Codex output is correct without verification — cross-reference codebase and project standards.2535. Build or maintain a packet-local Codex execution adapter; the deep-loop runtime is the execution authority.254255### ⚠️ ESCALATE IF2562571. Codex CLI is not installed and user has not acknowledged (provide `npm i -g @openai/codex`).2582. Rate limits are persistently exceeded (suggest checking the ChatGPT OAuth account's plan and usage limits).2593. Codex output conflicts with existing code patterns (present both perspectives; user decides).2604. Task requires `--sandbox danger-full-access` (describe risks; get explicit user approval). A no-prompt approval policy still requires explicit scope approval.261262### Memory Handback Protocol263264When the calling AI needs to preserve session context from a Codex CLI delegation, run the canonical procedure: extract the `MEMORY_HANDBACK` section, build structured JSON, scrub secrets, and invoke `generate-context.js` via `--stdin`/`--json`/temp-file. The continuity writer is the last step, and nothing is handed to an index.265Full procedure and caveats: [`system-spec-kit/references/cli/memory-handback.md`](../../system-spec-kit/references/cli/memory-handback.md). Codex-specific Memory Epilogue template: [assets/prompt-templates.md](./assets/prompt-templates.md) §13.266267```bash268printf '%s' "$JSON_PAYLOAD" | node .skilled/skills/system-spec-kit/runtime/cli/dist/continuity/generate-context.js --stdin [spec-folder]269```270271---272273## 5. REFERENCES274275### Core References276277- [cli-reference.md](./references/cli-reference.md) - Complete CLI subcommands, flags, sandbox modes, and config reference278- [integration-patterns.md](./references/integration-patterns.md) - Cross-AI orchestration patterns and workflows279- [codex-tools.md](./references/codex-tools.md) - Built-in capabilities documentation (/review, --search, MCP, session management)280- [hook-contract.md](./references/hook-contract.md) - Native hook contract and Spec Kit startup/advisor wiring281- [agent-delegation.md](./references/agent-delegation.md) - Codex agent roster, routing table, and invocation patterns282- [providers-and-models.md](./references/providers-and-models.md) - Single-source catalog of the OpenAI provider, the model roster and the effort ladder283284### Templates and Assets285286- [prompt-templates.md](./assets/prompt-templates.md) - Copy-paste ready prompt templates for common tasks287- [prompt-quality-card.md](./assets/prompt-quality-card.md) - Fast-path prompt framework + CLEAR check (ALWAYS loaded)288289### Shared (cli-* family)290291- [shared-smart-router.md](../../system-spec-kit/references/cli/shared-smart-router.md) - Helper-function bodies for the smart router.292- [memory-handback.md](../../system-spec-kit/references/cli/memory-handback.md) - Canonical 7-step Memory Handback procedure.293294### External295296- [Codex CLI GitHub](https://github.com/openai/codex) - Official repository297- [OpenAI ChatGPT](https://chatgpt.com) - ChatGPT OAuth account (auth for cli-codex)298299### Reference Loading Notes300301- Load only references needed for current intent. [`ROUTER.md`](./ROUTER.md) is the single routing authority.302- `cli-reference.md` is ALWAYS loaded as baseline.303304---305306## 6. SUCCESS CRITERIA307308### Task Completion309310- Codex CLI invoked with correct subcommand, flags, model, and sandbox mode.311- Output captured, validated, and integrated appropriately; no security vulnerabilities introduced.312- Rate limits handled gracefully (retry or fallback strategy).313- Appropriate Codex profile and sandbox level matched to task type (read-only for review, workspace-write for generation).314- Orchestrated execution delegated to the shared deep-loop runtime without a packet-local adapter.315316### Skill Quality317318- All 8 sections present with integer numbering.319- Smart routing covers all intent signals with UNKNOWN_FALLBACK.320- Reference files provide deep-dive content without duplication.321322---323324## 7. INTEGRATION POINTS325326### Framework Integration327328This skill operates within the behavioral framework defined in [AGENTS.md](../../../../AGENTS.md).329330Key integrations:331- **Gate 2**: Skill routing via `skill_advisor.py`332- **Tool Routing**: Per AGENTS.md Section 5 decision tree333- **Continuity**: Context preserved by `/speckit:save`, which writes through `generate-context.js`334- **Execution**: Shared deep-loop runtime (`../../system-deep-loop/runtime/scripts/fanout-run.cjs`)335336**Tool roles**: Bash dispatches the CLI; Read/Glob/Grep validate output.337338---339340## 8. REFERENCES AND RELATED RESOURCES341342The router discovers reference, asset, and script docs dynamically (Section 5 is the authored index). Start with the ALWAYS-loaded `references/cli-reference.md` and `assets/prompt-quality-card.md`, then load task-specific resources per [`ROUTER.md`](./ROUTER.md).343344Related skills: `cli-claude-code` for extended reasoning, `cli-opencode` for full OpenCode runtime dispatch, `sk-code` for code-quality contracts, `mcp-code-mode` for external MCP work, and `system-spec-kit` for packet handback.