Reviews current git changes with a senior engineer lens. Detects SOLID violations, YAGNI/DRY/KISS breaches, security risks, performance issues, and proposes actionable improvements. Use when reviewing pull requests, checking code quality before merging, or auditing changes for security vulnerabilities.
Reviews current git changes with a senior engineer lens. Detects SOLID violations, YAGNI/DRY/KISS breaches, security risks, performance issues, and proposes actionable improvements. Use when reviewing pull requests, checking code quality before merging, or auditing changes for security vulnerabilities.
license
MIT
Review Code
Review current git changes with focus on SOLID, engineering best practices (YAGNI, DRY, KISS), architecture, removal candidates, and security risks. Default to review-only output unless the user asks to implement changes.
Severity Levels
Level
Name
Description
Action
P0
Critical
Security vulnerability, data loss risk, correctness bug
Code smell, maintainability concern, minor SOLID violation
Fix in this PR or create follow-up
P3
Low
Style, naming, minor suggestion
Optional improvement
Verdict mapping: Any P0 or P1 finding = REQUEST_CHANGES. P2 findings only = COMMENT. No findings = APPROVE.
Workflow
1) Preflight context
Run git status -sb, git diff --stat, and to scope changes.
**Small diff, clean review (no issues)**
**Medium diff with mixed severity findings**
**Large diff (>400 lines), batched review**
**Review reasoning: tracing a race condition through control flow**
git diff
Use Grep to find related modules, usages, and contracts when the diff touches shared interfaces or exports.
Identify entry points, ownership boundaries, and critical paths (auth, payments, data writes, network).
Review approach — review the code, not the diff. Follow control flow via goto definition rather than reading in textual diff order. Understand the change in context of the surrounding system, not as an isolated patch.
Edge cases:
No changes: If git diff is empty, ask the user whether to review staged changes (git diff --cached) or a specific commit range.
Large diff (>400 lines): Summarise by file first, then review in batches by module/feature area. Research shows review effectiveness peaks at 200-400 lines and drops sharply beyond that threshold.
Mixed concerns: Group findings by logical feature, not by file order.
2) SOLID + architecture smells
Load references/solid-checklist.md for specific prompts.
Check for:
SRP: Overloaded modules with unrelated responsibilities.
OCP: Frequent edits to add behaviour instead of extension points.
LSP: Subclasses that break expectations or require type checks.
ISP: Wide interfaces with unused methods.
DIP: High-level logic tied to low-level implementations.
When proposing a refactor, explain why it improves cohesion/coupling and outline a minimal, safe split.
If the refactor is non-trivial, propose an incremental plan instead of a large rewrite.
3) Engineering best practices
Load references/best-practices-checklist.md for specific prompts.
DRY: duplicated logic across files (but tolerate small local repetition over premature abstraction).
KISS: over-engineered solutions, unnecessary indirection layers, complex patterns where a simple approach works.
Law of Demeter: long method chains reaching through multiple objects (a.b.c.d()).
Composition over inheritance: deep inheritance trees, base classes used purely for code sharing.
Premature optimisation: complex caching, pooling, or micro-optimisation without profiling evidence.
Fail fast: silent error swallowing, fallback values that mask bugs, late detection of invalid state.
Principle of Least Surprise: methods with misleading names, unexpected side effects, non-obvious return values.
AI-generated code patterns: higher redundancy (duplicated logic, lower code reuse), missing refactoring after initial pass, code that passes tests but lacks structural quality. Apply extra DRY and KISS scrutiny to code produced by AI agents.
Grade YAGNI and KISS violations at P2 minimum. Speculative code that adds maintenance burden without current value is a real cost.
4) Removal candidates + iteration plan
Load references/removal-plan.md for template.
Identify removal candidates:
Run Grep for functions, classes, and exports added or touched in the diff. Check each has at least one caller outside its own file.
Search for feature flags in the diff. If a flag is permanently off or has no toggle path, the gated code is a removal candidate.
Check for commented-out code blocks and TODO markers older than the current PR.
Distinguish safe delete now (zero references, no external consumers) vs defer with plan (active callers need migration).
Provide a follow-up plan with concrete steps and checkpoints (tests/metrics).
5) Security and reliability scan
Load references/security-checklist.md for coverage.
Flag issues that may cause silent failures or production incidents.
7) Output format
Structure the review as follows:
## Code Review Summary**Files reviewed**: X files, Y lines changed
**Overall assessment**: [APPROVE / REQUEST_CHANGES / COMMENT]
---
## Findings
### P0 - Critical
(none or list)
### P1 - High
- **[file:line]** Brief title
- Description of issue
- Suggested fix
### P2 - Medium
...
### P3 - Low
...
---
## Removal/Iteration Plan
(if applicable)
## Additional Suggestions
(optional improvements, not blocking)
Inline comments: When providing file-specific findings outside the summary table, use this format:
[P1] path/to/file.ts:42 -- Description of the issue and suggested fix.
Clean review: If no issues found, state:
What was checked
Any areas not covered (e.g., "Did not verify database migrations")
Residual risks or recommended follow-up tests
8) Next steps confirmation
After presenting findings, ask user how to proceed:
---
## Next Steps
I found X issues (P0: _, P1: _, P2: _, P3: _).
**How would you like to proceed?**1.**Fix all** - I'll implement all suggested fixes
2.**Fix P0/P1 only** - Address critical and high priority issues
3.**Fix specific items** - Tell me which issues to fix
4.**No changes** - Review complete, no implementation needed
Do NOT implement changes until the user confirms. This is a review-first workflow.
Gap: Between lines 34 and 38, no lock or transaction. Two concurrent requests can both read the same balance, both pass the check, and both deduct -- overdrawing the account.
This is a check-then-act (TOCTOU) race condition. Graded P0 because it affects financial data integrity. The fix is to wrap the read and write in a database transaction with SELECT ... FOR UPDATE, or use an atomic update: UPDATE accounts SET balance = balance - ? WHERE id = ? AND balance >= ?.
This example shows the review approach: trace data flow from entry point through state mutation, check for atomicity gaps, then grade by impact.
Resources
references/
File
Purpose
solid-checklist.md
SOLID smell prompts and refactor heuristics
security-checklist.md
Web/app security and runtime risk checklist
code-quality-checklist.md
Error handling, performance, boundary conditions
best-practices-checklist.md
YAGNI, DRY, KISS, Law of Demeter, composition, fail fast
removal-plan.md
Template for deletion candidates and follow-up plan