consult-codex
The consult-codex skill enables multi-turn conversations with Codex CLI for collaborative problem-solving, second opinions, and brainstorming. Use it when users request to consult, ask, or discuss with Codex rather than executing a single command. The skill maintains session persistence across multiple turns, supports both read-only and workspace-write modes, and provides structured prompting templates with XML tags to shape clearer responses for tasks like diagnosis, code review, and verification-heavy work.
git clone --depth 1 https://github.com/tobihagemann/turbo /tmp/consult-codex && cp -r /tmp/consult-codex/claude/skills/consult-codex ~/.claude/skills/consult-codexSKILL.md
# Consult Codex Multi-turn consultation with Codex CLI. Maintains a conversation across multiple turns using session persistence, unlike single-shot `/codex-exec`. ## Step 1: Gather Context Identify the 2-5 files most relevant to the problem. Formulate a clear, specific question. Include what has been tried and relevant constraints. ## Step 2: Start Session Run `codex exec` with `-o` to capture the response cleanly. Default to `-s read-only` for safety. Use `-s workspace-write` when the consultation requires running code or reading files outside the workspace. **All `codex` Bash calls require `dangerouslyDisableSandbox: true`** (network access to OpenAI API). Use `.turbo/` as the temp directory — it is in the working directory (sandbox-writable), gitignored, and avoids `$TMPDIR` path mismatches between sandbox and non-sandbox mode. **Non-piped `codex exec` invocations require `< /dev/null`** to avoid hanging on stdin. Codex reads from stdin whenever stdin is non-TTY, and in subprocess contexts the harness leaves stdin connected to a pipe that never EOFs — codex blocks forever, printing only `Reading additional input from stdin...`. The piped form (`cat file | codex exec "..."`) is safe — `cat` closes the pipe after the file. Generate a random session tag at the start to keep files unique for parallel use, and print the absolute path prefix it produces: ```bash CODEX_TAG=$(head -c 4 /dev/urandom | xxd -p) && mkdir -p "$PWD/.turbo/codex" && echo "$PWD/.turbo/codex/$CODEX_TAG" ``` Substitute the printed value for `<prefix>` in every later command of this consultation. Shell variables do not survive between Bash tool calls, and an earlier `cd` in a compound command leaves the session in a different directory, so a relative path resolves against that directory instead. Number the `-o` file by turn — `<prefix>-1.txt` for the first, `<prefix>-2.txt` for the next, and so on. A turn that reuses the previous turn's path finds that turn's complete answer waiting there, so a read landing before the current turn finishes returns the wrong answer with nothing to mark it as stale. ```bash codex exec -s read-only -o "<prefix>-1.txt" "<question>" < /dev/null ``` ### Prompt Shaping Structure the question using XML tags for clearer Codex responses: - `<task>`: The concrete question and relevant context. - `<compact_output_contract>`: Desired output shape and brevity requirements. - `<structured_output_contract>`: Same purpose but for structured/schema responses. - `<grounding_rules>`: When claims must be evidence-based (review, research, root-cause analysis). - `<dig_deeper_nudge>`: Push past surface-level findings to check for second-order failures. - `<verification_loop>`: When correctness matters — ask Codex to verify before finalizing. - `<merit_only>`: When a recommendation is wanted, bar answers that appeal to scope. - `<style_constraints>`: When the answer must follow a house style, name the shapes that style forbids. Example prompt for a diagnosis question: ``` <task>Diagnose why the auth middleware rejects valid tokens after the session refactor.</task> <compact_output_contract>Return: (1) most likely root cause, (2) evidence, (3) smallest safe next step.</compact_output_contract> <grounding_rules>Ground every claim in the provided context or tool outputs. Label hypotheses explicitly.</grounding_rules> ``` For correctness-critical questions, add `<verification_loop>` asking Codex to verify its answer before finalizing. When a recommendation is wanted, add `<merit_only>`: state that "out of scope" or "leave it alone" is not an acceptable argument on its own, and that recommending no change must be justified on technical merit. Pair it with `<compact_output_contract>` demanding one pick per decision, the reasoning, and the strongest counterargument to that pick, with hedging across options ruled out. When the consultation is a prose rewrite bound by a house style, add `<style_constraints>` naming the shapes that style forbids in the first prompt, so they do not have to be corrected across follow-up turns. Common ones: prefixing a summary with a grammatical subject the convention omits, expanding a pronoun to its full noun phrase at every occurrence, and splitting a sentence so a condition is restated in both halves. Keep prompts compact, with tight output contracts. One clear task per Codex turn. For context that does not belong in the argument, write a context file with the Write tool and pipe it via stdin. The prompt stays as the argument, context pipes in as `<stdin>` automatically: ```bash cat "<prefix>-ctx.txt" | codex exec -s read-only -o "<prefix>-1.txt" "<question>" ``` A `cat` that fails does not stop the run: codex executes on the bare prompt, burns the full timeout, and returns nothing. Read the stderr chrome for the `cat` error rather than waiting on the `-o` file. Route text you did not author through this channel whatever its size — a diff, file contents, a code comment, a plan or spec, third-party feedback, command output. Keep backticks and `$` out of the quoted argument even in text you wrote, since both stay live inside it. Write the context file with the Write tool so nothing is interpreted on the way in. Parse the `session id:` line from the CLI output. This UUID is needed for follow-up turns. The `session id:` line appears only in the stderr chrome, never on stdout and never in the `-o` file. When a follow-up turn may be needed, do not discard stderr with `2>/dev/null` or capture stdout alone — either silently drops the session id and makes `resume` impossible. If output must be truncated, `2>&1 | grep` for `session id:` so the id is always retained. Run via the Bash tool as a foreground call (`timeout: 600000`, the Bash maximum; do not set `run_in_background`) per turn. A larger timeout is not honored: the harness backgrounds the call immediately and hard-kills codex at 600s, truncating its output. A consult that outlives a valid timeout is normally
For each reviewer question on a PR, recall implementation reasoning and compose a raw answer. Use when the user asks to \"answer reviewer questions\", \"draft answers to PR questions\", or \"explain reviewer questions\".
Apply findings by making the suggested code changes. Applies accepted verdicts, escalates ambiguous findings to the user, and offers to note genuine improvements for later. Use when the user asks to \"apply findings\", \"apply fixes\", \"apply suggestions\", \"apply accepted findings\", \"fix the findings\", or \"apply the review results\".
Project-wide health audit pipeline that fans out to all analysis skills in parallel, evaluates findings, and produces a unified report at .turbo/audit.md. Use when the user asks to \"audit the project\", \"run a full audit\", \"project health check\", \"audit my code\", \"codebase audit\", or \"comprehensive review\".
Shared changelog conventions and formatting rules referenced by $create-changelog and $update-changelog. Not typically invoked directly.
Enforce existence, reuse, mirror, and symmetry principles to keep new code minimal and consistent with surrounding code. Use when writing new code in an existing codebase, adding new features, refactoring, or making any code changes.
Run autonomous task execution using the codex CLI. Use when the user asks to \"codex exec\", \"run codex exec\", \"execute a task with codex\", or \"delegate to codex\".
Run AI-powered code review using the codex CLI. Use when the user asks to \"codex review\", \"run codex review\", or \"review a commit with codex\".
Shared commit message rules and technical constraints referenced by /stage-commit and /commit-staged. Not typically invoked directly.