Skip to content
Back to skills

Smart Review

ASecurity

Auto-classifying code review router — rules floor + shadow classifier → dispatches code-review (low/medium/high) or adversarial-review (critical). Logs every classification to a local drift-audit file.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 1, 2026
ai-agentsgobashcode-reviewgitapisecurity

Works with

  • api

Security analysis

A100/100

Scanned October 1, 2026

npx -y skills add williamblair333/Uncle-J-s-Refinery --skill smart-review --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Smart Review?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Smart Review
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/williamblair333-smart-review/badge)](https://www.skillsdirectory.com/skills/williamblair333-smart-review)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: smart-review
description: Auto-classifying code review router — rules floor + shadow classifier → dispatches code-review (low/medium/high) or adversarial-review (critical). Logs every classification to a local drift-audit file.
version: 1.1.0
platforms: [linux, macos]
category: review
tags: [code-review, classification, adversarial, drift-audit, git, quality-gate]
prerequisites:
  commands: [git, gh]
  skills: []
related_skills: [adversarial-review, pre-mortem, prior-art-check]
---

# Smart Review — Auto-Classifying Router

## Step 0 — Get the diff

```bash
git diff @{upstream}...HEAD 2>/dev/null || git diff main...HEAD 2>/dev/null || git diff HEAD~1
git diff --name-only @{upstream}...HEAD 2>/dev/null || git diff --name-only HEAD~1
```

If an argument was passed (PR number, branch, file path), use that as the target instead. Also capture `git diff HEAD` if there are uncommitted changes.

Capture:
- `DIFF_STAT`: total lines added + removed (`git diff --stat`)
- `FILES_CHANGED`: list of changed file paths

---

## Step 1 — Rules floor (deterministic, no model judgment)

Match `FILES_CHANGED` against the table below. The HIGHEST matching tier is the floor. If nothing matches, floor = **Medium**.

| Pattern in any changed file path or content | Floor tier |
|---|---|
| `auth`, `session`, `token`, `password`, `credential`, `secret`, `permission`, `oauth`, `jwt`, `api_key`, `.env` | **Critical** |
| `hooks/`, `.claude/`, `settings.json`, `CLAUDE.md`, `*.service`, `cron`, `systemd`, `@reboot` | **Critical** |
| `migration`, `schema`, `ALTER TABLE`, `DROP TABLE`, `DROP COLUMN` | **Critical** |
| Any file the pre-mortem fired on in this session, AND the change goes beyond what the pre-mortem cleared | **Critical** (floor enforced by collision) |
| Any file the pre-mortem fired on in this session, AND the change IS exactly what the pre-mortem cleared | **High** (collision floor; pre-mortem already covered the risk) |
| New function or class added (diff contains `^+.*def ` or `^+.*class ` or `^+.*function `) | **High** |
| API route added or changed (diff contains `@app.`, `@router.`, `router.get`, `router.post`, `app.use`) | **High** |
| Diff > 150 lines changed | **High** |
| Diff 50–150 lines changed | **Medium** |
| Only `.md`, `.txt`, `.css`, comments, or whitespace changed | **Low** |

Tie-break rule: **always escalate, never downgrade**. Ambiguous = one tier up.

Record: `FLOOR_TIER`

---

## Step 2 — Shadow classifier (independent agent, adversarial upward bias)

Dispatch one Agent with this exact prompt — do NOT pass it the floor tier or your own assessment:

> "You are classifying a code diff for review depth. Your bias is upward — when uncertain, return the HIGHER tier, not the lower. Do not justify your decision with caveats.
>
> Tiers: Low (docs/comments/CSS only), Medium (routine feature/fix), High (complex logic, new API, significant refactor), Critical (auth/security/infrastructure/hooks/config that affects runtime).
>
> Diff stats: {DIFF_STAT}
> Files changed: {FILES_CHANGED}
> Diff:
> {DIFF}
>
> Return exactly: TIER: <Low|Medium|High|Critical> — <one sentence reason>"

Record: `SHADOW_TIER`

---

## Step 3 — Resolve

`RESOLVED_TIER = MAX(FLOOR_TIER, SHADOW_TIER)`

Tier ordering: Low < Medium < High < Critical.

If floor and shadow agree: proceed.
If they disagree: log the discrepancy (see Step 5), use the higher.

---

## Step 4 — Dispatch

| Resolved tier | Action |
|---|---|
| **Low** | Invoke `code-review` skill with `--effort low` argument |
| **Medium** | Invoke `code-review` skill with `--effort medium` argument (default) |
| **High** | Invoke `code-review` skill with `--effort high` argument |
| **Critical** | **Do NOT auto-invoke adversarial-review.** Report the classification and suggest it: "[SMART-REVIEW] Floor: {FLOOR_TIER} | Shadow: {SHADOW_TIER} | Resolved: **Critical** — I recommend running `/adversarial-review` before proceeding. Say yes to proceed." Then **stop and wait** for explicit user approval before invoking the skill. |

Tell the user: `"[SMART-REVIEW] Floor: {FLOOR_TIER} | Shadow: {SHADOW_TIER} | Resolved: {RESOLVED_TIER} → dispatching {tool}"` (for Low/Medium/High). For Critical, omit the dispatching suffix and instead show the recommendation prompt above.

---

## Step 5 — Drift audit log (local)

After every review, append a classification record to the local drift-audit log
(`state/smart-review-classifications.log` under the repo root). memweave has no
write API, so this is a plain append-only file:

```bash
printf '%s\n' "[SMART-REVIEW CLASSIFICATION] $(date -Iseconds)
Files: {FILES_CHANGED}
Diff size: {lines added/removed}
Floor tier: {FLOOR_TIER} (rules matched: {which rules fired})
Shadow tier: {SHADOW_TIER} (shadow reason: {shadow one-liner})
Resolved tier: {RESOLVED_TIER}
Disagreement: {yes/no — if yes, floor was X, shadow was Y}
Review dispatched: {code-review effort={level} | adversarial-review}
" >> /opt/proj/Uncle-J-s-Refinery/state/smart-review-classifications.log
```

(`state/` is gitignored, so the log stays local; the nightly memweave `--all` sync
does not index it.)

---

## Drift audit review (periodic)

When the `session-end-checklist` runs, or on request, scan `state/smart-review-classifications.log` for recent `[SMART-REVIEW CLASSIFICATION]` entries and check:

- How often did floor and shadow disagree?
- Which file paths am I consistently under-classifying?
- Any `Low` classification that touched a file matching a Critical pattern? → that's a rules bug, tighten the table.

If a pattern emerges → add a new row to the rules floor table and update this skill.

---

## Step 6 — Write clearance marker

After the review completes (findings returned or adversarial-review concludes), run:

```bash
HEAD_SHA=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
touch "/tmp/smart-review-cleared-${HEAD_SHA}"
echo "[SMART-REVIEW] Clearance marker written: /tmp/smart-review-cleared-${HEAD_SHA}"
```

This marker is consumed by the PreToolUse hook on `git push` and `gh pr create`. Without it those commands are blocked. The marker is scoped to the current HEAD SHA — a new commit invalidates it.

---

## Notes

- This skill is the default entry point. Users and Claude should call `/smart-review` instead of manually picking `/code-review --effort X`.
- Shadow classifier result is advisory only if floor is Critical — Critical cannot be downgraded by shadow.
- **adversarial-review is NOT auto-dispatched.** When tier resolves Critical, smart-review stops, reports the classification, and suggests `/adversarial-review`. The user must explicitly approve before it runs.
- The shadow agent has upward bias by prompt design. If it says Medium and floor says Low, Medium wins. If it says Low and floor says Medium, Medium wins. Low can only come from unanimous agreement.
- `verification-before-completion` (`superpowers:verification-before-completion`) checks functional correctness. This skill checks code quality and safety. They are complementary — run both before merging anything High or Critical.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.