Code Review Mode
Perform a comprehensive code review with structured analysis across multiple dimensions.
When to Use This Skill
- When reviewing pull requests or merge requests
- Before merging feature branches into main/trunk
- When asked to review specific files or changes
- During pair programming review sessions
- For post-implementation quality checks
Workflow
Phase 1: Context Gathering
Identify the scope:
- Determine which files/commits to review (diff, specific files, or branch comparison)
- Get the diff:
git diff for the relevant range
Understand the change:
- Review commit messages and PR description (if available)
- Check git history for related recent changes
- Identify the purpose and expected behavior of the change
Map dependencies:
- Identify what other code depends on the changed files
- Check for related test files
- Note any configuration or schema changes
Phase 2: Multi-Dimensional Review
Evaluate the code against each dimension in the Review Dimensions section below. For each dimension:
- Walk through the relevant checklist
- Note any issues with severity (Critical/High/Medium/Low)
- Record the specific location (file:line)
- Document suggested fixes
Phase 3: Synthesis
Produce a structured review following the template in references/code-review-template.md.
Determine verdict:
- APPROVE - No critical/high issues, code is ready to merge
- NEEDS WORK - Has issues that must be addressed before merge
- BLOCK - Has critical issues, security vulnerabilities, or fundamental design problems
Organize findings by severity
Acknowledge strengths - what's done well
Provide actionable fixes - not just problems, but solutions
Review Dimensions
Correctness
Security
Performance
Reliability
Maintainability
Testing
Escalation Criteria
Flag for additional human review when:
| Concern |
Escalation Trigger |
| Security |
Any auth changes, crypto usage, user data handling, or potential vulnerabilities |
| Reliability |
Changes to error handling, retry logic, or failure recovery paths |
| Performance |
Changes to hot paths, database queries, or algorithms with scale concerns |
| Architecture |
New patterns, significant structural changes, or cross-cutting concerns |
| Testing |
Reduced coverage, disabled tests, or changes to test infrastructure |
Constraints
- Review only what's in scope - don't expand to unrelated code unless it's directly affected
- Be specific - reference exact file:line locations for all findings
- Provide fixes, not just criticisms - every issue should have a suggested resolution
- Calibrate severity appropriately - not everything is critical
- Acknowledge good work - positive feedback matters too
Examples
Example: Reviewing a New API Endpoint
Scope: PR adds POST /api/users endpoint in internal/api/users.go
Phase 1 output:
Files changed:
- internal/api/users.go (new handler)
- internal/api/routes.go (route registration)
- internal/db/users.go (new repository method)
Related tests: internal/api/users_test.go (new)
Purpose: Add user creation endpoint for onboarding flow
Phase 2 findings:
| Severity |
Issue |
Location |
Fix |
| High |
SQL injection via unsanitized email |
db/users.go:45 |
Use parameterized query |
| Medium |
Missing rate limiting |
api/users.go:23 |
Add rate limiter middleware |
| Low |
Error message exposes internal details |
api/users.go:67 |
Return generic error to client |
Phase 3 verdict:
Verdict: NEEDS WORK
Critical/High Issues:
- SQL injection vulnerability must be fixed before merge
What's Done Well:
- Clean separation between handler and repository
- Comprehensive input validation struct
- Good test coverage for happy path
Action Items:
1. [High] Fix SQL injection in db/users.go:45
2. [Medium] Add rate limiting to endpoint
3. [Low] Sanitize error messages returned to client
Begin by gathering context on the target files/commits before conducting the multi-dimensional review.
1---2name: code-review3description: Comprehensive code review with security, performance, and maintainability focus. Produces structured review with APPROVE, NEEDS WORK, or BLOCK verdict.4license: MIT5compatibility:6 - runtime:any7allowed-tools:8 - Read9 - Glob10 - Grep11 - Bash(git:diff)12 - Bash(git:log)13 - Bash(git:show)14 - Bash(git:blame)15metadata:16 source: https://skillmd.com/skills/thoreinstein/code-review17 author: thoreinstein18 version: 1.0.019---2021# Code Review Mode2223Perform a comprehensive code review with structured analysis across multiple dimensions.2425## When to Use This Skill2627- When reviewing pull requests or merge requests28- Before merging feature branches into main/trunk29- When asked to review specific files or changes30- During pair programming review sessions31- For post-implementation quality checks3233## Workflow3435### Phase 1: Context Gathering36371. **Identify the scope:**38 - Determine which files/commits to review (diff, specific files, or branch comparison)39 - Get the diff: `git diff` for the relevant range40412. **Understand the change:**42 - Review commit messages and PR description (if available)43 - Check git history for related recent changes44 - Identify the purpose and expected behavior of the change45463. **Map dependencies:**47 - Identify what other code depends on the changed files48 - Check for related test files49 - Note any configuration or schema changes5051### Phase 2: Multi-Dimensional Review5253Evaluate the code against each dimension in the Review Dimensions section below. For each dimension:54551. Walk through the relevant checklist562. Note any issues with severity (Critical/High/Medium/Low)573. Record the specific location (file:line)584. Document suggested fixes5960### Phase 3: Synthesis6162Produce a structured review following the template in `references/code-review-template.md`.63641. **Determine verdict:**65 - **APPROVE** - No critical/high issues, code is ready to merge66 - **NEEDS WORK** - Has issues that must be addressed before merge67 - **BLOCK** - Has critical issues, security vulnerabilities, or fundamental design problems68692. **Organize findings** by severity703. **Acknowledge strengths** - what's done well714. **Provide actionable fixes** - not just problems, but solutions7273## Review Dimensions7475### Correctness7677- [ ] Logic is correct and handles all expected cases78- [ ] Edge cases are handled (null, empty, boundary values)79- [ ] Assumptions are documented or validated80- [ ] Error states are handled appropriately81- [ ] Types are correct and conversions are safe8283### Security8485- [ ] No injection vulnerabilities (SQL, command, XSS)86- [ ] Input is validated and sanitized87- [ ] No secrets, credentials, or keys in code88- [ ] Authentication/authorization checks are correct89- [ ] Dependencies are secure and up-to-date9091### Performance9293- [ ] No unnecessary loops or redundant operations94- [ ] Algorithms are appropriate for the data size95- [ ] Memory usage is reasonable96- [ ] No N+1 queries or unbounded fetches97- [ ] Caching is used appropriately9899### Reliability100101- [ ] Errors are caught and handled gracefully102- [ ] Failures don't leave system in bad state103- [ ] Retry logic has backoff and limits104- [ ] Resources are properly cleaned up (connections, files, etc.)105- [ ] Timeouts are set for external calls106107### Maintainability108109- [ ] Code is readable and self-documenting110- [ ] Functions/methods have single responsibility111- [ ] Naming is clear and consistent112- [ ] No unnecessary duplication113- [ ] Follows project conventions and patterns114115### Testing116117- [ ] Tests exist for new/changed behavior118- [ ] Edge cases and error paths are tested119- [ ] Tests are deterministic (not flaky)120- [ ] Test names clearly describe what they verify121- [ ] Mocks/stubs are appropriate and not excessive122123## Escalation Criteria124125Flag for additional human review when:126127| Concern | Escalation Trigger |128| ---------------- | -------------------------------------------------------------------------------- |129| **Security** | Any auth changes, crypto usage, user data handling, or potential vulnerabilities |130| **Reliability** | Changes to error handling, retry logic, or failure recovery paths |131| **Performance** | Changes to hot paths, database queries, or algorithms with scale concerns |132| **Architecture** | New patterns, significant structural changes, or cross-cutting concerns |133| **Testing** | Reduced coverage, disabled tests, or changes to test infrastructure |134135## Constraints136137- **Review only what's in scope** - don't expand to unrelated code unless it's directly affected138- **Be specific** - reference exact file:line locations for all findings139- **Provide fixes, not just criticisms** - every issue should have a suggested resolution140- **Calibrate severity appropriately** - not everything is critical141- **Acknowledge good work** - positive feedback matters too142143## Examples144145### Example: Reviewing a New API Endpoint146147**Scope:** PR adds `POST /api/users` endpoint in `internal/api/users.go`148149**Phase 1 output:**150```151Files changed:152- internal/api/users.go (new handler)153- internal/api/routes.go (route registration)154- internal/db/users.go (new repository method)155156Related tests: internal/api/users_test.go (new)157Purpose: Add user creation endpoint for onboarding flow158```159160**Phase 2 findings:**161162| Severity | Issue | Location | Fix |163| -------- | -------------------------------------- | --------------- | ------------------------------ |164| High | SQL injection via unsanitized email | db/users.go:45 | Use parameterized query |165| Medium | Missing rate limiting | api/users.go:23 | Add rate limiter middleware |166| Low | Error message exposes internal details | api/users.go:67 | Return generic error to client |167168**Phase 3 verdict:**169```170Verdict: NEEDS WORK171172Critical/High Issues:173- SQL injection vulnerability must be fixed before merge174175What's Done Well:176- Clean separation between handler and repository177- Comprehensive input validation struct178- Good test coverage for happy path179180Action Items:1811. [High] Fix SQL injection in db/users.go:451822. [Medium] Add rate limiting to endpoint1833. [Low] Sanitize error messages returned to client184```185186---187188Begin by gathering context on the target files/commits before conducting the multi-dimensional review.