---
name: ask-codex
description: NEVER USE IT UNLESS EXPLICITLY ASKED! IT IS FOR HUMAN INVOKATION ONLY
---

# Ask Codex — Delegate Tasks to Codex CLI

Audience: AI coding agents first. Optimize for model activation, not human readability.

Delegate tasks to Codex (OpenAI coding agent) non-interactively via `cdx exec`, called directly — never via a dispatched Agent/subagent whose only job is to shell out to it.
Use for: research, advice, code review, implementation — anything suited to a subagent or advisor call.

## Invocation

```
/ask-codex [model/effort] <task>
```

`model/effort` is optional first token. Everything after (or everything if no spec) = task prompt.

## Step 1 — Parse model/effort

Match first token against pattern `<model-or-shorthand>/<effort>`. If no match → use defaults.

**Model expansion:**
| Input | Resolved |
|---|---|
| `5.6-terra` | `gpt-5.6-terra` |
| `5.6-sol` | `gpt-5.6-sol` |
| `5.6-luna` | `gpt-5.6-luna` |
| already `gpt-*` | pass through |
| *(omitted)* | `gpt-5.6-terra` ← default |

Rule: bare version number `5.X[-suffix]` → prepend `gpt-`. Anything starting `gpt-` → unchanged.

**Effort expansion:**
| Input | Resolved |
|---|---|
| `low` | `low` |
| `med` | `medium` |
| `medium` | `medium` |
| `high` | `high` |
| *(omitted)* | `low` ← default |

## Step 2 — Build prompt

Compose a self-contained prompt for Codex. Include:
- The user's task (verbatim + rephrased if ambiguous)
- Relevant context from current conversation: file paths, code snippets, error messages, constraints
- Expected output shape (analysis, code diff, answer, review findings, etc.)

NEVER pass a bare one-liner if context is available. Codex has no conversation history — front-load everything it needs.

## Step 3 — Run (ONE call, auto-logged)

Call directly from the main loop — do NOT dispatch an Agent/subagent just to shell out to this:

```bash
cdx exec --skip-git-repo-check -m "<resolved-model>" -c "model_reasoning_effort=<resolved-effort>" "<prompt>"
```

`cdx exec` auto-captures codex's full stdout+stderr to a logfile and prints ONLY that logfile path on stdout — nothing else, nothing truncatable. Run it ONCE. NEVER re-run to capture output, NEVER pipe/tee/redirect yourself — the wrapper already does it. Logfile lives under `~/.local/state/overdeck/systray/runtime/logs/cdx/`, NEVER `/tmp`.

NEVER use bare `codex exec`/`codex review`/`codex e` — the deny-gate blocks that exact token (`tools.json` rule `codex-review-raw`). `cdx` is the sanctioned account-routing wrapper (see `tools.json` rule `codex-auth-symlink-mutate`) and does not match the blocked pattern — but it does NOT add safety flags for you; always pass:
- `--skip-git-repo-check` — codex otherwise refuses outside a bare checkout.
- `-m "<model>" -c "model_reasoning_effort=<effort>"` — pins the resolved model/effort; omit and codex silently falls back to its own config default.

Do NOT add `</dev/null` — `cdx exec` sets stdin to `/dev/null` itself. (Interactive `cdx` subcommands still inherit stdio; only `exec` is captured.)

Optional: `-C <dir>` before the prompt sets codex's working directory. To pin a specific codex account, add `--account=<slug>` (or `--profile=<slug>`) as the first arg after `cdx`, before `exec`.

Full command example:
```bash
cdx exec --skip-git-repo-check -m "gpt-5.6-terra" -c "model_reasoning_effort=low" "Review the auth middleware in src/middleware/auth.ts for security issues. Focus on token validation and session handling."
```

## Step 4 — Present result

- The single stdout line IS the logfile path. `Read` that file to get codex's full response.
- Check `cdx`'s exit code — it is codex's own exit code. Non-zero → codex failed (quota, crash, sandbox refusal). Read the logfile for the failure and report it — do NOT present a failed run as a result.
- Show Codex response directly.
- If long: lead with key findings/decisions, then full output.
- Clearly label what is Codex output vs your (Claude) synthesis/additions.
- If Codex made file changes: summarize what changed and verify against user intent before reporting done.

## Quick reference

| Invocation | Model | Effort |
|---|---|---|
| `/ask-codex <task>` | `gpt-5.6-terra` | `low` |
| `/ask-codex 5.6-terra/med <task>` | `gpt-5.6-terra` | `medium` |
| `/ask-codex 5.6-sol/high <task>` | `gpt-5.6-sol` | `high` |
| `/ask-codex gpt-5.6-luna/med <task>` | `gpt-5.6-luna` | `medium` |
| `/ask-codex 5.6-luna/low <task>` | `gpt-5.6-luna` | `low` |
