Skip to content
code-review-patterns logo

Code Review Patterns

code-review-patterns

Internal skill. Use cc10x-router for all development tasks.

SKILL.md

Full skill instructions

Code Review Patterns

Overview

Code reviews catch bugs before they ship. But reviewing code quality before functionality is backwards.

Core principle: First verify it works, THEN verify it's good.

Violating the letter of this process is violating the spirit of review.

The Iron Law

NO CODE QUALITY REVIEW BEFORE SPEC COMPLIANCE

If you haven't verified the code meets requirements, you cannot review code quality.

Two-Stage Review Process

Stage 1: Spec Compliance Review

Does it do what was asked?

  1. Read the Requirements

    • What was requested?
    • What are the acceptance criteria?
    • What are the edge cases?
  2. Trace the Implementation

    • Does the code implement each requirement?
    • Are all edge cases handled?
    • Does it match the spec exactly?
  3. Test Functionality

    • Run the tests
    • Manual test if needed
    • Verify outputs match expectations

Gate: Only proceed to Stage 2 if Stage 1 passes.

Stage 2: Code Quality Review

Is it well-written?

Review in priority order:

  1. Security - Vulnerabilities that could be exploited
  2. Correctness - Logic errors, edge cases missed
  3. Performance - Unnecessary slowness
  4. Maintainability - Hard to understand or modify
  5. UX - User experience issues (if UI involved)
  6. Accessibility - A11y issues (if UI involved)

Security Review Checklist

CheckLooking ForExample Vulnerability
Input validationUnvalidated user inputSQL injection, XSS
AuthenticationMissing auth checksUnauthorized access
AuthorizationMissing permission checksPrivilege escalation
SecretsHardcoded credentialsAPI key exposure
SQL queriesString concatenationSQL injection
Output encodingUnescaped outputXSS attacks
CSRFMissing tokensCross-site request forgery
File handlingPath traversalReading arbitrary files

For each security issue found:

- [CRITICAL] SQL injection at `src/​api/​users.ts:45`
  - Problem: User input concatenated into query
  - Fix: Use parameterized query
  - Code: `db.query(\`SELECT * FROM users WHERE id = ?\`, [userId])`

Quality Review Checklist

CheckGoodBad
NamingcalculateTotalPrice()calc(), doStuff()
FunctionsDoes one thingMultiple responsibilities
ComplexityLinear flowNested conditions
DuplicationDRY where sensibleCopy-paste code
Error handlingGraceful failuresSilent failures
TestabilityInjectable dependenciesGlobal state

Performance Review Checklist

PatternProblemFix
N+1 queriesLoop with DB callBatch query
Unnecessary loopsIterating full listEarly return
Missing cacheRepeated expensive opsAdd caching
Memory leaksObjects never cleanedCleanup on dispose
Sync blockingBlocking main threadAsync operation

UX Review Checklist (UI Code)

CheckVerify
Loading statesShows loading indicator
Error statesShows helpful error message
Empty statesShows appropriate empty message
Success feedbackConfirms action completed
Form validationShows inline errors
ResponsiveWorks on mobile/​tablet

Accessibility Review Checklist (UI Code)

CheckVerify
Semantic HTMLUses correct elements (button, not div)
Alt textImages have meaningful alt text
KeyboardAll interactions keyboard accessible
FocusFocus visible and logical order
Color contrastMeets WCAG AA (4.5:1 text)
Screen readerLabels and ARIA where needed

Severity Classification

SeverityDefinitionAction
CRITICALSecurity vulnerability or blocks functionalityMust fix before merge
MAJORAffects functionality or significant quality issueShould fix before merge
MINORStyle issues, small improvementsCan merge, fix later
NITPurely stylistic preferencesOptional

Red Flags - STOP and Re-review

If you find yourself:

  • Reviewing code style before checking functionality
  • Not running the tests
  • Skipping the security checklist
  • Giving generic feedback ("looks good")
  • Not providing file:line citations
  • Not explaining WHY something is wrong
  • Not providing fix recommendations

STOP. Start over with Stage 1.

Rationalization Prevention

ExcuseReality
"Tests pass so it's fine"Tests can miss requirements. Check spec compliance.
"Code looks clean"Clean code can still be wrong. Verify functionality.
"I trust this developer"Trust but verify. Everyone makes mistakes.
"It's a small change"Small changes cause big bugs. Review thoroughly.
"No time for full review"Bugs take more time than reviews. Do it properly.
"Security is overkill"One vulnerability can sink the company. Check it.

Output Format

## Code Review: [PR Title/​Component]

### Stage 1: Spec Compliance ✅/❌

**Requirements:**
- [x] Requirement 1 - implemented at `file:line`
- [x] Requirement 2 - implemented at `file:line`
- [ ] Requirement 3 - NOT IMPLEMENTED

**Tests:** PASS (24/​24)

**Verdict:** [Meets spec / Missing requirements]

---

### Stage 2: Code Quality

**Security:**
- [CRITICAL] Issue at `file:line` - Fix: [recommendation]
- No issues found ✅

**Performance:**
- [MAJOR] N+1 query at `file:line` - Fix: Use batch query
- No issues found ✅

**Quality:**
- [MINOR] Unclear naming at `file:line` - Suggestion: rename to X
- No issues found ✅

**UX/​A11y:** (if UI code)
- [MAJOR] Missing loading state - Fix: Add spinner
- No issues found ✅

---

### Summary

**Decision:** Approve / Request Changes

**Critical:** [count]
**Major:** [count]
**Minor:** [count]

**Required fixes before merge:**
1. [Most important fix]
2. [Second fix]

Review Loop Protocol

After requesting changes:

  1. Wait for fixes - Developer addresses issues
  2. Re-review - Check that fixes actually fix the issues
  3. Verify no regressions - Run tests again
  4. Approve or request more changes - Repeat if needed

Never approve without verifying fixes work.

Final Check

Before approving:

  • Stage 1 complete (spec compliance verified)
  • Stage 2 complete (all checklists reviewed)
  • All critical/​major issues addressed
  • Tests pass
  • No regressions introduced
  • Evidence captured for each claim

More Security skills

supabase logo
Security

supabase

Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...

2.7K 308.9K
View

Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.

98 216.2K
View

Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.

462 163.8K
View

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

462 127.7K
View

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

462 125.1K
View

Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.

222 118.2K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View
cloudflare logo
Security

cloudflare

Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.

3K 110.7K
View

Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.

253 103K
View
gws-gmail logo
Security

gws-gmail

Send, read, and manage Gmail messages, drafts, labels, and account settings.

31.2K 78.9K
View

Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.

94 72.3K
View
gws-shared logo
Security

gws-shared

Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.

31.2K 63.4K
View

Security AI tools

StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
GeoSpy logo
Security

GeoSpy

GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams

Free
View

Detect AI-generated voices to protect against audio fraud.

Paid
View

Ensure Your Content's Originality with AI Plagiarism Checker

Freemium
View
Img Upscaler logo
Security

Img Upscaler

Upscale images by 400% without quality loss

Freemium
View
AICheatCheck logo
Security

AICheatCheck

Accurately Detect AI-Generated Content with TheChecker.AI

Free
View
D
Security

Detect GPT

Chrome extension that detects and flags AI-generated content

Free
View