Second Opinion
Automatically leverage Codex for code review by launching review sessions in tmux panes, managing the review conversation, and iterating until approval.
When to Use
Use this skill proactively in these scenarios:
- •After creating an implementation plan - Automatically when exiting plan mode
- •Significant code changes - Multi-file refactors, architectural changes, new features
- •User request - When explicitly asked to get Codex feedback
Decision heuristic: If the change is non-trivial and would benefit from a second opinion, use this skill.
Workflow
- •
Start Review Session
- •Create tmux horizontal split with Codex in right pane
- •Send initial review prompt with context (plan file or code changes)
- •Set up output monitoring
- •
Poll for Response
- •Check Codex output every 3-5 seconds
- •Wait for response completion (detect output pause)
- •Read and analyze feedback
- •
Iterate on Feedback
- •If issues found: Address them and send updated version
- •If questions raised: Provide clarifications or counterarguments
- •If approved: Proceed to closure
- •
Close Session
- •When review complete (no more concerns, implicit approval)
- •Kill Codex pane
- •Clean up session files
Implementation
CRITICAL: You MUST use the provided scripts. Do NOT generate your own tmux/codex commands.
Starting a Review
# REQUIRED: Use this exact pattern - do not modify or generate alternative commands OUTPUT_DIR="/tmp/codex-review-$(date +%s)" SKILL_DIR="$HOME/.config/claude/skills/second-opinion" "$SKILL_DIR/scripts/start_codex_review.sh" "$REVIEW_PROMPT" "$OUTPUT_DIR"
The script handles:
- •Horizontal tmux split (left: Claude Code, right: Codex)
- •Working directory preservation (Codex runs in the same repo as Claude Code)
- •TTY/terminal requirements
- •Output directory with session metadata
- •Log file for Codex responses
DO NOT use script, expect, or other TTY workarounds - the script handles this.
Monitoring Progress
# Poll for new output (call every 3-5 seconds)
SKILL_DIR="$HOME/.config/claude/skills/second-opinion"
STATUS=$("$SKILL_DIR/scripts/check_codex_status.sh" "$OUTPUT_DIR")
if echo "$STATUS" | head -1 | grep -q "new_output"; then
# New response available
NEW_CONTENT=$(echo "$STATUS" | tail -n +2)
# Analyze and respond
fi
Sending Follow-ups
# Send response to Codex SKILL_DIR="$HOME/.config/claude/skills/second-opinion" "$SKILL_DIR/scripts/send_to_codex.sh" "$OUTPUT_DIR" "Updated the plan to address your concerns: ..."
Ending the Session
# Close Codex pane when done SKILL_DIR="$HOME/.config/claude/skills/second-opinion" "$SKILL_DIR/scripts/close_codex_session.sh" "$OUTPUT_DIR"
Review Prompts
For Implementation Plans
Review the following implementation plan for potential issues, architectural concerns, or improvements. Focus on: - Correctness and completeness - Potential edge cases or bugs - Better approaches or patterns - Security or performance concerns [Plan content here] Provide specific, actionable feedback. If the plan looks good, say so clearly.
For Code Changes
Review these code changes: Files modified: - [List of files] Changes summary: [Brief description] Code diff: [Actual changes] Point out any issues, suggest improvements, or confirm if it looks good.
Completion Detection
Determine review completion by analyzing Codex's response tone and content:
- •Approved: "Looks good", "LGTM", "No issues", "Approved", positive without new concerns
- •Needs work: Specific issues listed, questions raised, suggestions for changes
- •Ambiguous: Ask follow-up to clarify
Important: Don't wait for explicit "DONE" signal. Use natural language understanding to detect completion.
Error Handling
- •Tmux not running: Error early, ask user to start tmux session
- •Codex not found: Verify
codexcommand is in PATH - •Pane closed unexpectedly: Detect in polling loop, restart if needed
- •Codex hangs: Timeout after 60s of no output, prompt user
Scripts
- •
start_codex_review.sh- Initialize tmux split and Codex session - •
check_codex_status.sh- Poll for new Codex output - •
send_to_codex.sh- Send follow-up message to Codex - •
close_codex_session.sh- Clean up tmux pane and session files