Codex Second Opinion
Get a second opinion from OpenAI Codex on your current work. Codex uses your configured model and settings.
How to call
Call with your context on stdin. A Codex call takes as long as the work takes; use Bash run_in_background: true and wait for Claude Code's completion notification instead of sleep-polling.
echo "<gathered context>" | python3 ${CLAUDE_PLUGIN_ROOT}/skills/codex-opinion/scripts/ask_codex.py
The script bookends stdin with a short default review directive. Pass a positional arg to override it, or --no-default-instruction to skip the wrapper entirely.
Building the context
If there are uncommitted changes:
git diff HEAD | python3 ${CLAUDE_PLUGIN_ROOT}/skills/codex-opinion/scripts/ask_codex.py
If there are also untracked files that matter, include them (with binary/size guards):
{ git diff HEAD
git ls-files --others --exclude-standard | while IFS= read -r f; do
file --mime "$f" | grep -q 'charset=binary' && continue
[ $(wc -c <"$f") -gt 32768 ] && continue
printf '\n=== %s ===\n' "$f"
cat "$f"
done
} | python3 ${CLAUDE_PLUGIN_ROOT}/skills/codex-opinion/scripts/ask_codex.py
If the tree is clean, gather context yourself:
echo "Review this codebase. Key files: ..." | python3 ${CLAUDE_PLUGIN_ROOT}/skills/codex-opinion/scripts/ask_codex.py
With a custom instruction (from user text after /codex-opinion:codex-opinion):
echo "<context>" | python3 ${CLAUDE_PLUGIN_ROOT}/skills/codex-opinion/scripts/ask_codex.py "user's instruction"
Never pipe an empty string. If git diff HEAD would be empty, use echo with gathered context instead.
Session continuity
One Codex session per project, persisted across Claude Code sessions. Follow-up calls resume the prior Codex thread so it keeps its accumulated codebase knowledge. Reframe when the task shifts so prior framing doesn't bias later turns. If the session has expired server-side, the script logs a notice and starts fresh.
Set CODEX_OPINION_SESSION_KEY before launching Claude Code to isolate a session from the project-wide thread.
After Codex responds
Reconcile Codex's findings with your own read, then tell the user what changed, what you accept, what you challenge, and what remains uncertain.
Multi-turn is available when a reply warrants follow-up (Claude → Codex → Claude → Codex → reconcile); default is single-turn.