Code Review
Step 0 — Scope Selection
Before anything else, ask the user the following question and wait for their answer:
What would you like to review?
- Uncommitted changes — files modified but not yet staged or committed (
git diff HEAD)
- Staged changes only — files added to the index but not yet committed (
git diff --cached)
- Current branch vs base branch — all commits introduced by this branch compared to its merge base (e.g.
git diff main...HEAD)
- A specific commit — changes introduced by a single commit (provide the commit hash)
- A commit range — changes across a range of commits (provide
<from>..<to>)
Type the number of your choice. For options 4 or 5, also provide the commit hash or range.
Once the user answers, run the appropriate git command to obtain the diff, then proceed with the review below.
| Choice |
Command to run |
| 1 |
git diff HEAD |
| 2 |
git diff --cached |
| 3 |
Ask: "What is the base branch? (e.g. main, develop)" — then run git diff $(git merge-base HEAD <base-branch>)...HEAD |
| 4 |
git show <commit-hash> |
| 5 |
git diff <from>..<to> |
Findings should be reported with severity levels:
- Critical: blocks the merge; must be fixed before merging
- Warning: should be fixed shortly after merging; not a blocker
- Suggestion: optional improvement; does not block merge
Step 1 — Codebase Investigation
Before reviewing anything, identify the project's stack by inspecting the following files (read only what exists):
package.json → identifies JS/TS frameworks, bundlers, and tools
composer.json → identifies PHP frameworks (Laravel, Symfony, etc.)
pyproject.toml / requirements.txt / setup.py → Python
go.mod → Go
*.csproj / global.json → .NET / C#
pom.xml / build.gradle → Java / Spring Boot
pubspec.yaml → Flutter / Dart
vite.config.* / webpack.config.* → bundler and frontend stack
tailwind.config.* → Tailwind CSS
tsconfig.json → TypeScript
Dockerfile / docker-compose.yml → Docker
*.tf → Terraform / IaC
- Top-level directory structure → architecture pattern signals (DDD, Clean Architecture, etc.)
Based on what you find, load and apply only the stack and pattern files that match this project. Do not evaluate or report on technologies not present.
API Validation: Before flagging a misuse of a library API, validate the syntax and best practice against live docs using mcp__plugin_context7_context7__query-docs for the version detected in package.json or composer.json. Avoids false positives from outdated training data.
Stack files to load if relevant:
Read these files using the path relative to this skill file's directory. If a file cannot be read, continue with the generic rules above.
./stacks/laravel.md
./stacks/vue.md
./stacks/nuxt.md
./stacks/react.md
./stacks/angular.md
./stacks/svelte.md
./stacks/typescript.md
./stacks/tailwind.md
./stacks/node.md
./stacks/python.md
./stacks/go.md
./stacks/java-spring.md
./stacks/dotnet.md
./stacks/react-native.md
./stacks/flutter.md
./stacks/docker.md
./stacks/terraform.md
./stacks/kafka.md
./stacks/inertia.md
./stacks/pest.md
Pattern files to load if relevant:
Read these files using the path relative to this skill file's directory. If a file cannot be read, continue with the generic rules above.
./patterns/clean-architecture.md
./patterns/ddd.md
./patterns/event-driven.md
./patterns/microservices.md
./patterns/cqrs.md
Step 1.5 — Consistency Check
Before flagging any pattern violation, check what the codebase already does. Laravel, Vue, and similar frameworks offer multiple valid approaches — the best choice is the one already established in the project, even if another would be theoretically better. Inconsistency is worse than a suboptimal pattern.
- Check sibling controllers, services, components, or tests for established conventions
- If the project already uses a non-standard pattern consistently, follow it — report it as a Suggestion at most, not a blocker
- These checklist rules are defaults for when no pattern exists yet, not overrides of working conventions
1. Security
- Injection vulnerabilities: SQL injection, command injection, XSS, LDAP injection
- Authentication & Authorization: proper access control checks, no hardcoded credentials, no exposed secrets
- Input validation & sanitization: all user inputs validated at system boundaries
- Sensitive data exposure: no secrets, tokens, or PII in logs, responses, or source code
- CSRF protection: state-changing operations protected against cross-site request forgery
- Dependency vulnerabilities: no known CVEs in added/updated dependencies
- File upload handling: proper validation of file types, sizes, and storage paths
- Rate limiting & abuse prevention: endpoints exposed to the public have appropriate limits
- Secure defaults: encryption, HTTPS, secure cookies, proper CORS configuration
- Mass assignment protection: objects not blindly accepting all user input fields
2. Performance
- N+1 queries: data access patterns avoid unnecessary repeated queries
- Indexing: new queries have proper database indexes to support them
- Caching: appropriate use of caching for expensive or repeated operations
- Pagination: large datasets are paginated, not loaded entirely into memory
- Lazy loading vs eager loading: relationships loaded efficiently for the use case
- Unnecessary computation: no redundant loops, recalculations, or re-renders
- Memory leaks: no event listeners, subscriptions, or references left dangling
- Bundle size: no unnecessarily large dependencies added for small functionality
- Database transactions: long-running transactions avoided; transactions scoped minimally
- Async operations: I/O-bound work uses async patterns where available
3. Tests & Coverage
- New code has tests: all new public methods/endpoints have corresponding tests
- Edge cases covered: null values, empty collections, boundary conditions, error states
- Happy path and sad path: both success and failure scenarios tested
- Test isolation: tests don't depend on each other or on external state
- Mocking: external services and I/O properly mocked; no real API calls in unit tests
- Assertions are meaningful: tests assert behavior, not implementation details
- Coverage: no significant drop in test coverage percentage
- Regression tests: if fixing a bug, a test exists that would have caught it
4. Architecture & Design Principles
SOLID
- Single Responsibility: each class/module/function does one thing well
- Open/Closed: code is extendable without modifying existing behavior
- Liskov Substitution: subtypes can replace their base types without breaking behavior
- Interface Segregation: interfaces are small and focused, not bloated
- Dependency Inversion: high-level modules depend on abstractions, not concrete implementations
DRY (Don't Repeat Yourself)
- No duplicated logic across files or methods — extract shared behavior when duplication introduces a risk of inconsistency
KISS (Keep It Simple, Stupid)
- Solution uses the simplest approach that works; no over-engineering
- No premature abstractions or unnecessary design patterns
General
- Separation of concerns: business logic, data access, and presentation are clearly separated
- Naming conventions: variables, functions, and classes have clear, descriptive names
- Error handling: errors are handled gracefully with meaningful messages; no silent catches
- Code readability: code is self-documenting; complex logic has brief explanatory comments
- No dead code: unused imports, variables, functions, or commented-out blocks are removed
- Consistent patterns: new code follows the patterns already established in the codebase
- Immutability: prefer immutable data structures where appropriate; avoid mutating shared state
- Pure functions: side effects isolated and explicit; core logic written as pure functions where possible
Code & File Size
- Method/function length: methods exceeding 30 lines should be justified; methods exceeding 50 lines require refactoring — they are doing too much (Clean Code / Rule of 30)
- Class length: classes exceeding 200 lines should be reviewed for single-responsibility violations; classes exceeding 500 lines require decomposition
- File length: source files exceeding 300 lines are a signal of multiple responsibilities; files exceeding 500 lines should be investigated and split
- Component length (Vue/React): SFCs or components exceeding 300 total lines should be decomposed;
<template> and <script> blocks each kept under 150 lines where possible
- Binary files in git: images, PDFs, videos, database dumps, and compiled binaries not committed to the repository;
.gitignore covers them; Git LFS used for large assets that must be versioned
- File reading at runtime: files read from disk using streaming (not loaded entirely into memory) when the file size is not bounded and could be large
5. Potential Bug Investigation
Actively trace the modified code looking for latent bugs — do not just check style or structure. For each item below, reason through the changed code paths and report anything that could produce incorrect behavior, data corruption, or a runtime failure.
- Null / undefined / zero dereference: identify paths where a variable could be
null, undefined, 0, or an empty collection at the point it is used without a guard
- Off-by-one errors: check loop bounds, slice indices, pagination offsets, and comparisons using
< vs <=
- Inverted or incomplete conditions: logic conditions that appear reversed (
!== where === was intended), missing else branches, or switch cases without a default
- Implicit assumptions about state: code that assumes a record exists, a list is non-empty, a value has already been set, or a previous step has succeeded — without verifying
- Broken contracts with dependents: changes to a method signature, return shape, event payload, or database column that are not reflected in all callers, consumers, or downstream modules
- Race conditions in async flows: multiple async operations that share state and could interleave in a way that produces inconsistent results
- Data mutation side effects: functions that mutate their input arguments, shared collections, or global state in ways that callers do not expect
- Query / migration data hazards: SQL changes that could silently drop data, produce incorrect results on existing rows, or behave differently on empty vs non-empty tables
- Error paths that silently succeed: catch blocks that swallow exceptions and return a success response; missing re-throws; errors logged but not propagated
- Type coercion surprises: implicit type coercions (PHP loose comparisons, JavaScript
==, string-to-number) that could produce wrong results at the boundary of the changed code
- Unreachable or dead logic: conditions that can never be true given the surrounding context; code after an unconditional
return; branches that contradict earlier guards
6. Accessibility (only if the diff includes frontend/UI changes)
- Semantic HTML: correct use of headings, landmarks, lists, buttons, and form elements
- ARIA attributes:
aria-label, aria-describedby, role, etc. used correctly and only when native semantics are insufficient
- Keyboard navigation: all interactive elements reachable and operable via keyboard
- Focus management: focus order is logical; focus traps used appropriately in modals/dialogs
- Color contrast: text and UI elements meet WCAG AA contrast ratios
- Images & icons: meaningful images have
alt text; decorative images use alt=""
- Form labels: all inputs have associated
<label> or aria-label
7. Observability
- Structured logging: logs use a structured format (JSON or key=value); no
console.log / var_dump left in production code
- Sensitive data in logs: no passwords, tokens, PII, or secrets logged — even partially
- Log levels: appropriate log levels used (
debug, info, warning, error); no critical events logged at debug
- Correlation IDs: requests and async jobs carry a trace/correlation ID through logs
- Error reporting: exceptions are captured and forwarded to the error tracking system (e.g. Sentry, Bugsnag)
- Metrics: significant new operations (queue jobs, external calls, cache hits) are instrumented where relevant
8. API Design (only if the diff includes API endpoints or API client code)
- HTTP methods: correct verbs used (
GET for reads, POST for creation, PUT/PATCH for updates, DELETE for removal)
- Status codes: correct HTTP status codes returned (
201 for creation, 204 for no content, 422 for validation errors, 404 for not found, etc.)
- Versioning: API version is reflected in the URL or header; breaking changes bump the version
- Consistent error responses: error payloads follow a uniform structure across all endpoints
- Pagination: consistent strategy used (cursor or offset); metadata included in response
- Filtering & sorting: query parameters follow established conventions
- Idempotency:
PUT/PATCH/DELETE operations are idempotent; POST operations are idempotent where appropriate (e.g. with idempotency keys)
- No sensitive data in URLs: tokens, passwords, and PII passed in headers or body, not in query strings or paths
- GraphQL (only if project uses GraphQL): N+1 prevented with DataLoader, query depth limited, introspection disabled in production, mutations validate input
9. Resilience & Fault Tolerance (only if the diff involves external calls, queues, or critical flows)
- Timeouts: all outbound HTTP calls, database queries, and queue operations have explicit timeouts
- Retry with backoff: transient failures retried with exponential backoff and jitter; non-retriable errors not retried
- Circuit breakers: repeated failures to an external dependency trip a circuit breaker to prevent cascade
- Graceful degradation: the system degrades gracefully when a non-critical dependency is unavailable
- Idempotency: operations that may be retried are idempotent (safe to execute more than once)
- Bulkhead isolation: slow or failing dependencies do not exhaust shared resources (thread pools, connections)
10. Zero-Downtime Database Migrations (only if the diff includes migrations)
- Additive changes first: new columns added as nullable or with a default before application code uses them
- No instant NOT NULL without default: adding a NOT NULL column without a default on a large table causes a full table lock
- Column/table rename safety: old column kept alongside new one during a transition period; renamed in a follow-up migration after code is deployed
- Column removal safety: column removed only after code no longer references it and the deployment is stable
- Index creation: indexes on large tables created concurrently (e.g.
CREATE INDEX CONCURRENTLY) to avoid locking
- Reversibility:
down method correctly undoes the up method without data loss
11. Concurrency & Thread Safety (only if the diff involves shared state, background jobs, or concurrent operations)
- Race conditions: operations on shared state are atomic or properly synchronized
- Locks & mutexes: locking strategy is correct; no deadlock potential (consistent lock ordering)
- Atomic operations: counters and flags updated atomically (e.g. database atomic increments, compare-and-swap)
- Job uniqueness: background jobs that must not run concurrently are protected by a unique lock
- Shared mutable state: global or static mutable state avoided; dependencies injected rather than shared
12. Internationalization (i18n) (only if the project supports multiple languages or locales)
- No hardcoded strings: all user-facing text uses translation keys, not inline strings
- Date & time formatting: dates, times, and durations formatted via locale-aware utilities, not manual string building
- Number & currency formatting: numbers and currency amounts formatted according to the user's locale
- Pluralization: plural forms handled correctly via i18n library, not with manual conditionals
- RTL support: layout does not break for right-to-left languages if RTL is supported
- Locale in URLs or headers: locale derived from user preference or
Accept-Language, not hardcoded
13. Privacy & Data Compliance (only if the diff involves user data, PII, or data storage)
- Minimal data collection: only data strictly necessary for the feature is collected and stored
- PII handling: personal data identified, encrypted at rest where required, and access-controlled
- Data retention: data is deleted or anonymized according to defined retention policies
- Consent: data collection requiring user consent is gated behind explicit opt-in
- Audit trail: access to and modification of sensitive data is logged for audit purposes
- Third-party data sharing: data shared with external services is documented and limited to what is necessary
14. What Was Done Well
Before listing issues, acknowledge what was done well in this change. Point out strong design decisions, good test coverage, clean abstractions, or anything that should be recognized and repeated.
15. Output Format
For each finding, report:
### [Category] — [Severity]
**File:** `path/to/file.ext:line`
**Issue:** Brief description of the problem.
**Fix:** Suggested correction or approach.
At the end, provide a summary table covering all evaluated categories (use N/A for categories that do not apply to this change):
## Summary
| Category | Critical | Warning | Suggestion | N/A |
|-----------------------|----------|---------|------------|-----|
| Security | 0 | 0 | 0 | |
| Performance | 0 | 0 | 0 | |
| Tests/Coverage | 0 | 0 | 0 | |
| Architecture | 0 | 0 | 0 | |
| Code & File Size | 0 | 0 | 0 | |
| Potential Bugs | 0 | 0 | 0 | |
| Accessibility | 0 | 0 | 0 | |
| Observability | 0 | 0 | 0 | |
| API Design | 0 | 0 | 0 | |
| Resilience | 0 | 0 | 0 | |
| DB Migrations | 0 | 0 | 0 | |
| Concurrency | 0 | 0 | 0 | |
| i18n | 0 | 0 | 0 | |
| Privacy/Compliance | 0 | 0 | 0 | |
| Architecture Patterns | 0 | 0 | 0 | |
| Stack-Specific | 0 | 0 | 0 | |
| **Total** | **0** | **0** | **0** | |
If no issues are found, state: "Code review passed — no issues found."
1---2name: code-review3description: Performs a structured, comprehensive code review of git changes. Detects stack and architecture automatically, applies relevant stack/pattern-specific rules, and reports findings by severity. Use when: user runs /code-review, /review-pr, or asks to "review my changes".4---56# Code Review78## Step 0 — Scope Selection910Before anything else, ask the user the following question and wait for their answer:1112---1314**What would you like to review?**15161. **Uncommitted changes** — files modified but not yet staged or committed (`git diff HEAD`)172. **Staged changes only** — files added to the index but not yet committed (`git diff --cached`)183. **Current branch vs base branch** — all commits introduced by this branch compared to its merge base (e.g. `git diff main...HEAD`)194. **A specific commit** — changes introduced by a single commit (provide the commit hash)205. **A commit range** — changes across a range of commits (provide `<from>..<to>`)2122*Type the number of your choice. For options 4 or 5, also provide the commit hash or range.*2324---2526Once the user answers, run the appropriate git command to obtain the diff, then proceed with the review below.2728| Choice | Command to run |29|--------|---------------|30| 1 | `git diff HEAD` |31| 2 | `git diff --cached` |32| 3 | Ask: *"What is the base branch? (e.g. main, develop)"* — then run `git diff $(git merge-base HEAD <base-branch>)...HEAD` |33| 4 | `git show <commit-hash>` |34| 5 | `git diff <from>..<to>` |3536---3738Findings should be reported with severity levels:3940- **Critical**: blocks the merge; must be fixed before merging41- **Warning**: should be fixed shortly after merging; not a blocker42- **Suggestion**: optional improvement; does not block merge4344---4546## Step 1 — Codebase Investigation4748Before reviewing anything, identify the project's stack by inspecting the following files (read only what exists):4950- `package.json` → identifies JS/TS frameworks, bundlers, and tools51- `composer.json` → identifies PHP frameworks (Laravel, Symfony, etc.)52- `pyproject.toml` / `requirements.txt` / `setup.py` → Python53- `go.mod` → Go54- `*.csproj` / `global.json` → .NET / C#55- `pom.xml` / `build.gradle` → Java / Spring Boot56- `pubspec.yaml` → Flutter / Dart57- `vite.config.*` / `webpack.config.*` → bundler and frontend stack58- `tailwind.config.*` → Tailwind CSS59- `tsconfig.json` → TypeScript60- `Dockerfile` / `docker-compose.yml` → Docker61- `*.tf` → Terraform / IaC62- Top-level directory structure → architecture pattern signals (DDD, Clean Architecture, etc.)6364Based on what you find, load and apply **only** the stack and pattern files that match this project. Do not evaluate or report on technologies not present.6566> **API Validation:** Before flagging a misuse of a library API, validate the syntax and best practice against live docs using `mcp__plugin_context7_context7__query-docs` for the version detected in `package.json` or `composer.json`. Avoids false positives from outdated training data.6768**Stack files to load if relevant:**6970Read these files using the path relative to this skill file's directory. If a file cannot be read, continue with the generic rules above.7172- `./stacks/laravel.md`73- `./stacks/vue.md`74- `./stacks/nuxt.md`75- `./stacks/react.md`76- `./stacks/angular.md`77- `./stacks/svelte.md`78- `./stacks/typescript.md`79- `./stacks/tailwind.md`80- `./stacks/node.md`81- `./stacks/python.md`82- `./stacks/go.md`83- `./stacks/java-spring.md`84- `./stacks/dotnet.md`85- `./stacks/react-native.md`86- `./stacks/flutter.md`87- `./stacks/docker.md`88- `./stacks/terraform.md`89- `./stacks/kafka.md`90- `./stacks/inertia.md`91- `./stacks/pest.md`9293**Pattern files to load if relevant:**9495Read these files using the path relative to this skill file's directory. If a file cannot be read, continue with the generic rules above.9697- `./patterns/clean-architecture.md`98- `./patterns/ddd.md`99- `./patterns/event-driven.md`100- `./patterns/microservices.md`101- `./patterns/cqrs.md`102103---104105## Step 1.5 — Consistency Check106107Before flagging any pattern violation, check what the codebase already does. Laravel, Vue, and similar frameworks offer multiple valid approaches — the best choice is the one already established in the project, even if another would be theoretically better. **Inconsistency is worse than a suboptimal pattern.**108109- Check sibling controllers, services, components, or tests for established conventions110- If the project already uses a non-standard pattern consistently, follow it — report it as a **Suggestion** at most, not a blocker111- These checklist rules are defaults for when no pattern exists yet, not overrides of working conventions112113---114115## 1. Security116117- **Injection vulnerabilities**: SQL injection, command injection, XSS, LDAP injection118- **Authentication & Authorization**: proper access control checks, no hardcoded credentials, no exposed secrets119- **Input validation & sanitization**: all user inputs validated at system boundaries120- **Sensitive data exposure**: no secrets, tokens, or PII in logs, responses, or source code121- **CSRF protection**: state-changing operations protected against cross-site request forgery122- **Dependency vulnerabilities**: no known CVEs in added/updated dependencies123- **File upload handling**: proper validation of file types, sizes, and storage paths124- **Rate limiting & abuse prevention**: endpoints exposed to the public have appropriate limits125- **Secure defaults**: encryption, HTTPS, secure cookies, proper CORS configuration126- **Mass assignment protection**: objects not blindly accepting all user input fields127128---129130## 2. Performance131132- **N+1 queries**: data access patterns avoid unnecessary repeated queries133- **Indexing**: new queries have proper database indexes to support them134- **Caching**: appropriate use of caching for expensive or repeated operations135- **Pagination**: large datasets are paginated, not loaded entirely into memory136- **Lazy loading vs eager loading**: relationships loaded efficiently for the use case137- **Unnecessary computation**: no redundant loops, recalculations, or re-renders138- **Memory leaks**: no event listeners, subscriptions, or references left dangling139- **Bundle size**: no unnecessarily large dependencies added for small functionality140- **Database transactions**: long-running transactions avoided; transactions scoped minimally141- **Async operations**: I/O-bound work uses async patterns where available142143---144145## 3. Tests & Coverage146147- **New code has tests**: all new public methods/endpoints have corresponding tests148- **Edge cases covered**: null values, empty collections, boundary conditions, error states149- **Happy path and sad path**: both success and failure scenarios tested150- **Test isolation**: tests don't depend on each other or on external state151- **Mocking**: external services and I/O properly mocked; no real API calls in unit tests152- **Assertions are meaningful**: tests assert behavior, not implementation details153- **Coverage**: no significant drop in test coverage percentage154- **Regression tests**: if fixing a bug, a test exists that would have caught it155156---157158## 4. Architecture & Design Principles159160### SOLID161- **Single Responsibility**: each class/module/function does one thing well162- **Open/Closed**: code is extendable without modifying existing behavior163- **Liskov Substitution**: subtypes can replace their base types without breaking behavior164- **Interface Segregation**: interfaces are small and focused, not bloated165- **Dependency Inversion**: high-level modules depend on abstractions, not concrete implementations166167### DRY (Don't Repeat Yourself)168- No duplicated logic across files or methods — extract shared behavior when duplication introduces a risk of inconsistency169170### KISS (Keep It Simple, Stupid)171- Solution uses the simplest approach that works; no over-engineering172- No premature abstractions or unnecessary design patterns173174### General175- **Separation of concerns**: business logic, data access, and presentation are clearly separated176- **Naming conventions**: variables, functions, and classes have clear, descriptive names177- **Error handling**: errors are handled gracefully with meaningful messages; no silent catches178- **Code readability**: code is self-documenting; complex logic has brief explanatory comments179- **No dead code**: unused imports, variables, functions, or commented-out blocks are removed180- **Consistent patterns**: new code follows the patterns already established in the codebase181- **Immutability**: prefer immutable data structures where appropriate; avoid mutating shared state182- **Pure functions**: side effects isolated and explicit; core logic written as pure functions where possible183184### Code & File Size185- **Method/function length**: methods exceeding **30 lines** should be justified; methods exceeding **50 lines** require refactoring — they are doing too much (Clean Code / Rule of 30)186- **Class length**: classes exceeding **200 lines** should be reviewed for single-responsibility violations; classes exceeding **500 lines** require decomposition187- **File length**: source files exceeding **300 lines** are a signal of multiple responsibilities; files exceeding **500 lines** should be investigated and split188- **Component length** *(Vue/React)*: SFCs or components exceeding **300 total lines** should be decomposed; `<template>` and `<script>` blocks each kept under **150 lines** where possible189- **Binary files in git**: images, PDFs, videos, database dumps, and compiled binaries not committed to the repository; `.gitignore` covers them; Git LFS used for large assets that must be versioned190- **File reading at runtime**: files read from disk using streaming (not loaded entirely into memory) when the file size is not bounded and could be large191192---193194## 5. Potential Bug Investigation195196Actively trace the modified code looking for latent bugs — do not just check style or structure. For each item below, reason through the changed code paths and report anything that could produce incorrect behavior, data corruption, or a runtime failure.197198- **Null / undefined / zero dereference**: identify paths where a variable could be `null`, `undefined`, `0`, or an empty collection at the point it is used without a guard199- **Off-by-one errors**: check loop bounds, slice indices, pagination offsets, and comparisons using `<` vs `<=`200- **Inverted or incomplete conditions**: logic conditions that appear reversed (`!==` where `===` was intended), missing `else` branches, or `switch` cases without a `default`201- **Implicit assumptions about state**: code that assumes a record exists, a list is non-empty, a value has already been set, or a previous step has succeeded — without verifying202- **Broken contracts with dependents**: changes to a method signature, return shape, event payload, or database column that are not reflected in all callers, consumers, or downstream modules203- **Race conditions in async flows**: multiple async operations that share state and could interleave in a way that produces inconsistent results204- **Data mutation side effects**: functions that mutate their input arguments, shared collections, or global state in ways that callers do not expect205- **Query / migration data hazards**: SQL changes that could silently drop data, produce incorrect results on existing rows, or behave differently on empty vs non-empty tables206- **Error paths that silently succeed**: catch blocks that swallow exceptions and return a success response; missing re-throws; errors logged but not propagated207- **Type coercion surprises**: implicit type coercions (PHP loose comparisons, JavaScript `==`, string-to-number) that could produce wrong results at the boundary of the changed code208- **Unreachable or dead logic**: conditions that can never be true given the surrounding context; code after an unconditional `return`; branches that contradict earlier guards209210---211212## 6. Accessibility *(only if the diff includes frontend/UI changes)*213214- **Semantic HTML**: correct use of headings, landmarks, lists, buttons, and form elements215- **ARIA attributes**: `aria-label`, `aria-describedby`, `role`, etc. used correctly and only when native semantics are insufficient216- **Keyboard navigation**: all interactive elements reachable and operable via keyboard217- **Focus management**: focus order is logical; focus traps used appropriately in modals/dialogs218- **Color contrast**: text and UI elements meet WCAG AA contrast ratios219- **Images & icons**: meaningful images have `alt` text; decorative images use `alt=""`220- **Form labels**: all inputs have associated `<label>` or `aria-label`221222---223224## 7. Observability225226- **Structured logging**: logs use a structured format (JSON or key=value); no `console.log` / `var_dump` left in production code227- **Sensitive data in logs**: no passwords, tokens, PII, or secrets logged — even partially228- **Log levels**: appropriate log levels used (`debug`, `info`, `warning`, `error`); no critical events logged at `debug`229- **Correlation IDs**: requests and async jobs carry a trace/correlation ID through logs230- **Error reporting**: exceptions are captured and forwarded to the error tracking system (e.g. Sentry, Bugsnag)231- **Metrics**: significant new operations (queue jobs, external calls, cache hits) are instrumented where relevant232233---234235## 8. API Design *(only if the diff includes API endpoints or API client code)*236237- **HTTP methods**: correct verbs used (`GET` for reads, `POST` for creation, `PUT`/`PATCH` for updates, `DELETE` for removal)238- **Status codes**: correct HTTP status codes returned (`201` for creation, `204` for no content, `422` for validation errors, `404` for not found, etc.)239- **Versioning**: API version is reflected in the URL or header; breaking changes bump the version240- **Consistent error responses**: error payloads follow a uniform structure across all endpoints241- **Pagination**: consistent strategy used (cursor or offset); metadata included in response242- **Filtering & sorting**: query parameters follow established conventions243- **Idempotency**: `PUT`/`PATCH`/`DELETE` operations are idempotent; `POST` operations are idempotent where appropriate (e.g. with idempotency keys)244- **No sensitive data in URLs**: tokens, passwords, and PII passed in headers or body, not in query strings or paths245- **GraphQL** *(only if project uses GraphQL)*: N+1 prevented with DataLoader, query depth limited, introspection disabled in production, mutations validate input246247---248249## 9. Resilience & Fault Tolerance *(only if the diff involves external calls, queues, or critical flows)*250251- **Timeouts**: all outbound HTTP calls, database queries, and queue operations have explicit timeouts252- **Retry with backoff**: transient failures retried with exponential backoff and jitter; non-retriable errors not retried253- **Circuit breakers**: repeated failures to an external dependency trip a circuit breaker to prevent cascade254- **Graceful degradation**: the system degrades gracefully when a non-critical dependency is unavailable255- **Idempotency**: operations that may be retried are idempotent (safe to execute more than once)256- **Bulkhead isolation**: slow or failing dependencies do not exhaust shared resources (thread pools, connections)257258---259260## 10. Zero-Downtime Database Migrations *(only if the diff includes migrations)*261262- **Additive changes first**: new columns added as nullable or with a default before application code uses them263- **No instant NOT NULL without default**: adding a NOT NULL column without a default on a large table causes a full table lock264- **Column/table rename safety**: old column kept alongside new one during a transition period; renamed in a follow-up migration after code is deployed265- **Column removal safety**: column removed only after code no longer references it and the deployment is stable266- **Index creation**: indexes on large tables created concurrently (e.g. `CREATE INDEX CONCURRENTLY`) to avoid locking267- **Reversibility**: `down` method correctly undoes the `up` method without data loss268269---270271## 11. Concurrency & Thread Safety *(only if the diff involves shared state, background jobs, or concurrent operations)*272273- **Race conditions**: operations on shared state are atomic or properly synchronized274- **Locks & mutexes**: locking strategy is correct; no deadlock potential (consistent lock ordering)275- **Atomic operations**: counters and flags updated atomically (e.g. database atomic increments, compare-and-swap)276- **Job uniqueness**: background jobs that must not run concurrently are protected by a unique lock277- **Shared mutable state**: global or static mutable state avoided; dependencies injected rather than shared278279---280281## 12. Internationalization (i18n) *(only if the project supports multiple languages or locales)*282283- **No hardcoded strings**: all user-facing text uses translation keys, not inline strings284- **Date & time formatting**: dates, times, and durations formatted via locale-aware utilities, not manual string building285- **Number & currency formatting**: numbers and currency amounts formatted according to the user's locale286- **Pluralization**: plural forms handled correctly via i18n library, not with manual conditionals287- **RTL support**: layout does not break for right-to-left languages if RTL is supported288- **Locale in URLs or headers**: locale derived from user preference or `Accept-Language`, not hardcoded289290---291292## 13. Privacy & Data Compliance *(only if the diff involves user data, PII, or data storage)*293294- **Minimal data collection**: only data strictly necessary for the feature is collected and stored295- **PII handling**: personal data identified, encrypted at rest where required, and access-controlled296- **Data retention**: data is deleted or anonymized according to defined retention policies297- **Consent**: data collection requiring user consent is gated behind explicit opt-in298- **Audit trail**: access to and modification of sensitive data is logged for audit purposes299- **Third-party data sharing**: data shared with external services is documented and limited to what is necessary300301---302303## 14. What Was Done Well304305Before listing issues, acknowledge what was done well in this change. Point out strong design decisions, good test coverage, clean abstractions, or anything that should be recognized and repeated.306307---308309## 15. Output Format310311For each finding, report:312313```314### [Category] — [Severity]315316**File:** `path/to/file.ext:line`317**Issue:** Brief description of the problem.318**Fix:** Suggested correction or approach.319```320321At the end, provide a summary table covering all evaluated categories (use N/A for categories that do not apply to this change):322323```324## Summary325326| Category | Critical | Warning | Suggestion | N/A |327|-----------------------|----------|---------|------------|-----|328| Security | 0 | 0 | 0 | |329| Performance | 0 | 0 | 0 | |330| Tests/Coverage | 0 | 0 | 0 | |331| Architecture | 0 | 0 | 0 | |332| Code & File Size | 0 | 0 | 0 | |333| Potential Bugs | 0 | 0 | 0 | |334| Accessibility | 0 | 0 | 0 | |335| Observability | 0 | 0 | 0 | |336| API Design | 0 | 0 | 0 | |337| Resilience | 0 | 0 | 0 | |338| DB Migrations | 0 | 0 | 0 | |339| Concurrency | 0 | 0 | 0 | |340| i18n | 0 | 0 | 0 | |341| Privacy/Compliance | 0 | 0 | 0 | |342| Architecture Patterns | 0 | 0 | 0 | |343| Stack-Specific | 0 | 0 | 0 | |344| **Total** | **0** | **0** | **0** | |345```346347If no issues are found, state: **"Code review passed — no issues found."**