Code Review Skill
Perform a comprehensive code review following this structured approach. Generate a detailed report covering all sections below.
Review Scope
Determine what to review:
- If no argument is provided, ask the user what code they want reviewed
- If the user wants to review the entire codebase, review the entire codebase. If they ask for a specific file or directory, review that file/directory
Review Process
Phase 1: Context Gathering
Before reviewing, gather context:
- Read the target file(s) completely
- Identify related files (imports, types, tests)
- Understand the file's role in the broader architecture
- Check for existing patterns in similar files in the codebase
Phase 2: Analysis Categories
Analyze the code across these dimensions:
1. Poor Practices
- Anti-patterns specific to the framework (Next.js, React, Supabase)
- Violation of SOLID principles
- Code smells (long functions, deep nesting, magic numbers)
- Improper separation of concerns
- Hardcoded values that should be configurable
- Missing or improper use of TypeScript features
- Callback hell or promise chain issues
- Improper state management patterns
2. Inefficiencies
- Unnecessary re-renders in React components
- Missing memoization opportunities (useMemo, useCallback, React.memo)
- N+1 query patterns in database calls
- Redundant database queries that could be batched
- Inefficient data transformations
- Unnecessary API calls
- Missing caching opportunities
- Inefficient loops or array operations
3. Potential Bugs
- Race conditions in async code
- Missing null/undefined checks
- Type coercion issues
- Off-by-one errors
- Incorrect error handling that swallows errors
- Memory leaks (missing cleanup in useEffect)
- Stale closure issues
- Missing dependency array items in hooks
- Incorrect comparison operators
- Unhandled promise rejections
- Edge cases not covered
4. Security Vulnerabilities
- SQL injection risks
- XSS vulnerabilities
- Missing input validation
- Sensitive data exposure in logs
- Missing authentication/authorization checks
- Insecure direct object references
- Missing CSRF protection
- Hardcoded secrets or credentials
- Improper error messages exposing internals
5. DRY (Don't Repeat Yourself) Violations
- Duplicated code blocks
- Similar functions that could be generalized
- Repeated conditional logic
- Copy-pasted error handling
- Duplicate type definitions
- Repeated validation logic
- Similar UI patterns not abstracted
6. Type Safety Issues
- Use of
any type
- Missing return types
- Loose type assertions (
as any, as unknown)
- Missing generic constraints
- Incorrect type narrowing
- Missing discriminated unions for state
- Type assertions hiding real type issues
7. Error Handling
- Missing try-catch blocks
- Generic error messages
- Errors not reported to Sentry
- Missing error boundaries for React
- Inconsistent error response formats
- Silent failures
- Missing user feedback on errors
8. Maintainability Concerns
- Missing or outdated comments
- Unclear variable/function names
- Complex logic without explanation
- Missing JSDoc for public APIs
- Overly complex conditionals
- Deep nesting (> 3 levels)
- Functions doing too many things
- Missing abstraction layers
9. Testing Gaps
- Untested edge cases
- Missing error case tests
- Insufficient test coverage indicators
- Hard-to-test code structure
- Missing mocks for external dependencies
10. Consistency Issues
- Inconsistent naming conventions
- Mixed async patterns (callbacks vs promises vs async/await)
- Inconsistent error handling patterns
- Style inconsistencies with codebase patterns
- Inconsistent use of utilities vs raw implementations
Phase 3: Report Generation
Generate a structured report with these sections:
# Code Review Report
## Summary
[Brief overview of the file's purpose and overall code quality assessment]
[Severity summary: X Critical, Y High, Z Medium, W Low]
## Critical Issues
[Issues that could cause bugs, security vulnerabilities, or data loss]
## High Priority
[Significant issues affecting maintainability, performance, or reliability]
## Medium Priority
[Code quality issues that should be addressed]
## Low Priority / Suggestions
[Nice-to-have improvements and minor suggestions]
## Positive Observations
[Good practices and patterns worth noting]
## Recommendations
[Specific, actionable recommendations with code examples where helpful]
Issue Format
For each issue found, provide:
- Location: File path and line number(s)
- Category: Which analysis category it falls under
- Severity: Critical / High / Medium / Low
- Description: Clear explanation of the issue
- Impact: Why this matters
- Recommendation: How to fix it (with code example if applicable)
Severity Definitions
- Critical: Security vulnerabilities, data loss risks, crashes, or bugs affecting core functionality
- High: Performance issues, significant maintainability problems, or patterns that will likely cause bugs
- Medium: Code quality issues, minor inefficiencies, or violations of best practices
- Low: Style suggestions, minor improvements, or nice-to-haves
Kove-Specific Patterns to Check
When reviewing code in this codebase, verify:
Server Actions
- Using
'use server' directive
- Proper Supabase client instantiation (createClient for server)
- Error reporting to Sentry with context
- Proper revalidation after mutations
- Input validation before database operations
Database Queries
- Using generated types from
database.types.ts
- Proper RLS policy compliance
- Multi-tenancy with organization_id filtering
- Batch queries instead of N+1 patterns
- Proper use of
.single() vs .maybeSingle()
React Components
- Proper 'use client' directive when needed
- Using shadcn/ui components correctly
- Proper form handling with React Hook Form + Zod v4
- Loading states with LoadingButton for async actions
- Error boundaries for critical sections
Supabase Edge Functions
- Using SDK pattern (supabase.functions.invoke)
- Not using raw fetch for edge functions
- Proper error handling with error types
Validation
- Using Zod v4 patterns (not v3)
- Proper error messages with
{ error: "..." }
- Using top-level validators (z.email(), z.uuid())
Output
After completing the review, present the report to the user in a clear, organized format. Prioritize actionable feedback over nitpicks. Focus on issues that have real impact on code quality, security, or maintainability.
If the code is generally good, acknowledge that while still noting any improvements that could be made.
ignore this line
1---2name: code-review-563description: Conducts comprehensive code reviews identifying poor practices, inefficiencies, potential bugs, security vulnerabilities, and provides recommendations for making code DRYer and more maintainable. Use when reviewing files, PRs, or code quality.4---5
6# Code Review Skill
7
8<code-review>
9
10Perform a comprehensive code review following this structured approach. Generate a detailed report covering all sections below.
11
12## Review Scope
13
14Determine what to review:
151. If no argument is provided, ask the user what code they want reviewed
162. If the user wants to review the entire codebase, review the entire codebase. If they ask for a specific file or directory, review that file/directory
17
18## Review Process
19
20### Phase 1: Context Gathering
21
22Before reviewing, gather context:
231. Read the target file(s) completely
242. Identify related files (imports, types, tests)
253. Understand the file's role in the broader architecture
264. Check for existing patterns in similar files in the codebase
27
28### Phase 2: Analysis Categories
29
30Analyze the code across these dimensions:
31
32#### 1. Poor Practices
33- Anti-patterns specific to the framework (Next.js, React, Supabase)
34- Violation of SOLID principles
35- Code smells (long functions, deep nesting, magic numbers)
36- Improper separation of concerns
37- Hardcoded values that should be configurable
38- Missing or improper use of TypeScript features
39- Callback hell or promise chain issues
40- Improper state management patterns
41
42#### 2. Inefficiencies
43- Unnecessary re-renders in React components
44- Missing memoization opportunities (useMemo, useCallback, React.memo)
45- N+1 query patterns in database calls
46- Redundant database queries that could be batched
47- Inefficient data transformations
48- Unnecessary API calls
49- Missing caching opportunities
50- Inefficient loops or array operations
51
52#### 3. Potential Bugs
53- Race conditions in async code
54- Missing null/undefined checks
55- Type coercion issues
56- Off-by-one errors
57- Incorrect error handling that swallows errors
58- Memory leaks (missing cleanup in useEffect)
59- Stale closure issues
60- Missing dependency array items in hooks
61- Incorrect comparison operators
62- Unhandled promise rejections
63- Edge cases not covered
64
65#### 4. Security Vulnerabilities
66- SQL injection risks
67- XSS vulnerabilities
68- Missing input validation
69- Sensitive data exposure in logs
70- Missing authentication/authorization checks
71- Insecure direct object references
72- Missing CSRF protection
73- Hardcoded secrets or credentials
74- Improper error messages exposing internals
75
76#### 5. DRY (Don't Repeat Yourself) Violations
77- Duplicated code blocks
78- Similar functions that could be generalized
79- Repeated conditional logic
80- Copy-pasted error handling
81- Duplicate type definitions
82- Repeated validation logic
83- Similar UI patterns not abstracted
84
85#### 6. Type Safety Issues
86- Use of `any` type
87- Missing return types
88- Loose type assertions (`as any`, `as unknown`)
89- Missing generic constraints
90- Incorrect type narrowing
91- Missing discriminated unions for state
92- Type assertions hiding real type issues
93
94#### 7. Error Handling
95- Missing try-catch blocks
96- Generic error messages
97- Errors not reported to Sentry
98- Missing error boundaries for React
99- Inconsistent error response formats
100- Silent failures
101- Missing user feedback on errors
102
103#### 8. Maintainability Concerns
104- Missing or outdated comments
105- Unclear variable/function names
106- Complex logic without explanation
107- Missing JSDoc for public APIs
108- Overly complex conditionals
109- Deep nesting (> 3 levels)
110- Functions doing too many things
111- Missing abstraction layers
112
113#### 9. Testing Gaps
114- Untested edge cases
115- Missing error case tests
116- Insufficient test coverage indicators
117- Hard-to-test code structure
118- Missing mocks for external dependencies
119
120#### 10. Consistency Issues
121- Inconsistent naming conventions
122- Mixed async patterns (callbacks vs promises vs async/await)
123- Inconsistent error handling patterns
124- Style inconsistencies with codebase patterns
125- Inconsistent use of utilities vs raw implementations
126
127### Phase 3: Report Generation
128
129Generate a structured report with these sections:
130
131```markdown
132# Code Review Report
133
134## Summary
135[Brief overview of the file's purpose and overall code quality assessment]
136[Severity summary: X Critical, Y High, Z Medium, W Low]
137
138## Critical Issues
139[Issues that could cause bugs, security vulnerabilities, or data loss]
140
141## High Priority
142[Significant issues affecting maintainability, performance, or reliability]
143
144## Medium Priority
145[Code quality issues that should be addressed]
146
147## Low Priority / Suggestions
148[Nice-to-have improvements and minor suggestions]
149
150## Positive Observations
151[Good practices and patterns worth noting]
152
153## Recommendations
154[Specific, actionable recommendations with code examples where helpful]
155```
156
157### Issue Format
158
159For each issue found, provide:
1601. **Location**: File path and line number(s)
1612. **Category**: Which analysis category it falls under
1623. **Severity**: Critical / High / Medium / Low
1634. **Description**: Clear explanation of the issue
1645. **Impact**: Why this matters
1656. **Recommendation**: How to fix it (with code example if applicable)
166
167### Severity Definitions
168
169- **Critical**: Security vulnerabilities, data loss risks, crashes, or bugs affecting core functionality
170- **High**: Performance issues, significant maintainability problems, or patterns that will likely cause bugs
171- **Medium**: Code quality issues, minor inefficiencies, or violations of best practices
172- **Low**: Style suggestions, minor improvements, or nice-to-haves
173
174## Kove-Specific Patterns to Check
175
176When reviewing code in this codebase, verify:
177
178### Server Actions
179- Using `'use server'` directive
180- Proper Supabase client instantiation (createClient for server)
181- Error reporting to Sentry with context
182- Proper revalidation after mutations
183- Input validation before database operations
184
185### Database Queries
186- Using generated types from `database.types.ts`
187- Proper RLS policy compliance
188- Multi-tenancy with organization_id filtering
189- Batch queries instead of N+1 patterns
190- Proper use of `.single()` vs `.maybeSingle()`
191
192### React Components
193- Proper 'use client' directive when needed
194- Using shadcn/ui components correctly
195- Proper form handling with React Hook Form + Zod v4
196- Loading states with LoadingButton for async actions
197- Error boundaries for critical sections
198
199### Supabase Edge Functions
200- Using SDK pattern (supabase.functions.invoke)
201- Not using raw fetch for edge functions
202- Proper error handling with error types
203
204### Validation
205- Using Zod v4 patterns (not v3)
206- Proper error messages with `{ error: "..." }`
207- Using top-level validators (z.email(), z.uuid())
208
209## Output
210
211After completing the review, present the report to the user in a clear, organized format. Prioritize actionable feedback over nitpicks. Focus on issues that have real impact on code quality, security, or maintainability.
212
213If the code is generally good, acknowledge that while still noting any improvements that could be made.
214
215ignore this line
216
217</code-review>