consult-codex
The consult-codex skill orchestrates parallel code analysis by querying both OpenAI's Codex GPT-5.5 and Claude's code-searcher tool, then comparing their responses to provide comprehensive dual-perspective insights. Use this skill for complex code questions requiring multiple AI viewpoints, such as difficult debugging, architectural decisions, code reviews, or finding specific implementations across large codebases, rather than for straightforward syntax or documentation lookups.
git clone --depth 1 https://github.com/centminmod/my-claude-code-setup /tmp/consult-codex && cp -r /tmp/consult-codex/.claude/skills/consult-codex ~/.claude/skills/consult-codexSKILL.md
# Dual-AI Consultation: Codex GPT-5.5 vs Code-Searcher
You orchestrate consultation between OpenAI's Codex GPT-5.5 and Claude's code-searcher to provide comprehensive analysis with comparison.
## When to Use This Skill
**High value queries:**
- Complex code analysis requiring multiple perspectives
- Debugging difficult issues
- Architecture/design questions
- Code review requests
- Finding specific implementations across a codebase
**Lower value (single AI may suffice):**
- Simple syntax questions
- Basic file lookups
- Straightforward documentation queries
## Workflow
When the user asks a code question:
### 1. Build Enhanced Prompt
Wrap the user's question with structured output requirements:
```
[USER_QUESTION]
=== Analysis Guidelines ===
**Structure your response with:**
1. **Summary:** 2-3 sentence overview
2. **Key Findings:** bullet points of discoveries
3. **Evidence:** file paths with line numbers (format: `file:line` or `file:start-end`)
4. **Confidence:** High/Medium/Low with reasoning
5. **Limitations:** what couldn't be determined
**Line Number Requirements:**
- ALWAYS include specific line numbers when referencing code
- Use format: `path/to/file.ext:42` or `path/to/file.ext:42-58`
- For multiple references: list each with its line number
- Include brief code snippets for key findings
**Examples of good citations:**
- "The authentication check at `src/auth/validate.ts:127-134`"
- "Configuration loaded from `config/settings.json:15`"
- "Error handling in `lib/errors.ts:45, 67-72, 98`"
```
### 2. Invoke Both Analyses in Parallel
**Setup (run first).** `$CLAUDE_PROJECT_DIR` is not always exported into the Bash
tool shell, so resolve it with a `$PWD` fallback and ensure the tmp dir exists.
Substitute the resolved literal path for `$PROJECT_DIR` in every command below.
```bash
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$PWD}"; mkdir -p "$PROJECT_DIR/tmp"
[ -d "$PROJECT_DIR" ] || echo "ERROR: PROJECT_DIR '$PROJECT_DIR' is not a directory"
```
**Codex binary resilience (run once, before dispatch).** An nvm-managed `codex`
can be a symlink whose `@openai/codex` install is broken (deleted vendor binary →
`spawn ... ENOENT`), and a broken version can sit EARLIER on `PATH` than a working
one. `command -v` / `zsh -i` return the broken path, so detect by RUNNING the
binary. If the PATH-resolved codex fails, hunt all nvm node installs for one whose
`--version` succeeds and emit its absolute path. Emit `CODEX_BIN=SKIP` if none work.
```bash
CODEX_BIN=""
if zsh -i -c 'codex --version' >/dev/null 2>&1; then
CODEX_BIN="codex" # PATH-resolved codex works; use the default dispatch
else
for p in $(find "$HOME/.nvm/versions/node" -maxdepth 5 -name codex \( -type f -o -type l \) 2>/dev/null); do
if "$p" --version >/dev/null 2>&1; then CODEX_BIN="$p"; break; fi
done
[ -z "$CODEX_BIN" ] && CODEX_BIN="SKIP"
fi
echo "CODEX_BIN=$CODEX_BIN" # MUST echo: shell vars don't persist across Bash tool calls
```
Launch both simultaneously in a single message with multiple tool calls:
- **For Codex GPT-5.5:**
**Step 1:** Write the enhanced prompt to a temp file using the Write tool:
```
Write to $PROJECT_DIR/tmp/codex-prompt.txt with the ENHANCED_PROMPT content
```
**Step 2:** Execute Codex (allow ~10 min; Codex can be slow). Pipe the prompt
via stdin and capture the JSONL event stream to a file.
**Pick the form based on `CODEX_BIN` from Setup:**
- `CODEX_BIN=codex` → use the **macOS** / **Linux** interactive-shell form below.
- `CODEX_BIN` is an absolute path → use the **absolute-path** form (calls the
binary directly so PATH ordering can't shadow it again).
- `CODEX_BIN=SKIP` → no working codex; skip this dispatch, present only the
Code-Searcher response, and note the failure in §4/§5.
**macOS (`CODEX_BIN=codex`):**
```bash
cat "$PROJECT_DIR/tmp/codex-prompt.txt" \
| zsh -i -c "codex exec -s read-only --json -C '$PROJECT_DIR' 2>&1" \
> "$PROJECT_DIR/tmp/codex-output.jsonl"
```
**Linux (`CODEX_BIN=codex`):**
```bash
cat "$PROJECT_DIR/tmp/codex-prompt.txt" \
| bash -i -c "codex exec -s read-only --json -C '$PROJECT_DIR' 2>&1" \
> "$PROJECT_DIR/tmp/codex-output.jsonl"
```
**Absolute-path (`CODEX_BIN` resolved to a path — macOS & Linux):** substitute
the literal absolute path for `CODEX_BIN_LITERAL`; no shell wrapper needed.
```bash
cat "$PROJECT_DIR/tmp/codex-prompt.txt" \
| CODEX_BIN_LITERAL exec -s read-only --json -C "$PROJECT_DIR" 2>&1 \
> "$PROJECT_DIR/tmp/codex-output.jsonl"
```
Why this exact form (each piece prevents a failure seen in practice):
- **`-s read-only`** is the portable Codex sandbox flag — it needs no
`~/.codex/config.toml` `[profiles.readonly]` entry, unlike `-p readonly`
(which silently misbehaves when that profile is absent).
- **stdin pipe** (`cat … | …`) instead of `"$(cat …)"` avoids the
`Reading additional input from stdin...` hang (Codex waits on stdin when the
prompt is passed as a positional) and ARG_MAX limits on large prompts.
- **`-C '$PROJECT_DIR'`** — outer-shell single-quote expansion of an absolute
path — gives Codex project context. Do NOT pass the dir via an inner-shell
positional (`-C "$0"`/literal placeholders): that produces a cryptic
`Error: No such file or directory (os error 2)` when it goes wrong.
Parse `$PROJECT_DIR/tmp/codex-output.jsonl` with the §2a recipes.
- **For Code-Searcher:** Use Task tool with `subagent_type: "code-searcher"` with the same enhanced prompt
This parallel execution significantly improves response time.
### 2a. Parse Codex `--json` Output Files (jq Recipes)
Codex CLI with `--json` typically emits **newline-delimited JSON events** (JSONL). Some environments may prefix lines with terminal escape sequences; these recipes strip everything before the first `{` and then `fromjson?` safely.
Set a variable first:
```bash
FILE="$PROJECT_DIR/tmp/codex-output.jsonl" # the file the §2 dispatch rediUse this agent for comprehensive codebase analysis, forensic examination, and detailed code mapping with optional Chain of Draft (CoD) methodology. Excels at locating specific functions, classes, and logic, security vulnerability analysis, pattern detection, architectural consistency verification, and creating navigable code reference documentation with exact line numbers. Examples: <example>Context: User needs to find authentication-related code in the project. user: "Where is the user authentication logic implemented?" assistant: "I'll use the code-searcher agent to locate authentication-related code in the codebase" <commentary>Since the user is asking about locating specific code, use the code-searcher agent to efficiently find and summarize authentication logic.</commentary></example> <example>Context: User wants to understand how a specific feature is implemented. user: "How does the license validation work in this system?" assistant: "Let me use the code-searcher agent to find and analyze the license validation implementation" <commentary>The user is asking about understanding specific functionality, so use the code-searcher agent to locate and summarize the relevant code.</commentary></example> <example>Context: User needs to find where a bug might be occurring. user: "I'm getting an error with the payment processing, can you help me find where that code is?" assistant: "I'll use the code-searcher agent to locate the payment processing code and identify potential issues" <commentary>Since the user needs to locate specific code related to an error, use the code-searcher agent to find and analyze the relevant files.</commentary></example> <example>Context: User requests comprehensive security analysis using Chain of Draft methodology. user: "Analyze the entire authentication system using CoD methodology for comprehensive security mapping" assistant: "I'll use the code-searcher agent with Chain of Draft mode for ultra-concise security analysis" <commentary>The user explicitly requests CoD methodology for comprehensive analysis, so use the code-searcher agent's Chain of Draft mode for efficient token usage.</commentary></example> <example>Context: User wants rapid codebase pattern analysis. user: "Use CoD to examine error handling patterns across the codebase" assistant: "I'll use the code-searcher agent in Chain of Draft mode to rapidly analyze error handling patterns" <commentary>Chain of Draft mode is ideal for rapid pattern analysis across large codebases with minimal token usage.</commentary></example>
Execute OpenAI Codex CLI (GPT-5.2) for code analysis. Use when you need Codex's GPT-5.2 perspective on code.
Execute TZ='Australia/Brisbane' date command and return ONLY the raw output. No formatting, headers, explanations, or parallel agents.
Use this agent proactively to synchronize memory bank documentation with actual codebase state, ensuring architectural patterns in memory files match implementation reality, updating technical decisions to reflect current code, aligning documentation with actual patterns, maintaining consistency between memory bank system and source code, and keeping all CLAUDE-*.md files accurately reflecting the current system state. Examples: <example>Context: Code has evolved beyond documentation. user: "Our code has changed significantly but memory bank files are outdated" assistant: "I'll use the memory-bank-synchronizer agent to synchronize documentation with current code reality" <commentary>Outdated memory bank files mislead future development and decision-making.</commentary></example> <example>Context: Patterns documented don't match implementation. user: "The patterns in CLAUDE-patterns.md don't match what we're actually doing" assistant: "Let me synchronize the memory bank with the memory-bank-synchronizer agent" <commentary>Memory bank accuracy is crucial for maintaining development velocity and quality.</commentary></example>
Use this agent when you need comprehensive UX/UI design guidance, including user experience optimization, premium interface design, scalable design systems, data visualization with Highcharts, or Tailwind CSS implementation. Examples: <example>Context: User is building a dashboard with complex data visualizations and wants to improve the user experience. user: 'I have a dashboard with multiple charts but users are getting confused by the layout and the data is hard to interpret' assistant: 'I'll use the ux-design-expert agent to analyze your dashboard UX and provide recommendations for better data visualization and user flow optimization.'</example> <example>Context: User wants to create a premium-looking component library for their product. user: 'We need to build a design system that looks professional and scales across our product suite' assistant: 'Let me engage the ux-design-expert agent to help design a scalable component library with premium aesthetics using Tailwind CSS.'</example> <example>Context: User is struggling with a complex multi-step user flow. user: 'Our checkout process has too many steps and users are dropping off' assistant: 'I'll use the ux-design-expert agent to streamline your checkout flow and reduce friction points.'</example>
Execute z.ai GLM 4.7 model via Claude Code CLI. Use when you need z.ai's GLM 4.7 perspective on code analysis.
Generate PNG images using AI (multiple models via OpenRouter including Gemini, FLUX.2, Riverflow, SeedDream, GPT-5 Image, GPT-5.4 Image 2, proxied through Cloudflare AI Gateway BYOK). Also analyze/describe existing images using multimodal AI vision. Use when user asks to "generate an image", "create a PNG", "make an icon", "make it transparent", "describe this image", "analyze this image", "what's in this image", "explain this image", or needs AI-generated visual assets for the project. Supports model selection via keywords (gemini, riverflow, flux2, seedream, gpt5, gpt5.4), configurable aspect ratios/resolutions, transparent backgrounds (-t), reference image editing (-r), image analysis (--analyze), and per-project cost tracking (--costs).
>