Code Review
You are performing a structured code review. Follow this process for every review.
Review Process
Step 1: Understand Scope
Before reviewing, determine:
- What files/components are being reviewed?
- Is this a full review or focused (security, performance, accessibility)?
- What framework/stack is the code using?
Step 2: Multi-Pass Analysis
Run these passes in order. Skip passes the user explicitly excludes.
Pass 1 — Correctness & Bugs
- Logic errors, off-by-one, null/undefined access
- Race conditions in async code
- Missing error boundaries in React/component trees
- Incorrect hook dependencies (
useEffect, useMemo, useCallback)
- State mutations that bypass reactivity (direct array/object mutation)
Pass 2 — Security
- XSS via
dangerouslySetInnerHTML, v-html, or unescaped template interpolation
- Exposed API keys, tokens, or secrets in client-side code
- Insecure
postMessage usage without origin checks
- Open redirect vulnerabilities
- Missing CSRF protections on form submissions
- Unsafe
eval(), Function(), or dynamic import() from user input
Pass 3 — Performance
- Unnecessary re-renders (missing memoization, unstable references)
- Layout thrashing (reading + writing DOM in loops)
- Expensive CSS:
filter, backdrop-filter, box-shadow on animated elements
will-change overuse or missing for animated elements
- Large bundle imports that could be lazy-loaded or tree-shaken
- Images without
loading="lazy", missing srcset/sizes
- Animations using
top/left instead of transform
Pass 4 — Accessibility (a11y)
- Missing
alt text, aria-label, or role attributes
- Non-semantic HTML (div soup)
- Color contrast issues (reference WCAG 2.1 AA)
- Focus management: can the UI be navigated by keyboard?
- Motion: does the code respect
prefers-reduced-motion?
- Touch targets under 44x44px
Pass 5 — Code Quality & Style
- Dead code, unused imports, unreachable branches
- Overly complex functions (consider cyclomatic complexity > 10)
- Magic numbers/strings without named constants
- Naming: unclear abbreviations, misleading names
- File length > 300 lines — suggest splitting
- Missing TypeScript types or
any abuse
Step 3: Structured Output
Present findings in this format:
## Review Summary
**Files reviewed:** [list]
**Overall:** [PASS | NEEDS WORK | CRITICAL ISSUES]
### Critical 🔴
- [Finding with file:line reference and fix suggestion]
### Warning 🟡
- [Finding with explanation and fix suggestion]
### Suggestion 🟢
- [Nice-to-have improvement]
### Positive ✅
- [Things done well — always include at least one]
Rules
- Always include at least one positive finding. Reviews should be constructive.
- Provide a concrete fix or code snippet for every Critical and Warning finding.
- Don't flag style preferences that are purely subjective (tabs vs spaces, semicolons, etc.) unless they violate the project's existing conventions.
- For performance findings, explain the why — e.g., "this causes layout recalculation because..."
- When reviewing animations/transitions, check for
transform/opacity-only animations on the compositor thread.
- If the codebase uses a specific linter/formatter config, defer to it for style issues.
Frontend-Specific Checklist
When reviewing frontend code, also check:
1---2name: code-review3description: Use this skill when the user asks to review code, audit a file or PR, find bugs, check for security vulnerabilities, analyze performance bottlenecks, or improve code quality. Also triggers for requests like "what's wrong with this code", "is this secure", "review my component", or "check for accessibility issues". Covers frontend-focused reviews including React/Vue/Svelte component patterns, CSS/animation performance, accessibility (a11y), bundle size impact, and browser compatibility. Produces structured, actionable feedback with severity levels and fix suggestions.4license: Complete terms in LICENSE.txt5---67# Code Review89You are performing a structured code review. Follow this process for every review.1011## Review Process1213### Step 1: Understand Scope1415Before reviewing, determine:1617- What files/components are being reviewed?18- Is this a full review or focused (security, performance, accessibility)?19- What framework/stack is the code using?2021### Step 2: Multi-Pass Analysis2223Run these passes in order. Skip passes the user explicitly excludes.2425#### Pass 1 — Correctness & Bugs2627- Logic errors, off-by-one, null/undefined access28- Race conditions in async code29- Missing error boundaries in React/component trees30- Incorrect hook dependencies (`useEffect`, `useMemo`, `useCallback`)31- State mutations that bypass reactivity (direct array/object mutation)3233#### Pass 2 — Security3435- XSS via `dangerouslySetInnerHTML`, `v-html`, or unescaped template interpolation36- Exposed API keys, tokens, or secrets in client-side code37- Insecure `postMessage` usage without origin checks38- Open redirect vulnerabilities39- Missing CSRF protections on form submissions40- Unsafe `eval()`, `Function()`, or dynamic `import()` from user input4142#### Pass 3 — Performance4344- Unnecessary re-renders (missing memoization, unstable references)45- Layout thrashing (reading + writing DOM in loops)46- Expensive CSS: `filter`, `backdrop-filter`, `box-shadow` on animated elements47- `will-change` overuse or missing for animated elements48- Large bundle imports that could be lazy-loaded or tree-shaken49- Images without `loading="lazy"`, missing `srcset`/`sizes`50- Animations using `top/left` instead of `transform`5152#### Pass 4 — Accessibility (a11y)5354- Missing `alt` text, `aria-label`, or `role` attributes55- Non-semantic HTML (div soup)56- Color contrast issues (reference WCAG 2.1 AA)57- Focus management: can the UI be navigated by keyboard?58- Motion: does the code respect `prefers-reduced-motion`?59- Touch targets under 44x44px6061#### Pass 5 — Code Quality & Style6263- Dead code, unused imports, unreachable branches64- Overly complex functions (consider cyclomatic complexity > 10)65- Magic numbers/strings without named constants66- Naming: unclear abbreviations, misleading names67- File length > 300 lines — suggest splitting68- Missing TypeScript types or `any` abuse6970### Step 3: Structured Output7172Present findings in this format:7374```75## Review Summary7677**Files reviewed:** [list]78**Overall:** [PASS | NEEDS WORK | CRITICAL ISSUES]7980### Critical 🔴81- [Finding with file:line reference and fix suggestion]8283### Warning 🟡84- [Finding with explanation and fix suggestion]8586### Suggestion 🟢87- [Nice-to-have improvement]8889### Positive ✅90- [Things done well — always include at least one]91```9293## Rules9495- Always include at least one positive finding. Reviews should be constructive.96- Provide a concrete fix or code snippet for every Critical and Warning finding.97- Don't flag style preferences that are purely subjective (tabs vs spaces, semicolons, etc.) unless they violate the project's existing conventions.98- For performance findings, explain the _why_ — e.g., "this causes layout recalculation because..."99- When reviewing animations/transitions, check for `transform`/`opacity`-only animations on the compositor thread.100- If the codebase uses a specific linter/formatter config, defer to it for style issues.101102## Frontend-Specific Checklist103104When reviewing frontend code, also check:105106- [ ] Components have clear prop types / interfaces107- [ ] Event handlers are properly cleaned up (removeEventListener, abort controllers)108- [ ] CSS animations use GPU-accelerated properties (`transform`, `opacity`)109- [ ] `z-index` values follow a documented scale (not random large numbers)110- [ ] Responsive design handles common breakpoints111- [ ] Loading/error/empty states are handled112- [ ] Text is not hardcoded (i18n-ready if applicable)