skills/aif-review/SKILL.md
Perform code review on staged changes or a pull request. Checks for bugs, security issues, performance problems, and best practices. Use when user says "review code", "check my code", "review PR", or "is this code okay". Optional +check flag validates findings via a fresh-context subagent.
npx skillsauth add lee-to/ai-factory aif-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Perform thorough code reviews focusing on correctness, security, performance, and maintainability.
FIRST: Read .ai-factory/config.yaml if it exists to resolve:
paths.description, paths.architecture, paths.rules_file, paths.roadmap, and paths.ruleslanguage.ui for review summary languagegit.base_branch for branch comparison guidanceIf config.yaml doesn't exist, use defaults:
.ai-factory/ for all artifactsen (English)base_branch: mainBefore routing the argument string into one of the modes below, extract any standalone tokens that flag optional behavior. Strip them from the argument string and route the remainder normally.
+check — runs the optional findings validator after the review is produced. The full procedure (when to run, failure modes, output additions, gate-result recomputation) lives in references/CHECK-MODE.md. Default is OFF; the validator runs only when this token is present. The token may appear before or after the main argument (e.g. /aif-review +check, /aif-review 123 +check, /aif-review main +check).If the leftover argument string is empty, fall back to the empty-argument mode (staged review). Unknown +-prefixed tokens are passed through as part of the main argument so they are not silently consumed.
Edge case: a git ref literally named
+checkwill be consumed by the flag stripper — acceptable compromise.
git diff --cached to get staged changesgit diff for unstaged changesgh pr view <number> --json to get PR detailsgh pr diff <number> to get the diffArgument routing chain:
#N → PR mode (see above)git rev-parse --verify → commits mode or ask userValidation:
git rev-parse --verify <argument> 2>/dev/null
Valid ref → enter commits mode (steps below)
Invalid ref → do NOT fall back to staged review silently. Ask the user to clarify:
AskUserQuestion: `<argument>` is not a valid git ref. What did you mean?
Options:
1. Review staged changes instead
2. Cancel
Based on choice:
rev-parseEdge case: a branch with a purely numeric name (e.g.
123) will be interpreted as a PR number — acceptable compromise.
Steps:
Get commit list between the ref and HEAD:
git log --oneline --reverse <ref>..HEAD
If no commits found (HEAD is at or behind <ref>), inform the user and stop.
Check commit count: If more than 20 commits, ask the user before proceeding:
AskUserQuestion: Found <N> commits to review. Reviewing all of them will be slow and consume significant context. How to proceed?
Options:
1. Review all <N> commits
2. Review only the last 20
3. Cancel
Based on choice:
Review each commit:
git show <commit-hash> --stat
git show <commit-hash>
For each commit check:
Provide combined summary with per-commit notes
Before finalizing review findings, run read-only context gates:
feat/fix/perf work.Human gate result severity:
WARN for non-blocking inconsistencies or missing optional files.ERROR only for explicit blocking criteria requested by the user/review policy.If the user wants a standalone rules-only pass, suggest /aif-rules-check. Keep human /aif-review gate labels at WARN / ERROR, then append the standard machine-readable gate result with pass|warn|fail status.
This section is the single owner of aif-gate-result computation:
aif-gate-result JSON block after the human-readable review."gate": "review"."status": "pass|warn|fail" — the more severe (fail > warn > pass) of two independent inputs:
fail when any "Critical Issues" item remains (critical correctness, security, data-loss, performance, downstream regression — see references/SEVERITY.md for the authoritative critical/suggestion definitions); warn when only "Suggestions", missing optional context, or review uncertainty remain; pass when nothing material remains.fail for a blocking (ERROR) gate finding; warn for a non-blocking (WARN) one; pass when none."status" at fail even with zero Critical Issues — a clean findings list must never mask a failed gate."blocking": true|false — true only when "status" is fail."blockers" — merge-blocking findings only: every "Critical Issues" item and every blocking context-gate finding, nothing else."affected_files" — reviewed or implicated paths."suggested_next.command" follows "status": fail → /aif-fix by default, but if every blocker came from a single context gate point at that gate's command instead (rules gate → /aif-rules, architecture gate → /aif-architecture, roadmap gate → /aif-roadmap); warn/pass → /aif-commit; null only when no command fits./aif-review is read-only for context artifacts by default. Do not modify context files unless user explicitly asks.
Read .ai-factory/skill-context/aif-review/SKILL.md — MANDATORY if the file exists.
This file contains project-specific rules accumulated by /aif-evolve from patches,
codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
How to apply skill-context rules:
Enforcement: After generating any output artifact, verify it against all skill-context rules. If any rule is violated — fix the output before presenting it to the user.
## Code Review Summary
**Files Reviewed:** [count]
**Risk Level:** 🟢 Low / 🟡 Medium / 🔴 High
### Context Gates
[Architecture / Rules / Roadmap gate results with WARN/ERROR labels]
### Critical Issues
[Each item is a short paragraph in prose, not a labeled record. Order inside the paragraph:
1. Behavioral impact — what breaks for the user or downstream code.
2. Optional note — a code citation, a consequence, or extra context. Include only if it adds signal; skip otherwise.
3. Path — file:line of the affected location (or the closest anchor).
4. Suggested fix — concrete edit that addresses the behavior above.
Example:
> Two clients buying the last item both get a confirmation and stock goes negative — the order creation and stock reservation run in separate transactions. `src/services/order.ts:42`. Wrap `OrderService.create` and `InventoryService.reserve` in a shared transaction so the second buyer fails fast with "out of stock".]
### Suggestions
[Same item shape as Critical Issues. The behavioral impact describes a non-blocking improvement (clarity, performance budget, missing log), not a bug.]
### Questions
[Free-form clarifications. Path optional, fix optional — these are open questions for the author, not findings.]
### Positive Notes
[Free-form acknowledgements of good patterns. No path/fix required.]
When +check reclassifies an item, a short [+check: …] suffix is appended to the item text; see references/CHECK-MODE.md for the exact wording.
Append the final machine-readable result after the markdown summary:
{
"schema_version": 1,
"gate": "review",
"status": "pass",
"blocking": false,
"blockers": [],
"affected_files": [],
"suggested_next": {
"command": "/aif-commit",
"reason": "Review found no blocking issues."
}
}
When the +check flag is set, the aif-gate-result block is assembled after validator filtering — status, blockers, affected_files, and suggested_next are recomputed accordingly. Exception: the whole-dispatch failure path keeps the unfiltered original list and does NOT recompute these fields. See references/CHECK-MODE.md for the full procedure.
User: /aif-review
Review staged changes in current repository.
User: /aif-review 123
Review PR #123 using GitHub CLI.
User: /aif-review https://github.com/org/repo/pull/123
Review PR from URL.
User: /aif-review 2.x
Review all commits on the current branch compared to branch 2.x.
User: /aif-review main
Review all commits on the current branch compared to main (or to whatever branch is configured as git.base_branch in this repository).
User: /aif-review v1.0.0
Review all commits on the current branch compared to tag v1.0.0.
User: /aif-review +check
Review staged changes, then run the +check validator over Critical Issues and Suggestions before rendering. The validator can drop invented items, rewrite partially-correct ones, and reclassify items between the two severity levels (promote a suggestion to critical or demote a critical to suggestion — see references/SEVERITY.md for the rules). It adds a filtering-summary line and rebuilds the gate result from the surviving findings; see references/CHECK-MODE.md for the exact line format.
User: /aif-review 123 +check
Review PR #123 with +check validation enabled.
If GitHub MCP is configured, can:
Tip: Context is heavy after code review. Consider
/clearor/compactbefore continuing with other tasks.
data-ai
Archive completed plans and roadmap milestones. Moves finished plans to the archive directory and optionally trims closed milestones from ROADMAP.md. Use when user says "archive plans", "clean up plans", "archive completed", or "trim roadmap".
tools
Set up agent context for a project. Analyzes tech stack, installs relevant skills from skills.sh, generates custom skills, and configures MCP servers. Use when starting new project, setting up AI context, or asking "set up project", "configure AI", "what skills do I need".
development
Verify completed implementation against the plan. Checks that all tasks were fully implemented, nothing was forgotten, code compiles, tests pass, and quality standards are met. Use after "/aif-implement" completes, or when user says "verify", "check work", "did we miss anything".
data-ai
Plan implementation for a feature or task. Two modes — fast (single quick plan) or full (richer plan with optional git branch/worktree flow). Use when user says "plan", "new feature", "start feature", "create tasks".