skills/code-review/SKILL.md
Review code changes for bugs, security vulnerabilities, and code quality issues — producing prioritized findings with specific fix suggestions. Don't use for performance tuning, writing new features from scratch, or generating test cases.
npx skillsauth add luongnv89/skills code-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.
Review code for quality issues, code smells, and pragmatic programming violations.
Use this skill when the user asks for a code review, PR review, audit, security check, or "review my changes". Trigger on phrases like "review this code", "audit this repo", "check this PR for issues", or "find bugs in these files". Do not trigger for performance profiling, writing new features from scratch, or test-case generation.
First, run the Repo Sync workflow below. Then complete the Environment Check to pick a mode (PR/diff vs full audit). Next, follow the Instructions phases (checklist scan -> findings synthesis -> validation). Finally, emit the Output Format report and verify Acceptance Criteria.
The skill orchestrates parallel reviewer subagents over batched files, then runs a validator pass. Each phase has explicit steps below. Read only the section you need; the rest is reference material.
Before creating/updating/deleting files in an existing repository, sync the current branch with remote:
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin
git pull --rebase origin "$branch"
If the working tree is not clean, stash first, sync, then restore:
git stash push -u -m "pre-sync"
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin && git pull --rebase origin "$branch"
git stash pop
If origin is missing, pull is unavailable, or rebase/stash conflicts occur, stop and ask the user before continuing.
Before proceeding with code review:
/Agent subagent system is availableFor full codebase audits and large PRs, use parallel subagent architecture:
┌─────────────────────────────────┐
│ Main SKILL (Orchestrator) │
│ - Parse scope (PR/audit) │
│ - Batch files into groups │
│ - Check Agent availability │
└──────────────┬──────────────────┘
│
┌───────┴───────┬───────────┬─────────────┐
│ │ │ │
v v v v
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
│ Reviewer 1 │ │ Reviewer 2 │ │ Reviewer 3 │ │ Reviewer N │
│ Batch 1 │ │ Batch 2 │ │ Batch 3 │ │ Batch N │
│ 5-10 │ │ 5-10 │ │ 5-10 │ │ 5-10 │
│ files │ │ files │ │ files │ │ files │
│ (parallel) │ │ (parallel) │ │ (parallel) │ │ (parallel) │
└─────┬──────┘ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘
│ │ │ │
│ └──────────────┴──────────────┘
│ │
└─────────────────────────────┘
│
┌────────────v────────────────┐
│ Report Assembler │
│ - Merge all findings │
│ - Deduplicate issues │
│ - Rank by severity │
│ - Generate CODE_REVIEW.md │
└────────────┬────────────────┘
│
┌───────v────────┐
│ Reviewer │
│ Validator │
│ - Fresh eyes │
│ - Verify │
│ - Completeness│
└────────────────┘
agents/file-reviewer.md — Review a batch of 5-10 files against the full checklist
agents/report-assembler.md — Merge all batch results into one report
agents/reviewer.md — Fresh-context validation pass
Mode 1: Small PR/Diff (Fast Path - Inline)
Mode 2: Medium Audit (Batched with Subagents)
Mode 3: Large Audit (Sampled with Subagents)
If Agent tool unavailable:
Missed cross-file smells: Report-assembler cross-file analysis partially mitigates by identifying:
Context overflow: Batching 5-10 files per agent keeps context manageable while maintaining review quality.
False positives: Reviewer agent catches most false positives through fresh-context validation before final report.
# Get changed files
git diff --name-only <base>..HEAD
git diff <base>..HEAD
Focus only on changed lines and their immediate context.
Scan all source files, prioritizing:
git log --format='%H' | head -100 | xargs -I{} git diff-tree --no-commit-id --name-only -r {} | sort | uniq -c | sort -rn)Read references/code-smells.md when a code smell is identified that requires the full catalog for classification.
Bloaters - Code that grows too large
Object-Orientation Abusers
Change Preventers
Dispensables
Couplers
DRY (Don't Repeat Yourself)
Orthogonality
Reversibility
Tracer Bullets
Good Enough Software
Broken Windows
Generate CODE_REVIEW.md:
# Code Review Report
**Date**: YYYY-MM-DD
**Scope**: [PR #123 | Full Audit]
**Files Reviewed**: N
## Summary
| Severity | Count |
|----------|-------|
| Critical | X |
| Major | X |
| Minor | X |
| Info | X |
## Critical Issues
### [Category]: Issue Title
**File**: `path/to/file.ts:42`
**Smell**: [Code smell name]
Description of the issue.
**Before**:
```language
// problematic code
Suggested Fix:
// improved code
...
...
## Expected Output
A `CODE_REVIEW.md` file with findings grouped by severity. Example:
```markdown
# Code Review Report
**Date**: 2024-01-15
**Scope**: PR #42 — auth module refactor
**Files Reviewed**: 8
## Summary
| Severity | Count |
|----------|-------|
| Critical | 1 |
| Major | 3 |
| Minor | 5 |
| Info | 2 |
## Critical Issues
### [Security]: Hardcoded API Secret
**File**: `src/auth/client.ts:17`
**Smell**: Hardcoded secrets
API key is embedded directly in source code and will be committed to version control.
**Before**:
```typescript
const API_KEY = "sk-prod-abc123xyz";
Suggested Fix:
const API_KEY = process.env.API_KEY;
if (!API_KEY) throw new Error("API_KEY env var is required");
.env to .gitignore and document required vars in READMEUserService class into smaller focused services
## Acceptance Criteria
A run passes when **all** of the following are true:
- [ ] `CODE_REVIEW.md` exists in the repo root with `# Code Review Report` as the first heading.
- [ ] Report includes a `## Summary` table with rows for Critical, Major, Minor, and Info severities.
- [ ] Every reported finding cites a `path/to/file.ext:line` reference and a code smell or category label.
- [ ] Critical findings include both a "Before" and "Suggested Fix" code block when a code change is proposed.
- [ ] Mode used (Mode 1/2/3) is recorded in the report header along with the file count.
- [ ] No merge-conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) are silently dropped — they appear as Critical findings if present in the source.
## Edge Cases
- **Empty or whitespace-only diff**: Report scope as zero files reviewed; skip review and inform the user.
- **Binary files or generated code**: Skip minified/generated files (e.g., `dist/`, `*.min.js`, `package-lock.json`) and note them as excluded in the report header.
- **Single-language vs. polyglot repos**: Apply language-appropriate checks for each file; don't flag Python idioms as issues in JS files.
- **No issues found**: Produce a report with all-zero severity counts and a brief "LGTM" summary — don't fabricate findings.
- **Files exceeding context limits**: Fall back to mode 3 (sampling) and note which files were sampled vs. fully reviewed.
- **Merge conflict markers**: Flag any `<<<<<<<` / `=======` / `>>>>>>>` as a Critical issue — never silently ignore them.
## Step Completion Reports
After completing each major step, output a status report in this format:
◆ [Step Name] ([step N of M] — [context]) ·································································· [Check 1]: √ pass [Check 2]: √ pass (note if relevant) [Check 3]: × fail — [reason] [Check 4]: √ pass [Criteria]: √ N/M met
Result: PASS | FAIL | PARTIAL
Adapt the check names to match what the step actually validates. Use `√` for pass, `×` for fail, and `—` to add brief context. The "Criteria" line summarizes how many acceptance criteria were met. The "Result" line gives the overall verdict.
### Skill-specific checks per phase
**Phase: Scope Assessment** — checks: `Scope assessment`, `File count estimated`
**Phase: Review Execution** — checks: `Code smell detection`, `Security scan`
**Phase: Report Generation** — checks: `Report generation`, `Severity classification`
**Phase: Validation Pass** — checks: `Validation pass`, `False positive check`
## Severity Levels
| Level | Description | Action |
|-------|-------------|--------|
| **Critical** | Security risks, bugs, data loss potential | Must fix before merge |
| **Major** | Code smells, maintainability blockers | Should fix soon |
| **Minor** | Style, minor improvements | Nice to have |
| **Info** | Suggestions, alternatives | Optional |
## Resources
- [references/code-smells.md](references/code-smells.md) - Complete catalog of code smells with examples
documentation
Manage software releases end-to-end: bump version, generate changelog, tag, push, GitHub release, publish to PyPI/npm. Use when user asks to ship, cut a release, tag a version, or list changes since last tag. Skip routine commits and marketplace publishing.
development
Review UI for usability issues using Steve Krug's principles and produce a scannable report. Use when asked for a usability audit, UX review, or UI feedback on screenshots, URLs, or code. Don't use for visual/brand design critique, accessibility (WCAG) audits, or backend/API review.
development
Validate app/startup ideas with market, feasibility, commercial, and open-source competitor analysis. Use when asked to evaluate, validate, or score a product idea. Don't use for PRDs, go-to-market plans, or investor decks.
testing
Install local-first security hardening: pre-commit secret detection, offline dependency scans, static analysis, reports, and gated free CI. Use when hardening repos or adding security hooks. Don't use for incident response or cloud security reviews.