Review Codebase
Multi-phase deep codebase review producing severity-rated findings w/ fix-order rec. Unlike review-pull-request (scoped to diff) or single-domain reviews (security-audit-codebase, review-software-architecture), covers entire project/subproject across all quality dims in one pass.
Use When
- Whole-project or subproject review (not PR-scoped)
- New codebase onboarding — building mental model of what exists + needs attention
- Periodic health checks after sustained dev
- Pre-release quality gate across architecture, security, code quality, UX
- Output should feed directly into issue creation or sprint planning
In
- Required:
target_path — root dir of codebase/subproject
- Optional:
scope — phases to run: full (default), security, architecture, quality, ux
output_format — findings (table only), report (narrative), both (default)
severity_threshold — min severity: LOW (default), MEDIUM, HIGH, CRITICAL
Do
Step 1: Census
Inventory codebase → est scope + ID review targets.
- Count files by lang/type:
find target_path -type f | sort by extension
- Measure total line counts per lang
- ID test dirs + estimate coverage (files w/ tests vs without)
- Check dep state: lockfiles present, outdated deps, known vulns
- Note build system, CI/CD config, docs state
- Record census as opening section of report
→ Factual inventory — file counts, langs, test presence, dep health. No judgments yet.
If err: target empty/inaccessible → stop + report. Specific subdirs inaccessible → note + continue w/ available.
Step 2: Architecture Review
Assess structural health: coupling, duplication, data flow, separation of concerns.
- Map module/dir structure + ID primary architectural pattern
- Check code duplication — repeated logic across files, copy-paste
- Assess coupling — how many files must change for single feature mod
- Eval data flow — clear boundaries between layers (UI, logic, data)?
- ID dead code, unused exports, orphaned files
- Check consistent patterns — codebase follows own conventions?
- Rate each: CRITICAL, HIGH, MEDIUM, LOW
→ List of architectural findings w/ severity + file refs. Common: mode dispatch duplication, missing abstraction layers, circular deps.
If err: codebase too small for meaningful review (<5 files) → note + skip Step 3. Architecture review needs enough code to have structure.
Step 3: Security Audit
ID security vulns + defensive coding gaps.
- Scan injection vectors: HTML (
innerHTML), SQL, command injection
- Check authn + authz patterns (if applicable)
- Review error handling — silently swallowed? Leak internals?
- Audit dep versions vs known CVEs
- Check hardcoded secrets, API keys, creds
- Review Docker/container security: root user, exposed ports, build secrets
- Check localStorage/sessionStorage for sensitive data
- Rate each: CRITICAL, HIGH, MEDIUM, LOW
→ List of security findings w/ severity, affected files, remediation. CRITICAL = injection vulns + exposed secrets.
If err: no security-relevant code (pure docs project) → note + skip Step 4.
Step 4: Code Quality
Eval maintainability, readability, defensive coding.
- ID magic numbers + hardcoded values should be named consts
- Check consistent naming across codebase
- Find missing input validation at system boundaries
- Assess error handling — consistent? Useful messages?
- Check commented-out code, TODO/FIXME, incomplete impls
- Review test quality — testing behavior or impl details?
- Rate each: CRITICAL, HIGH, MEDIUM, LOW
→ List of quality findings → maintainability. Common: magic numbers, inconsistent patterns, missing guards.
If err: codebase generated/minified → note + adjust expectations. Generated code has diff quality criteria than hand-written.
Step 5: UX + a11y (if frontend exists)
Eval UX + a11y compliance.
- Check ARIA roles, labels, landmarks on interactive
- Verify keyboard nav — all interactive reachable via Tab?
- Test focus mgmt — focus moves logically when panels open/close?
- Check responsive — test at common breakpoints (320px, 768px, 1024px)
- Verify color contrast meets WCAG 2.1 AA
- Check screen reader compat — dynamic content changes announced?
- Rate each: CRITICAL, HIGH, MEDIUM, LOW
→ List of UX/a11y findings w/ WCAG refs. No frontend → "N/A — no frontend code detected."
If err: frontend exists but can't render (missing build step) → audit source code statically + note runtime testing not possible.
Step 6: Findings Synthesis
Compile all findings → prioritized summary.
- Merge findings from all phases → single table
- Sort by severity (CRITICAL first, then HIGH, MEDIUM, LOW)
- Within each severity, group by theme (security, architecture, quality, UX)
- Each finding: severity, phase, file(s), one-line description, suggested fix
- Produce rec fix order considering deps between fixes
- Summarize: total findings by severity, top 3 priorities, est effort level
→ Findings table w/ columns: #, Severity, Phase, File(s), Finding, Fix. Fix-order rec accounting for deps (e.g. "refactor architecture before adding tests").
If err: no findings produced → finding itself — codebase exceptionally clean or review too shallow. Re-examine ≥1 phase deeper.
Check
Scaling w/ Rest
Between review phases, use /rest as checkpoint — esp between phases 2-5 needing diff analytical perspectives. Checkpoint rest (brief, transitional) prevents momentum of one phase biasing next. See rest "Scaling Rest" for guidance on checkpoint vs full rest.
Traps
- Boiling ocean: Reviewing every line of large codebase produces noise. Focus high-impact: entry points, security boundaries, architectural seams.
- Severity inflation: Not every finding CRITICAL. Reserve CRITICAL for exploitable vulns + data-loss risks. Most architectural = MEDIUM.
- Missing forest for trees: Individual code quality matters less than systemic patterns. Magic numbers in 20 files = 1 architectural finding not 20 quality.
- Skip census: Census (Step 1) seems bureaucratic but prevents reviewing code that doesn't exist or missing entire dirs.
- Phase bleed: Security findings during architecture, or quality during security audit. Note for correct phase, no mix concerns — produces cleaner table.
→
security-audit-codebase — deep-dive when review-codebase security phase reveals complex vulns
review-software-architecture — detailed architecture review for specific subsystems
review-ux-ui — comprehensive UX/a11y audit beyond phase 5
review-pull-request — diff-scoped review for individual changes
clean-codebase — impl code quality fixes ID'd by this review
create-github-issues — convert findings → tracked GH issues
1---2name: review-codebase-103description: Multi-phase deep codebase review w/ severity ratings + structured output. Architecture, security, code quality, UX/a11y in single coordinated pass. Produces prioritized findings table → direct conversion to GH issues via create-github-issues.4license: MIT5---67# Review Codebase89Multi-phase deep codebase review producing severity-rated findings w/ fix-order rec. Unlike `review-pull-request` (scoped to diff) or single-domain reviews (`security-audit-codebase`, `review-software-architecture`), covers entire project/subproject across all quality dims in one pass.1011## Use When1213- Whole-project or subproject review (not PR-scoped)14- New codebase onboarding — building mental model of what exists + needs attention15- Periodic health checks after sustained dev16- Pre-release quality gate across architecture, security, code quality, UX17- Output should feed directly into issue creation or sprint planning1819## In2021- **Required**: `target_path` — root dir of codebase/subproject22- **Optional**:23 - `scope` — phases to run: `full` (default), `security`, `architecture`, `quality`, `ux`24 - `output_format` — `findings` (table only), `report` (narrative), `both` (default)25 - `severity_threshold` — min severity: `LOW` (default), `MEDIUM`, `HIGH`, `CRITICAL`2627## Do2829### Step 1: Census3031Inventory codebase → est scope + ID review targets.32331. Count files by lang/type: `find target_path -type f | sort by extension`342. Measure total line counts per lang353. ID test dirs + estimate coverage (files w/ tests vs without)364. Check dep state: lockfiles present, outdated deps, known vulns375. Note build system, CI/CD config, docs state386. Record census as opening section of report3940→ Factual inventory — file counts, langs, test presence, dep health. No judgments yet.4142If err: target empty/inaccessible → stop + report. Specific subdirs inaccessible → note + continue w/ available.4344### Step 2: Architecture Review4546Assess structural health: coupling, duplication, data flow, separation of concerns.47481. Map module/dir structure + ID primary architectural pattern492. Check code duplication — repeated logic across files, copy-paste503. Assess coupling — how many files must change for single feature mod514. Eval data flow — clear boundaries between layers (UI, logic, data)?525. ID dead code, unused exports, orphaned files536. Check consistent patterns — codebase follows own conventions?547. Rate each: CRITICAL, HIGH, MEDIUM, LOW5556→ List of architectural findings w/ severity + file refs. Common: mode dispatch duplication, missing abstraction layers, circular deps.5758If err: codebase too small for meaningful review (<5 files) → note + skip Step 3. Architecture review needs enough code to have structure.5960### Step 3: Security Audit6162ID security vulns + defensive coding gaps.63641. Scan injection vectors: HTML (`innerHTML`), SQL, command injection652. Check authn + authz patterns (if applicable)663. Review error handling — silently swallowed? Leak internals?674. Audit dep versions vs known CVEs685. Check hardcoded secrets, API keys, creds696. Review Docker/container security: root user, exposed ports, build secrets707. Check localStorage/sessionStorage for sensitive data718. Rate each: CRITICAL, HIGH, MEDIUM, LOW7273→ List of security findings w/ severity, affected files, remediation. CRITICAL = injection vulns + exposed secrets.7475If err: no security-relevant code (pure docs project) → note + skip Step 4.7677### Step 4: Code Quality7879Eval maintainability, readability, defensive coding.80811. ID magic numbers + hardcoded values should be named consts822. Check consistent naming across codebase833. Find missing input validation at system boundaries844. Assess error handling — consistent? Useful messages?855. Check commented-out code, TODO/FIXME, incomplete impls866. Review test quality — testing behavior or impl details?877. Rate each: CRITICAL, HIGH, MEDIUM, LOW8889→ List of quality findings → maintainability. Common: magic numbers, inconsistent patterns, missing guards.9091If err: codebase generated/minified → note + adjust expectations. Generated code has diff quality criteria than hand-written.9293### Step 5: UX + a11y (if frontend exists)9495Eval UX + a11y compliance.96971. Check ARIA roles, labels, landmarks on interactive982. Verify keyboard nav — all interactive reachable via Tab?993. Test focus mgmt — focus moves logically when panels open/close?1004. Check responsive — test at common breakpoints (320px, 768px, 1024px)1015. Verify color contrast meets WCAG 2.1 AA1026. Check screen reader compat — dynamic content changes announced?1037. Rate each: CRITICAL, HIGH, MEDIUM, LOW104105→ List of UX/a11y findings w/ WCAG refs. No frontend → "N/A — no frontend code detected."106107If err: frontend exists but can't render (missing build step) → audit source code statically + note runtime testing not possible.108109### Step 6: Findings Synthesis110111Compile all findings → prioritized summary.1121131. Merge findings from all phases → single table1142. Sort by severity (CRITICAL first, then HIGH, MEDIUM, LOW)1153. Within each severity, group by theme (security, architecture, quality, UX)1164. Each finding: severity, phase, file(s), one-line description, suggested fix1175. Produce rec fix order considering deps between fixes1186. Summarize: total findings by severity, top 3 priorities, est effort level119120→ Findings table w/ columns: `#`, `Severity`, `Phase`, `File(s)`, `Finding`, `Fix`. Fix-order rec accounting for deps (e.g. "refactor architecture before adding tests").121122If err: no findings produced → finding itself — codebase exceptionally clean or review too shallow. Re-examine ≥1 phase deeper.123124## Check125126- [ ] All requested phases done (or explicitly skipped w/ justification)127- [ ] Every finding has severity rating (CRITICAL/HIGH/MEDIUM/LOW)128- [ ] Every finding refs ≥1 file or dir129- [ ] Findings table sorted by severity130- [ ] Fix-order recs account for deps between findings131- [ ] Summary has total counts by severity132- [ ] If `output_format` includes `report`, narrative sections accompany table133134## Scaling w/ Rest135136Between review phases, use `/rest` as checkpoint — esp between phases 2-5 needing diff analytical perspectives. Checkpoint rest (brief, transitional) prevents momentum of one phase biasing next. See `rest` "Scaling Rest" for guidance on checkpoint vs full rest.137138## Traps139140- **Boiling ocean**: Reviewing every line of large codebase produces noise. Focus high-impact: entry points, security boundaries, architectural seams.141- **Severity inflation**: Not every finding CRITICAL. Reserve CRITICAL for exploitable vulns + data-loss risks. Most architectural = MEDIUM.142- **Missing forest for trees**: Individual code quality matters less than systemic patterns. Magic numbers in 20 files = 1 architectural finding not 20 quality.143- **Skip census**: Census (Step 1) seems bureaucratic but prevents reviewing code that doesn't exist or missing entire dirs.144- **Phase bleed**: Security findings during architecture, or quality during security audit. Note for correct phase, no mix concerns — produces cleaner table.145146## →147148- `security-audit-codebase` — deep-dive when review-codebase security phase reveals complex vulns149- `review-software-architecture` — detailed architecture review for specific subsystems150- `review-ux-ui` — comprehensive UX/a11y audit beyond phase 5151- `review-pull-request` — diff-scoped review for individual changes152- `clean-codebase` — impl code quality fixes ID'd by this review153- `create-github-issues` — convert findings → tracked GH issues