Run adversarial code review by Codex on current changes. Codex reviews the diff, Claude fixes issues autonomously, iterating until convergence.
From adversarial-reviewnpx claudepluginhub anthropics/claude-plugins-community --plugin adversarial-review/adversarial-reviewRuns adversarial Codex review challenging implementation approach, design choices, tradeoffs, and assumptions on git-scoped codebase. Supports --wait, --background, --base <ref>, --scope, focus args.
/adversarial-reviewRun a Gemini review that challenges the implementation approach and design choices
/adversarial-reviewRun a MiniMax review that challenges the implementation approach and design choices
/adversarial-reviewPerform multi-lens adversarial review to challenge implementation correctness, structural fitness, and necessity
/adversarial-reviewRuns adversarial Codex review challenging implementation approach, design choices, tradeoffs, and assumptions on git-scoped codebase. Supports --wait, --background, --base <ref>, --scope, focus args.
/adversarial-reviewRun a Gemini review that challenges the implementation approach and design choices
You are orchestrating an adversarial code review workflow. OpenAI Codex CLI reviews the current code changes, and Claude (you) autonomously fixes any issues found. You iterate until Codex approves or you hit the max iteration limit.
The user has invoked /adversarial-review. Follow these steps exactly:
Generate a unique session slug and create the session directory. Use the Bash tool to run:
SLUG=$(cat /dev/urandom | LC_ALL=C tr -dc 'a-z' | fold -w 4 | head -n 3 | tr '\n' '-' | sed 's/-$//'); SESSION_DIR=".adversarial-review/$SLUG"; mkdir -p "$SESSION_DIR"; ln -sfn "$SLUG" .adversarial-review/latest; echo "$SESSION_DIR"
IMPORTANT: The output of this command is the session directory path (e.g., .adversarial-review/abcd-efgh-ijkl). Use this exact path as $SESSION_DIR in ALL subsequent steps. Every file you read or write in this workflow goes inside this directory.
Read the plan (if it exists) for implementation context:
Use the Read tool on .adversarial-review/latest/plan_final.md if it exists. This provides context about the intent behind the changes. Note: the latest symlink may point to a previous planning session.
Capture current changes. Use the Bash tool to run:
git diff HEAD > $SESSION_DIR/diff_for_review.md 2>/dev/null; git diff --cached >> $SESSION_DIR/diff_for_review.md 2>/dev/null; if [ ! -s $SESSION_DIR/diff_for_review.md ]; then git diff main...HEAD > $SESSION_DIR/diff_for_review.md 2>/dev/null || git diff origin/main...HEAD > $SESSION_DIR/diff_for_review.md 2>/dev/null || echo "No changes detected" > $SESSION_DIR/diff_for_review.md; fi
If the diff is empty or says "No changes detected", inform the user and stop.
Starting at iteration 1, loop up to 20 iterations. For each iteration N (starting at 1):
Send changes for Codex review. Use the Bash tool to run the codex-review script, substituting the actual iteration number for N. On iteration 2+, pass the previous review file as the 5th argument so Codex has context on what it already asked for:
Iteration 1:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/codex-review.sh" $SESSION_DIR/diff_for_review.md $SESSION_DIR/code_review_v1.md code "$(pwd)"
Iteration 2+:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/codex-review.sh" $SESSION_DIR/diff_for_review.md $SESSION_DIR/code_review_v2.md code "$(pwd)" $SESSION_DIR/code_review_v1.md
Always pass the previous iteration's review file (code_review_v{N-1}.md) as the last argument on follow-up iterations.
Read the review. Use the Read tool to read $SESSION_DIR/code_review_vN.md (using the actual number).
Check verdict:
APPROVED:
NEEDS_REVISION:
Read all critical issues carefully
Autonomously apply fixes to the codebase to address ALL critical (blocking) issues
Apply reasonable non-blocking suggestions where appropriate
After making fixes, re-capture the updated diff using the Bash tool:
git diff HEAD > $SESSION_DIR/diff_for_review.md 2>/dev/null; git diff --cached >> $SESSION_DIR/diff_for_review.md 2>/dev/null; if [ ! -s $SESSION_DIR/diff_for_review.md ]; then git diff main...HEAD > $SESSION_DIR/diff_for_review.md 2>/dev/null || git diff origin/main...HEAD > $SESSION_DIR/diff_for_review.md 2>/dev/null || echo "No changes detected" > $SESSION_DIR/diff_for_review.md; fi
Continue the loop with the next iteration number
NEEDS_REVISION and note the parsing issueIf max iterations (20) reached:
Display to the user:
Tell the user:
The adversarial code review is complete. All artifacts are saved in
$SESSION_DIR/.You can review the individual round feedback in
$SESSION_DIR/code_review_v*.mdfiles.