Frontend Code Review
Systematically review frontend code to identify issues, ensure quality, and provide actionable improvement recommendations across code quality, performance, accessibility, and security dimensions.
Review Workflow
1. Initial Assessment
Gather context about the project and identify review scope:
Project Context:
- Framework and version (React, Vue, Angular, vanilla JS)
- Build tools and dependencies
- Target browsers/devices
- Accessibility requirements (WCAG level)
- Performance targets (Core Web Vitals)
Review Scope:
- New features vs. refactoring vs. bug fixes
- Component complexity level
- Critical user paths
- Security-sensitive areas
2. Code Quality Analysis
Evaluate component structure, code patterns, and maintainability:
Key Areas:
- Component architecture (single responsibility, composition patterns)
- JavaScript/TypeScript quality (type safety, naming, complexity)
- State management decisions (local vs. global, immutability)
- Error handling and edge cases
- Code duplication and DRY violations
Load references/code-quality-checklist.md for detailed quality criteria, common issues, and fixes with code examples
3. Performance Review
Assess rendering efficiency, resource loading, and Core Web Vitals:
Focus Areas:
- Rendering optimization (React.memo, useMemo, useCallback, keys)
- Resource loading (images, fonts, scripts, lazy loading)
- Bundle size and code splitting
- Core Web Vitals: LCP < 2.5s, FID < 100ms, CLS < 0.1
- Memory leaks and cleanup
Load references/performance-checklist.md for detailed optimization techniques and Web Vitals guidelines with code examples
4. Accessibility Assessment
Evaluate WCAG 2.1 compliance and inclusive design:
Key Areas:
- Semantic HTML (proper headings, landmarks, lists)
- ARIA implementation (labels, roles, live regions)
- Keyboard navigation and focus management
- Screen reader support (alt text, labels, announcements)
- Color contrast ratios
Load references/accessibility-checklist.md for WCAG 2.1 AA/AAA compliance criteria with detailed examples
5. Security Review
Identify vulnerabilities and security best practices:
Common Vulnerabilities:
- XSS (input sanitization, safe HTML rendering)
- CSRF protection
- Authentication token handling
- Sensitive data exposure
- Dependency vulnerabilities
Security Controls:
- Content Security Policy (CSP)
- HTTPS enforcement
- Secure cookies
- Input validation and output encoding
Load references/security-checklist.md for comprehensive frontend security guidelines and vulnerability prevention
6. CSS/Styling Review
Assess architecture, responsiveness, and maintainability:
Key Areas:
- CSS methodology (BEM, OOCSS, CSS-in-JS, Tailwind)
- Responsive design (mobile-first, breakpoints, flexible layouts)
- Design tokens and variables
- Specificity management
- Unused CSS detection
7. Testing Coverage
Evaluate test completeness and quality:
Test Types:
- Unit tests (component logic, utilities, edge cases)
- Integration tests (component interaction, API integration, state flows)
- E2E tests (critical user journeys, cross-browser compatibility)
- Accessibility automated tests
8. Generate Review Report
Create structured report with findings and recommendations:
Report Structure:
- Executive Summary (quality rating, critical issues, recommendation)
- Detailed Findings (by category with severity: Critical/Major/Minor)
- Action Items (prioritized with file/line references and specific fixes)
Load references/report-templates.md for full review report formats and examples
Review Process Guidelines
Review Timing:
- Pre-Commit: Automated linting and formatting
- Pre-PR: Self-review using this workflow
- PR Review: Peer review with comprehensive analysis
- Pre-Deployment: Final quality gate
Severity Definitions:
- Critical: Blocks deployment (security issues, breaking bugs, accessibility blockers)
- Major: Should fix before merge (performance issues, poor patterns, maintainability concerns)
- Minor: Nice to improve (style suggestions, micro-optimizations, documentation)
Common Anti-Patterns
React/Component Patterns:
- Prop drilling through multiple levels
- God components doing too much
- Missing error boundaries
- Mutating state directly
- Inline functions causing unnecessary re-renders
JavaScript/TypeScript:
- Using
any type in TypeScript
- Console.log in production code
- Deeply nested callbacks
- Global variables
- Unhandled promises
CSS/Styling:
- !important overuse
- Inline styles instead of classes
- Fixed pixels instead of relative units
- High specificity wars
Performance:
- Synchronous expensive operations in render
- Large unoptimized bundles (>500KB)
- Missing code splitting and lazy loading
- Unoptimized images
Accessibility:
- Non-semantic div/span buttons
- Missing alt attributes
- Color-only information
- Keyboard traps
- Missing focus management in modals
Key Review Checkpoints
Code Quality:
Performance:
Accessibility:
Security:
Reference Files
Load these files when detailed guidance is needed:
- references/code-quality-checklist.md: Component patterns, code smells, fixes with examples (693 lines)
- references/performance-checklist.md: Web Vitals optimization, rendering performance (891 lines)
- references/accessibility-checklist.md: WCAG 2.1 compliance with detailed examples (1045 lines)
- references/security-checklist.md: XSS, CSRF, authentication, CSP guidelines (969 lines)
- references/report-templates.md: Review report formats and examples (1203 lines)
1---2name: frontend-code-review3description: Conducts comprehensive frontend code reviews including React/Vue/Angular component analysis, TypeScript/JavaScript quality assessment, CSS/styling review, performance optimization, accessibility compliance, security vulnerabilities, and best practices validation. Produces detailed review reports with specific issues, severity ratings, and actionable recommendations. Use when reviewing frontend code, analyzing React/Vue/Angular components, checking JavaScript/TypeScript quality, validating CSS/SCSS, assessing web performance, or when users mention "review frontend code", "check React components", "analyze JavaScript", "review TypeScript", "validate accessibility", or "frontend code quality".4---5
6# Frontend Code Review
7
8Systematically review frontend code to identify issues, ensure quality, and provide actionable improvement recommendations across code quality, performance, accessibility, and security dimensions.
9
10## Review Workflow
11
12## 1. Initial Assessment
13
14Gather context about the project and identify review scope:
15
16**Project Context:**
17
18- Framework and version (React, Vue, Angular, vanilla JS)
19- Build tools and dependencies
20- Target browsers/devices
21- Accessibility requirements (WCAG level)
22- Performance targets (Core Web Vitals)
23
24**Review Scope:**
25
26- New features vs. refactoring vs. bug fixes
27- Component complexity level
28- Critical user paths
29- Security-sensitive areas
30
31### 2. Code Quality Analysis
32
33Evaluate component structure, code patterns, and maintainability:
34
35**Key Areas:**
36
37- Component architecture (single responsibility, composition patterns)
38- JavaScript/TypeScript quality (type safety, naming, complexity)
39- State management decisions (local vs. global, immutability)
40- Error handling and edge cases
41- Code duplication and DRY violations
42
43> **Load references/code-quality-checklist.md** for detailed quality criteria, common issues, and fixes with code examples
44
45### 3. Performance Review
46
47Assess rendering efficiency, resource loading, and Core Web Vitals:
48
49**Focus Areas:**
50
51- Rendering optimization (React.memo, useMemo, useCallback, keys)
52- Resource loading (images, fonts, scripts, lazy loading)
53- Bundle size and code splitting
54- Core Web Vitals: LCP < 2.5s, FID < 100ms, CLS < 0.1
55- Memory leaks and cleanup
56
57> **Load references/performance-checklist.md** for detailed optimization techniques and Web Vitals guidelines with code examples
58
59### 4. Accessibility Assessment
60
61Evaluate WCAG 2.1 compliance and inclusive design:
62
63**Key Areas:**
64
65- Semantic HTML (proper headings, landmarks, lists)
66- ARIA implementation (labels, roles, live regions)
67- Keyboard navigation and focus management
68- Screen reader support (alt text, labels, announcements)
69- Color contrast ratios
70
71> **Load references/accessibility-checklist.md** for WCAG 2.1 AA/AAA compliance criteria with detailed examples
72
73### 5. Security Review
74
75Identify vulnerabilities and security best practices:
76
77**Common Vulnerabilities:**
78
79- XSS (input sanitization, safe HTML rendering)
80- CSRF protection
81- Authentication token handling
82- Sensitive data exposure
83- Dependency vulnerabilities
84
85**Security Controls:**
86
87- Content Security Policy (CSP)
88- HTTPS enforcement
89- Secure cookies
90- Input validation and output encoding
91
92> **Load references/security-checklist.md** for comprehensive frontend security guidelines and vulnerability prevention
93
94### 6. CSS/Styling Review
95
96Assess architecture, responsiveness, and maintainability:
97
98**Key Areas:**
99
100- CSS methodology (BEM, OOCSS, CSS-in-JS, Tailwind)
101- Responsive design (mobile-first, breakpoints, flexible layouts)
102- Design tokens and variables
103- Specificity management
104- Unused CSS detection
105
106### 7. Testing Coverage
107
108Evaluate test completeness and quality:
109
110**Test Types:**
111
112- Unit tests (component logic, utilities, edge cases)
113- Integration tests (component interaction, API integration, state flows)
114- E2E tests (critical user journeys, cross-browser compatibility)
115- Accessibility automated tests
116
117### 8. Generate Review Report
118
119Create structured report with findings and recommendations:
120
121**Report Structure:**
122
123- Executive Summary (quality rating, critical issues, recommendation)
124- Detailed Findings (by category with severity: Critical/Major/Minor)
125- Action Items (prioritized with file/line references and specific fixes)
126
127> **Load references/report-templates.md** for full review report formats and examples
128
129## Review Process Guidelines
130
131**Review Timing:**
132
133- **Pre-Commit**: Automated linting and formatting
134- **Pre-PR**: Self-review using this workflow
135- **PR Review**: Peer review with comprehensive analysis
136- **Pre-Deployment**: Final quality gate
137
138**Severity Definitions:**
139
140- **Critical**: Blocks deployment (security issues, breaking bugs, accessibility blockers)
141- **Major**: Should fix before merge (performance issues, poor patterns, maintainability concerns)
142- **Minor**: Nice to improve (style suggestions, micro-optimizations, documentation)
143
144## Common Anti-Patterns
145
146**React/Component Patterns:**
147
148- Prop drilling through multiple levels
149- God components doing too much
150- Missing error boundaries
151- Mutating state directly
152- Inline functions causing unnecessary re-renders
153
154**JavaScript/TypeScript:**
155
156- Using `any` type in TypeScript
157- Console.log in production code
158- Deeply nested callbacks
159- Global variables
160- Unhandled promises
161
162**CSS/Styling:**
163
164- !important overuse
165- Inline styles instead of classes
166- Fixed pixels instead of relative units
167- High specificity wars
168
169**Performance:**
170
171- Synchronous expensive operations in render
172- Large unoptimized bundles (>500KB)
173- Missing code splitting and lazy loading
174- Unoptimized images
175
176**Accessibility:**
177
178- Non-semantic div/span buttons
179- Missing alt attributes
180- Color-only information
181- Keyboard traps
182- Missing focus management in modals
183
184## Key Review Checkpoints
185
186**Code Quality:**
187
188- [ ] Components follow single responsibility
189- [ ] Functions < 50 lines, complexity < 10
190- [ ] TypeScript strict mode enabled
191- [ ] Meaningful naming conventions
192- [ ] Error handling present
193
194**Performance:**
195
196- [ ] Appropriate use of React.memo/useMemo/useCallback
197- [ ] Images optimized (WebP/AVIF)
198- [ ] Code splitting implemented
199- [ ] Core Web Vitals within targets
200
201**Accessibility:**
202
203- [ ] Semantic HTML used
204- [ ] All images have alt text
205- [ ] Keyboard navigable
206- [ ] Color contrast compliant (≥4.5:1)
207
208**Security:**
209
210- [ ] User input sanitized
211- [ ] XSS prevention in place
212- [ ] No sensitive data in localStorage
213- [ ] Dependencies up to date
214
215## Reference Files
216
217Load these files when detailed guidance is needed:
218
219- **references/code-quality-checklist.md**: Component patterns, code smells, fixes with examples (693 lines)
220- **references/performance-checklist.md**: Web Vitals optimization, rendering performance (891 lines)
221- **references/accessibility-checklist.md**: WCAG 2.1 compliance with detailed examples (1045 lines)
222- **references/security-checklist.md**: XSS, CSRF, authentication, CSP guidelines (969 lines)
223- **references/report-templates.md**: Review report formats and examples (1203 lines)