export const perf = {
    name: "perf",
    description: "Performance audit — N+1 queries, bundle size, missing pagination, unoptimized images",
    content: `Audit for common performance issues.

## 1. Database Query Analysis
Scan for N+1 query patterns:
- Loops that make database calls (for/forEach/map containing await supabase)
- Multiple sequential queries that could be joined
- Missing .select() specificity (selecting * when only needing 2 fields)
- Missing indexes (queries filtering on non-indexed columns)

For Supabase specifically:
- .single() calls that could fail on 0 or 2+ results
- Missing .limit() on potentially large result sets
- Realtime subscriptions on entire tables vs filtered

## 2. Missing Pagination
Find all data-fetching operations that:
- Return unbounded arrays
- Don't accept page/limit parameters
- Could return 1000+ rows

## 3. Bundle Size Analysis
- Check for large dependencies imported unnecessarily
- Identify dynamic imports that should be used (heavy components loaded on all pages)
- Find barrel imports that include unused code (import { x } from 'lodash' vs 'lodash/x')
- Check if next/dynamic or React.lazy is used for heavy components

## 4. Image Optimization
Scan for:
- Images not using next/image (or equivalent)
- Missing width/height props (causes layout shift)
- Large images served without srcset
- Images in public/ that should be optimized
- Missing blur placeholder for LCP images

## 5. API Response Size
Check API routes for:
- Returning more data than needed (full objects when only ID needed)
- Missing field selection
- No response compression
- Large payloads that should be paginated

## 6. Client-Side Performance
Scan components for:
- Heavy computations without useMemo
- Unnecessary re-renders (object/array literals in deps)
- Event handlers recreated on every render
- Missing key props on lists
- Expensive operations in render (should be in useEffect)

## 7. Caching Opportunities
Identify:
- Repeated identical API calls
- Data that changes rarely but is fetched frequently
- Missing revalidation strategies
- No ISR on mostly-static pages

## Output: PERF-AUDIT.md

### Critical Issues (will cause production problems)
- N+1 queries: X locations
- Unbounded queries: X locations

### High Impact Improvements
| Issue | Location | Impact | Fix |
|-------|----------|--------|-----|
| N+1 in user list | pages/users.tsx:45 | High | Use .in() query |

### Bundle Size
- Largest dependencies: [list]
- Candidates for dynamic import: [list]
- Unused imports: [list]

### Image Optimization
- X images not using next/image
- X images missing dimensions

### Recommended Actions (prioritized by impact)
1. Fix N+1 query in X
2. Add pagination to Y endpoint
3. Dynamic import Z component`
};
//# sourceMappingURL=perf.js.map