code-review
Adversarial multi-agent code review orchestrator with consensus voting and multi-repo support. CRITICAL: ONLY activate this skill when the user explicitly triggers the `/code-review` slash command. DO
SKILL.mdskills/code-review/SKILL.md
GitHubMulti-Agent Code Review Workflow
Adversarial multi-agent code review orchestrator coordinating logic, security, and simplification specialists with consensus voting.
0. Invocation Guard
Check the initiating user prompt:
- If this turn was NOT explicitly initiated by
/code-review(or an explicit direct request for this multi-agent review), ABORT this workflow immediately and answer normally without invoking subagents. - Never call subagents automatically for routine questions or diff queries.
0.1 Strict Read-Only Policy (CRITICAL)
- NEVER apply changes, edit code, or create commits/patches automatically during or after the review.
- Code review is strictly advisory and diagnostic.
- Your sole responsibility is to analyze diffs, detect issues, and present findings with replacement diff snippets in markdown.
- DO NOT invoke
replace_file_content,write_to_file, or terminal commands that alter the codebase. - The user will decide whether to apply any changes. Wait for explicit instructions before modifying any code.
1. Multi-Repository & Diff Resolution
Resolve the target repositories and diffs using smart cascade:
- Scan for active git repositories in the workspace:
- Root directory (
git rev-parse --show-toplevel). - Sibling or child folders containing
.gitor declared in.gitmodules. - Any specific repository argument provided by user (
/code-review <repo>).
- Root directory (
- For each repository, inspect git status:
- If user passed a git range:
git -C <repo> diff <range> - Else if uncommitted changes exist:
git -C <repo> diff HEAD - Else if branch diverged from default:
git -C <repo> diff origin/main...HEAD(ormain...HEAD) - Fallback:
git -C <repo> diff HEAD~1
- If user passed a git range:
- Skip repositories with clean diffs. If all are clean, return: "No changes detected across repositories."
- Persistent Review Memory Query:
- For each target repo, detect branch (
git -C <repo> rev-parse --abbrev-ref HEAD). - Query persistent memory via
node skills/review-memory/scripts/memory-store.mjs query --repo <repo> --branch <branch> --files "<files>"to retrieve active conventions and previously dismissed anchor signatures.
- For each target repo, detect branch (
2. Spawn Specialist Reviewers
Concurrently invoke the three specialist subagents using invoke_subagent:
reviewer-logic(gemini-3.1-pro): Reliability, boundaries, async/promises, race conditions, leaks, and cross-repo API contract mismatches.reviewer-security(gemini-3.1-pro): Injections, authorization bypasses, IDOR, data/credential exposure, insecure dependencies.reviewer-simplification(gemini-3.8-flash): Over-engineering, dead flexibility, reinvented stdlib, bloated abstractions.
Pass the repository path, relative file list, diff content, and any Active Project Conventions loaded from review memory to each subagent.
3. Two-Tier Consensus & Verification
Collect and parse JSON outputs from all three specialists:
- Memory Filter: Compare candidate findings against
dismissedSignaturesfor the active branch. If a finding matches a previously dismissed rationale, move it toskippedFindings(do not flag as active blocker or warning). - Critical / Blocker: Retain immediately.
- Moderate / Warning / Simplification: Retain if agreed upon across 2+ subagents OR verified by inspecting the surrounding code in the local file.
- Discard: Drop unverified warnings and purely stylistic nitpicks.
- Line-Anchor: Strictly ensure retained comments point to lines modified in the diff (
+or-).
4. Output Presentation
Format the final review report:
- Assign Stable IDs: Tag each retained finding sequentially (
[REV-1],[REV-2], etc.). - Persist Session Snapshot: Save the findings to session memory via
node skills/review-memory/scripts/memory-store.mjs save-session --repo <repo> --branch <branch> --findings '<json>'(or write to a temp file and pass--findings-file <file>). - Executive Summary Table: Scanned repositories, findings count by category, and simplification metric (
net: -<N> lines possible). - Grouped Findings: For each repository with issues:
- Header:
### [REV-X] [<SEVERITY> <DOMAIN>] <Title> - <file-link> - Concrete risk & failure mode explanation.
- Actionable inline replacement diff block (
- old/+ new).
- Header:
- Dismissed Audit Trail: If
skippedFindingsexist, render a collapsed summary at the bottom:<details> <summary>Skipped <N> previously dismissed findings for this branch</summary> - **[REV-old]** `<file>`: <type> (<rationale>) </details> - Verdict: Blocking issues detected / Changes recommended / Approved.
- Actionable Footer:
💡 Reply
Apply REV-1to apply a specific fix to your code. ReplyDismiss REV-2: <reason>to record a branch dismissal for future reviews. ReplyNote convention: <rule>to capture project conventions.
5. Handling User Follow-Ups
- If the user explicitly asks to apply changes (e.g.
Apply REV-1,Apply all,Fix REV-2):- Inspect the finding details and target file.
- Apply the requested modification surgically using
replace_file_content. - Optionally record the decision via
node skills/review-memory/scripts/memory-store.mjs record-decision --id REV-X --status accepted.
- If the user dismisses a finding (e.g.
Dismiss REV-2: <reason>):- Record the dismissal via
node skills/review-memory/scripts/memory-store.mjs record-decision --id REV-2 --status dismissed --rationale "<reason>".
- Record the dismissal via