agentleFS
howar31howar31/magi-workflow/skills/review-code/SKILL.md

review-code

Skill3 starsChanged 7 months agoMITView on GitHub

Review the current git diff and produce DRIFT.md when a sprint context exists. **Mandatory before /magi:commit in sprint mode** — DRIFT.md is required input for the commit step's drift backfill flow. Default behaviour is multi-CLI MAGI cross-review (orchestrator + magi-consensus). Use --single to fall back to a single Opus reviewer (the magi-reviewer subagent) — saves tokens but loses cross-validation. Supports --magi <mode> override and --reviewers override. Never auto-fixes; always presents findings for the user to decide.

41 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use review-deps, review-security and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • cjohnhansonSkill

    review-deps

    Judge dependencies, advisories, and licences. Use as a required review, or as /review-deps. Not for how a dependency is called: review-code covers that.

    Also in 3 projects that use this

  • PydanticSkill

    review-security

    Security review of the current branch against its merge base — sandbox escapes, memory errors, panics and resource-limit bypasses. Use when reviewing changes for security risk, or before merging anything touching the heap/ module, path_security.rs, the wire protocol or the pool.

    Also in 5 projects that use this

  • dirkkok101Skill

    review-design

    Use before /plan, after /technical-design, when user says "review design", "check the design", or when design quality is uncertain.

    Also in 4 projects that use this

  • Microsoft AzureSkill

    review-pr

    Review a pull request for functional issues, coding guideline adherence, and best practices. Use this when asked to review, inspect, or provide feedback on a pull request (Azure DevOps or GitHub). Proposes comments for user approval before posting.

    Also in 4 projects that use this

  • AWSSkill

    ship

    Finalize dev work on an issue branch — update docs, push, and open a PR.

    Also in 6 projects that use this

  • Microsoft AzureSkill

    test

    Also in 4 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 2 are distinctive, and 11 are very specific to this project.

  • 0

    Common

    Most of the 34 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If config missing → tell user to run /magi:setup.

    line 21
  2. Very specific:

    If working tree is clean, fall back to last commit (HEAD~..HEAD) and warn the user.

    line 54
  3. Very specific:

    Use Task tool with subagent_type: magi:reviewer (or --model override).

    line 103
  4. Very specific:

    If unanimous mode + degraded → abort per MAGI_VOTING.md.

    line 196
  5. Very specific:

    Write to <sprint_dir>/MAGI_CODE_REVIEW.md (or fallback to project root if no current sprint).

    line 200
  6. Very specific:

    If a sprint folder was identified and the reviewer prompt included a sprint contract, always write <sprint_dir>/DRIFT.md regardless of …

    line 254
  7. Distinctive:

    Only adopt items that meet the configured threshold.

    line 261
  8. Very specific:

    If verdict = APPROVE: tell user it's safe to commit.

    line 298
  9. Very specific:

    If verdict = APPROVE-WITH-NITS: list nits and ask user whether to address before commit (or note they can defer).

    line 302
  10. Very specific:

    If verdict = REQUEST-CHANGES: enumerate critical issues and recommend /magi:go --task <id> (or manual edit) to address.

    line 305
  11. Very specific:

    If DRIFT.md status = DETECTED, also tell the user the count of A / B / C items so they know what /magi:commit will prompt them to handle.

    line 308
  12. Very specific:

    Always read references/MAGI_VOTING.md before classifying in MAGI mode.

    line 332
  13. Distinctive:

    If the diff is huge (> ~2000 lines): warn the user and offer to split by file or by commit before spending tokens.

    line 334

“Common” is measured: kept by at least 6 in 10 of the 34 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/magi:review-code — code review (MAGI by default)

You are the coordinator. Review the current uncommitted change set (or a specified diff) and produce a structured verdict. Default: multi-CLI MAGI. Fallback: single-reviewer subagent.

0. Preflight

PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-}"
[[ -z "$PLUGIN_ROOT" ]] && PLUGIN_ROOT="$(cd "$(dirname "$BASH_SOURCE[0]")/../.." 2>/dev/null && pwd)"
USER_CONFIG="$HOME/.config/magi-workflow/config.json"

If config missing → tell user to run /magi:setup.

Confirm we are inside a git repo:

git rev-parse --git-dir >/dev/null 2>&1 || { echo "not a git repo"; exit 1; }

0.5. State preflight (auto-refuse if not allowed)

STATE_JSON=$(bash "$PLUGIN_ROOT/scripts/shared/detect-state.sh")
blocked=$(jq -r '.disallowed_skills["review-code"] // empty' <<<"$STATE_JSON")
if [[ -n "$blocked" ]]; then
  reason=$(jq -r '.disallowed_skills["review-code"].reason' <<<"$STATE_JSON")
  suggest=$(jq -r '.disallowed_skills["review-code"].suggest' <<<"$STATE_JSON")
  echo "Cannot run /magi:review-code: $reason"
  echo "Suggested: $suggest"
  exit 1
fi

--force skips preflight. The most common refusal: no diff to review (working tree clean and nothing staged) — make changes first.

1. Determine the diff scope

In priority order:

  • --diff <range> — explicit (e.g. HEAD~3..HEAD, main..HEAD, <file>...). Pass through to git.
  • --staged — review only staged changes.
  • (no flag) — review unstaged + staged changes against HEAD.
    • If working tree is clean, fall back to last commit (HEAD~..HEAD) and warn the user.

Capture the diff:

git diff $diff_args > "$workdir/changes.diff"
git diff --stat $diff_args > "$workdir/changes.stat"

Show the user git diff --stat first so they confirm scope before tokens get spent.

2. Branch on review mode

2a. Single-reviewer mode (--single)

Dispatch the magi-reviewer subagent. Build a brief:

You are dispatched to review this change set.

## Repo
<path>, branch <branch>, target <upstream-branch>

## Diff
<paste of changes.diff or --reference if too large>

## Files to read in full
- <path>
- <path>

## Project context
- TECHSTACK.md: <verbatim or summary>
- Conventions: CLAUDE.md / AGENTS.md (root)

## Sprint contract (if a sprint context exists)
<verbatim PLAN.md and/or SPEC.md from magi/<num>-<slug>/>

## Acceptance criteria (if applicable)
<from current sprint's SPEC.md if exists>

## Output protocol
Follow your standard structure: Verdict + 🔴 / 🟡 / 🟢 sections.
If a sprint contract was provided above, additionally output a
`## Drift from contract` section with A / B / C classes per your agent
spec.

Use Task tool with subagent_type: magi:reviewer (or --model override).

2b. Multi-CLI MAGI mode (default)

Build a reviewer prompt at <workdir>/review-prompt.md:

You are reviewing a software change. Apply skepticism and domain expertise.

## Repo context
<branch info, target branch, recent commits>

## Diff
<paste of changes.diff>

## Files in scope (full content for context)
<paste each touched file's relevant region(s)>

## Project conventions
<from CLAUDE.md / AGENTS.md / TECHSTACK.md>

## Sprint contract (if a sprint context exists)
<verbatim PLAN.md and/or SPEC.md from magi/<num>-<slug>/>

## Acceptance criteria
<from sprint SPEC.md if applicable>

## Your task
Identify concerns. For each, output:

  ## Issue: <short subject>
  Severity: Critical | Important | Note
  Where: <file:line>
  Description: <2–6 sentences>
  Suggested fix: <1–3 sentences>

End with:

  ## Verdict
  APPROVE | APPROVE-WITH-NITS | REQUEST-CHANGES
  <one paragraph>

If a sprint contract was provided above, additionally output a
`## Drift from contract` section classifying any deviations:

  ## Drift from contract

  ### A. Contract violations
  - <subject> — files: <paths>
    What the contract says vs. what the code does.
    Proposed PLAN/SPEC update: <one sentence>.
  (or "(none)" if no contract violations)

  ### B. Below-the-contract decisions
  - <description>
  (or "(none)")

  ### C. Out-of-scope observations
  - <description>
  (or "(none)")

A = code does something the contract did not authorize or contradicts.
B = code chose freely where the contract was silent.
C = new concerns that surfaced during implementation, not in the contract.

Do not edit files.

Invoke orchestrator:

WORKDIR=$(mktemp -d -t magi-review.XXXXXX)
MAGI_REVIEW_WORKDIR="$WORKDIR" \
  "$PLUGIN_ROOT/skills/review-plan/scripts/orchestrator.sh" \
  "$workdir/review-prompt.md" \
  $reviewer_args

Stream events to user. Then run consensus:

"$PLUGIN_ROOT/scripts/shared/magi-consensus.sh" "$WORKDIR" \
  ${magi_override:+--mode "$magi_override"}

Apply MAGI rules per references/MAGI_VOTING.md (semantic dedup + weighted voting). Same procedure as /magi:review-plan step 6.

If policy_pass=false:

  • Required reviewer failed → abort, surface cause.
  • Optional reviewers failed → continue in degraded mode with explicit warning.

If unanimous mode + degraded → abort per MAGI_VOTING.md.

3. Write the consolidated review

Write to <sprint_dir>/MAGI_CODE_REVIEW.md (or fallback to project root if no current sprint). Use output_language:

# 🧠 MAGI Code Review — <branch> @ <short-sha>

**Diff scope:** <range>

## Dashboard

┌─────────────────────────────────────────────────┐ │ VERDICT: <APPROVE | APPROVE-WITH-NITS | ...> │ ├─────────────────────────────────────────────────┤ │ Mode: <mode> Threshold: <value> │ │ OK weight: <ok> / <total> Degraded: <y/n> │ ├─────────────────────────────────────────────────┤ │ <✅|❌> claude <✅|❌> gemini <✅|❌> codex │ ├─────────────────────────────────────────────────┤ │ 🔴 Critical: <N> 🟡 Important: <N> │ │ 🟢 Minority: <N> │ └─────────────────────────────────────────────────┘


Generate this box dynamically using the actual values.

## Verdict
APPROVE | APPROVE-WITH-NITS | REQUEST-CHANGES

## 🔴 Critical (adopted)
...

## 🟡 Important (adopted)
...

## 🟢 Minority
...

## Untested paths
- <path/function> — flagged by <reviewer(s)>

## ⚠️ Degraded mode (if applicable)
<short explanation>

For --single mode the file is <sprint_dir>/SINGLE_CODE_REVIEW.md and omits the MAGI-specific sections (mode/weights/Dashboard/etc.).

Summarise top concerns in chat: include a condensed Dashboard box (verdict + issue counts on 2-3 lines), followed by the top 3 most critical issues.

3.5. Write DRIFT.md (when a sprint context exists)

If a sprint folder was identified and the reviewer prompt included a sprint contract, always write <sprint_dir>/DRIFT.md regardless of whether deviations were found. The file's existence signals "review was run"; the Status field signals "was there drift?".

Apply MAGI semantic dedup + voting to the ## Drift from contract sections of every successful reviewer (same procedure as code-review issues). Only adopt items that meet the configured threshold; below-threshold drift items are dropped (avoid single-reviewer over-flagging).

For --single mode, take the ## Drift from contract section verbatim from the reviewer's output; no voting needed.

Schema:

# Drift — <feature>
> Source: magi-report.md (or single reviewer)  •  Generated: <ISO 8601>  •  Status: NONE | DETECTED

## A. Contract violations
(none)
<or>
- [ ] <description> — files: `<paths>`
  Proposed PLAN/SPEC update: <one sentence>

## B. Below-the-contract decisions
(none)
<or>
- [ ] <description>

## C. Out-of-scope observations
(none)
<or>
- [ ] <description>

Status: NONE when all three sections are (none). Status: DETECTED otherwise. The status field is the canonical signal /magi:commit reads.

DRIFT.md is overwritten on every /magi:review-code run (current-state semantics). Historical record stays in WORKS.md.

4. Hand-off

If verdict = APPROVE: tell user it's safe to commit. Recommend /magi:commit (sprint mode if DRIFT.md was produced — it will pick up DRIFT.md automatically).

If verdict = APPROVE-WITH-NITS: list nits and ask user whether to address before commit (or note they can defer). Then /magi:commit.

If verdict = REQUEST-CHANGES: enumerate critical issues and recommend /magi:go --task <id> (or manual edit) to address. Do not commit.

If DRIFT.md status = DETECTED, also tell the user the count of A / B / C items so they know what /magi:commit will prompt them to handle.

Never commit, never push, never auto-fix. The user is the gate.

Argument parsing

  • --single — use single-reviewer subagent (Opus by default; saves tokens).
  • --magi <mode> — override MAGI mode for this run (majority / supermajority / unanimous / threshold:<N>).
  • --reviewers <list> — override the reviewer roster (e.g. --reviewers claude:opus,gemini:pro to skip codex).
  • --diff <range> — explicit diff range.
  • --staged — only review staged changes.
  • --model <name> — override the single-reviewer model (only with --single).
  • --workdir <path> — reuse an orchestrator workdir (skip fan-out).

Conventions

  • The diff is the source of truth for what to review. Do not review code that is not in the diff (out-of-scope observations are allowed in 🟢 Note only).
  • For renamed files, read both old and new content.
  • Always read references/MAGI_VOTING.md before classifying in MAGI mode.
  • Be conservative in semantic dedup; preserve minority concerns.
  • If the diff is huge (> ~2000 lines): warn the user and offer to split by file or by commit before spending tokens.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.