From multi-ai-consultant
Consults OpenAI Codex (GPT 5.2) for repo-aware code analysis and reasoning, providing a second opinion on coding problems or architectural decisions. Outputs a 5-part synthesis comparing Codex's analysis with your own.
How this command is triggered — by the user, by Claude, or both
Slash command
/multi-ai-consultant:consult-codexThis command is limited to the following tools:
The summary Claude sees in its command listing — used to decide when to auto-load this command
# Consult OpenAI Codex You are being asked to consult OpenAI's GPT 5.2 via the Codex CLI for a second opinion on a coding problem or architectural decision. ## Your Task 1. **Pre-flight Check**: Verify OpenAI API key is valid 2. **Navigate to Project**: Change to project directory (Codex is repo-aware) 3. **Build Prompt**: Create a clear, specific question 4. **Execute Consultation**: Call Codex with auto-approval flags 5. **Parse Response**: Read output from file 6. **Synthesize**: Compare Codex's analysis with your own reasoning 7. **Present**: Show 5-part synthesis to user 8. **Log Co...
You are being asked to consult OpenAI's GPT 5.2 via the Codex CLI for a second opinion on a coding problem or architectural decision.
# Test if OpenAI API key is valid
if ! command -v openai &>/dev/null; then
echo "⚠️ OpenAI CLI not installed (optional for pre-flight check)"
echo "Attempting Codex consultation anyway..."
else
if ! openai api models.list &>/dev/null 2>&1; then
echo "❌ OpenAI API key not working"
echo ""
echo "Possible issues:"
echo "1. API key not set: export OPENAI_API_KEY='sk-...'"
echo "2. API key invalid: Check https://platform.openai.com/api-keys"
echo ""
echo "After fixing, try the consultation again."
exit 1
fi
fi
# Check if Codex CLI is installed
if ! command -v codex &>/dev/null; then
echo "❌ Codex CLI not installed"
echo ""
echo "Install with: npm install -g codex"
echo "Docs: https://www.npmjs.com/package/codex"
echo ""
exit 1
fi
If pre-flight check fails, stop here and show the error message to the user.
Codex is repo-aware: It automatically scans the current directory for context.
# Get current project directory
PROJECT_DIR=$(pwd)
# Ensure we're in the right place
echo "📂 Consulting on project: $PROJECT_DIR"
Context behavior:
.gitignore automatically@<path> syntax--skip-git-repo-check)The prompt must include:
Format:
Problem: [Brief description]
Question: [Specific question]
I've tried: [Your attempts]
Current status: [What's happening now]
(You have access to the codebase in this directory.)
Note: No need to specify files - Codex automatically has access to the repo.
Required flags for non-interactive use:
--yolo OR --dangerously-bypass-approvals-and-sandbox OR --full-auto--output-last-message /tmp/codex-response.txtRecommended model: gpt-5.2 (latest)
Full command pattern:
PROMPT=$(cat <<'EOF'
[Your formatted prompt here]
EOF
)
# Create temp file for output
RESPONSE_FILE="/tmp/codex-response-$(date +%s).txt"
# Execute Codex (use --yolo to prevent hanging)
echo "$PROMPT" | codex exec - \
-m gpt-5.2 \
--yolo \
--output-last-message "$RESPONSE_FILE" \
--skip-git-repo-check
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "❌ Codex CLI failed (exit code: $EXIT_CODE)"
echo "Check your API key and internet connection"
exit 1
fi
# Read response
if [ ! -f "$RESPONSE_FILE" ] || [ ! -s "$RESPONSE_FILE" ]; then
echo "❌ Codex response file is empty or missing"
exit 1
fi
ANALYSIS=$(cat "$RESPONSE_FILE")
# Clean up
rm -f "$RESPONSE_FILE"
Note: Codex CLI doesn't return token counts in output. Estimate for logging.
# Rough estimation (4 chars = 1 token)
INPUT_TOKENS=$(echo "$PROMPT" | wc -c | awk '{print int($1/4)}')
OUTPUT_TOKENS=$(echo "$ANALYSIS" | wc -c | awk '{print int($1/4)}')
# Add codebase size estimate
CODEBASE_SIZE=$(find . -type f -not -path '*/\.*' -not -path '*/node_modules/*' | xargs wc -c 2>/dev/null | tail -1 | awk '{print int($1/4)}')
INPUT_TOKENS=$((INPUT_TOKENS + CODEBASE_SIZE))
You MUST compare Codex's analysis with your own reasoning. DO NOT just parrot Codex's response.
Required sections:
End with: "Should I proceed with this approach?"
# Calculate cost (GPT 5.2 pricing)
# Input: $0.00001/token, Output: $0.00003/token (example rates, verify current)
COST=$(echo "scale=4; ($INPUT_TOKENS * 0.00001) + ($OUTPUT_TOKENS * 0.00003)" | bc)
# Create log directory if needed
mkdir -p ~/.claude/ai-consultations
# Log consultation
echo "$(date -Iseconds),codex,gpt-5.2,$INPUT_TOKENS,$OUTPUT_TOKENS,$COST,$(pwd)" \
>> ~/.claude/ai-consultations/consultations.log
# Show cost to user
echo ""
echo "---"
echo "Cost: \$$COST (~$INPUT_TOKENS input + $OUTPUT_TOKENS output tokens, estimated)"
echo "Consultation logged: ~/.claude/ai-consultations/consultations.log"
echo "Note: Codex doesn't return exact token counts, these are estimates"
Always respect:
.gitignore (automatically excluded by Codex CLI)Never send:
.env* files*secret* files*credentials* filesnode_modules/ (auto-excluded)Codex warnings:
--skip-git-repo-check to override if neededCommon errors:
OPENAI_API_KEY--yolo flag (critical!)--skip-git-repo-check if appropriateAlways:
When to use Codex instead of Gemini:
When to use Gemini instead:
@<path>)Scenario: React component rendering issue
Prompt:
Problem: Component re-rendering infinitely causing browser freeze
Question: What's causing the infinite loop?
I've tried: Adding useCallback to handler functions
Current status: Still re-rendering, React DevTools shows state updates
(You have access to the codebase in this directory.)
Codex might find: Missing dependency in useEffect, or comparing object references in useEffect dependency array
Your synthesis would:
--yolo flag (prevents hanging)--output-last-message (clean output)--yolo flag (CLI will hang!)After consultation: Present synthesis and wait for user approval before implementing any changes.
2plugins reuse this command
First indexed Jan 1, 2026
npx claudepluginhub midego1/claude-skills --plugin multi-ai-consultant/consult-codexConsults OpenAI Codex (GPT 5.2) for repo-aware code analysis and reasoning, providing a second opinion on coding problems or architectural decisions. Outputs a 5-part synthesis comparing Codex's analysis with your own.
/codexDelegates a task to Codex (OpenAI) via the preferred plugin or CLI fallback. Accepts a prompt and optional --ask flag for interactive mode.