All skills
🖥️

Frontend Review

Best Practices

Comprehensive audit of your app's interface. Reviews how it's built, how fast it loads, accessibility, and file sizes. Helps catch the issues that make apps feel slow or bloated.

Skill prompt

Frontend Audit Skill

Perform a comprehensive audit of React and Next.js applications covering component architecture, performance, accessibility, state management, and framework-specific best practices.

1. Component Architecture

Component Size and Complexity:

bash
# Find large component files (over 300 lines)find . -name "*.tsx" -not -path "*/node_modules/*" | xargs wc -l | sort -rn | head -30
# Find components with excessive JSX return blocksgrep -rn "return\s*(" . --include="*.tsx" -l | while read f; do  count=$(grep -c "<" "$f" 2>/dev/null)  if [ "$count" -gt 100 ]; then    echo "$f: $count JSX elements"  fidone

Prop Drilling Detection:

bash
# Find components passing many props (potential prop drilling)grep -rn "props\.\|{.*,.*,.*,.*,.*}" . --include="*.tsx" | grep -v "node_modules" | head -30
# Find deeply nested prop passing (same prop name across multiple files)for prop in $(grep -roh '\b\w*Id\b' . --include="*.tsx" -h | sort | uniq -c | sort -rn | head -10 | awk '{print $2}'); do  echo "=== Prop: $prop ==="  grep -rn "$prop" . --include="*.tsx" --include="*.ts" | grep -v "node_modules" | head -5done

Single Responsibility Violations:

bash
# Find components with multiple useEffect hooks (may do too much)grep -rl "useEffect" . --include="*.tsx" | while read f; do  count=$(grep -c "useEffect" "$f")  if [ "$count" -gt 3 ]; then    echo "$f: $count useEffect calls"  fidone
# Find components mixing data fetching with UI logicgrep -rln "fetch\|axios\|useSWR\|useQuery" . --include="*.tsx" | while read f; do  if grep -q "return.*<" "$f"; then    echo "Mixed concerns: $f"  fidone

Colocation Check:

bash
# Find component directories missing colocated test filesfind . -name "*.tsx" -not -name "*.test.*" -not -name "*.spec.*" -not -path "*/node_modules/*" | while read f; do  dir=$(dirname "$f")  base=$(basename "$f" .tsx)  if [ ! -f "$dir/$base.test.tsx" ] && [ ! -f "$dir/$base.spec.tsx" ] && [ ! -f "$dir/__tests__/$base.test.tsx" ]; then    echo "Missing test: $f"  fidone

2. React Patterns

Hook Rules Violations:

bash
# Find hooks called conditionally (inside if/for/while blocks)grep -rn "if\s*(.*)\s*{" . --include="*.tsx" --include="*.ts" -A10 | grep "use[A-Z]\w*("
# Find hooks called after early returnsgrep -rn "return\s" . --include="*.tsx" -A20 | grep "use[A-Z]\w*("

Missing Dependency Arrays:

bash
# Find useEffect/useMemo/useCallback without dependency arraysgrep -rn "useEffect(\s*(" . --include="*.tsx" --include="*.ts" | grep -v "\[" | grep -v "node_modules"grep -rn "useMemo(\s*(" . --include="*.tsx" --include="*.ts" | grep -v "\[" | grep -v "node_modules"grep -rn "useCallback(\s*(" . --include="*.tsx" --include="*.ts" | grep -v "\[" | grep -v "node_modules"
# Find useEffect with empty dependency arrays that reference outer variablesgrep -rn "useEffect" . --include="*.tsx" -A10 | grep "\[\]" | head -20

Stale Closures and References:

bash
# Find state used inside setTimeout/setInterval without refsgrep -rn "setTimeout\|setInterval" . --include="*.tsx" --include="*.ts" -B5 -A5 | grep -v "node_modules"
# Find event handlers referencing state that may be stalegrep -rn "addEventListener" . --include="*.tsx" -A5 | grep "useState\|state\." | grep -v "node_modules"

Unnecessary Re-renders:

bash
# Find inline object/array creation in JSX props (causes re-renders)grep -rn 'style={{' . --include="*.tsx" | grep -v "node_modules"grep -rn '={{\s*\w' . --include="*.tsx" | grep -v "style=" | grep -v "node_modules" | head -20
# Find inline arrow functions in JSX event handlersgrep -rn 'on\w\+={() =>' . --include="*.tsx" | grep -v "node_modules" | head -20
# Find components creating new arrays/objects each rendergrep -rn "const.*=\s*\[" . --include="*.tsx" | grep -v "useState\|useMemo\|useRef" | grep -v "node_modules" | head -20

Missing Keys:

bash
# Find .map() calls in JSX that may lack proper keysgrep -rn "\.map(" . --include="*.tsx" -A3 | grep -v "key=" | grep "<" | grep -v "node_modules" | head -20

Direct DOM Manipulation:

bash
# Find direct DOM manipulation (anti-pattern in React)grep -rn "document\.getElementById\|document\.querySelector\|document\.getElement" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"grep -rn "\.innerHTML\|\.outerHTML\|\.insertAdjacentHTML" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"

3. Next.js Specifics

Server vs Client Components:

bash
# Find all 'use client' directivesgrep -rln "'use client'\|\"use client\"" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"
# Count ratio of client to server componentstotal=$(find . -name "*.tsx" -not -path "*/node_modules/*" | wc -l)client=$(grep -rln "'use client'" . --include="*.tsx" | grep -v "node_modules" | wc -l)echo "Total components: $total, Client components: $client, Server components: $((total - client))"
# Find 'use client' files that do not use any client featuresgrep -rln "'use client'" . --include="*.tsx" | grep -v "node_modules" | while read f; do  if ! grep -q "useState\|useEffect\|useRef\|useCallback\|useMemo\|useReducer\|useContext\|onClick\|onChange\|onSubmit\|onKeyDown\|addEventListener" "$f"; then    echo "Unnecessary 'use client': $f"  fidone

Route Organization:

bash
# Check for proper App Router structurefind . -path "*/app/*" -name "page.tsx" -not -path "*/node_modules/*" | sortfind . -path "*/app/*" -name "layout.tsx" -not -path "*/node_modules/*" | sort
# Check for missing loading/error/not-found boundariesfind . -path "*/app/*" -name "page.tsx" -not -path "*/node_modules/*" | while read f; do  dir=$(dirname "$f")  missing=""  [ ! -f "$dir/loading.tsx" ] && missing="$missing loading.tsx"  [ ! -f "$dir/error.tsx" ] && missing="$missing error.tsx"  [ ! -f "$dir/not-found.tsx" ] && missing="$missing not-found.tsx"  if [ -n "$missing" ]; then    echo "$dir: missing$missing"  fidone

Metadata and SEO:

bash
# Find pages without metadata exportsfind . -path "*/app/*" -name "page.tsx" -not -path "*/node_modules/*" | while read f; do  if ! grep -q "export.*metadata\|generateMetadata" "$f"; then    layout=$(dirname "$f")/layout.tsx    if [ ! -f "$layout" ] || ! grep -q "export.*metadata\|generateMetadata" "$layout"; then      echo "Missing metadata: $f"    fi  fidone
# Check for missing OpenGraph imagesfind . -path "*/app/*" -name "opengraph-image.*" -not -path "*/node_modules/*" | head -10

Image Component Usage:

bash
# Find <img> tags that should use next/imagegrep -rn "<img " . --include="*.tsx" --include="*.jsx" | grep -v "node_modules" | grep -v "next/image"
# Find next/image without width/height or fillgrep -rn "<Image" . --include="*.tsx" -A5 | grep -v "width=\|height=\|fill" | grep "<Image" | grep -v "node_modules"
# Find images without alt textgrep -rn "<Image\|<img" . --include="*.tsx" | grep -v "alt=" | grep -v "node_modules"

Font Optimization:

bash
# Check for Google Fonts loaded via <link> instead of next/fontgrep -rn "fonts.googleapis.com\|fonts.gstatic.com" . --include="*.tsx" --include="*.html" --include="*.ts" | grep -v "node_modules"
# Verify next/font usagegrep -rn "next/font" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"

4. State Management

Prop Drilling That Should Be Context or Store:

bash
# Find props passed through 3+ component levels (same prop name in parent-child chain)grep -rn "interface.*Props" . --include="*.tsx" --include="*.ts" -A20 | grep -v "node_modules" | grep ":\s*\w" | awk -F: '{print $NF}' | sort | uniq -c | sort -rn | head -20
# Find components receiving more than 8 propsgrep -rn "interface.*Props" . --include="*.tsx" -A30 | grep -v "node_modules" | grep "}" -m1 | head -20

Oversized Context Causing Re-renders:

bash
# Find large context providers (many values bundled together)grep -rn "createContext\|React\.createContext" . --include="*.tsx" --include="*.ts" -l | grep -v "node_modules" | while read f; do  echo "=== $f ==="  grep -A30 "Provider value=" "$f" | head -35done
# Find contexts without value splittinggrep -rn "Provider value={{" . --include="*.tsx" | grep -v "node_modules"

Client State That Should Be Server State:

bash
# Find useState for data that looks like it should be fetched server-sidegrep -rn "useState.*\[\])\|useState.*null)" . --include="*.tsx" | grep -v "node_modules" -A3 | grep "fetch\|axios\|api"
# Find client-side data fetching in components that could be Server Componentsgrep -rln "useEffect" . --include="*.tsx" | grep -v "node_modules" | while read f; do  if grep -q "fetch\|axios" "$f" && ! grep -q "'use client'" "$f"; then    echo "Fetch in effect without 'use client': $f"  fidone

URL State Underuse:

bash
# Find filter/sort/search state stored in useState instead of URL paramsgrep -rn "useState.*filter\|useState.*sort\|useState.*search\|useState.*query\|useState.*page\b\|useState.*tab" . --include="*.tsx" -i | grep -v "node_modules"
# Check for missing useSearchParams usagegrep -rln "useSearchParams" . --include="*.tsx" --include="*.ts" | grep -v "node_modules" | wc -l

5. Performance

Missing Memoization Where Measurably Needed:

bash
# Find expensive computations in render without useMemogrep -rn "\.filter(\|\.sort(\|\.reduce(\|\.map(" . --include="*.tsx" | grep -v "useMemo\|useCallback" | grep -v "node_modules" | head -20
# Find components receiving object/array props without React.memogrep -rn "export default function\|export function\|export const" . --include="*.tsx" | grep -v "React\.memo\|memo(" | grep -v "node_modules" | head -20
# Find large list renders without virtualizationgrep -rn "\.map(" . --include="*.tsx" -B5 | grep "items\|list\|data\|results\|rows" | grep -v "node_modules" | head -20

Missing Suspense Boundaries:

bash
# Find lazy-loaded components without Suspense wrappersgrep -rn "React\.lazy\|lazy(" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"grep -rn "<Suspense" . --include="*.tsx" | grep -v "node_modules"
# Compare countslazy_count=$(grep -rn "React\.lazy\|lazy(" . --include="*.tsx" --include="*.ts" | grep -v "node_modules" | wc -l)suspense_count=$(grep -rn "<Suspense" . --include="*.tsx" | grep -v "node_modules" | wc -l)echo "Lazy components: $lazy_count, Suspense boundaries: $suspense_count"

Missing Lazy Loading:

bash
# Find heavy components imported statically that could be lazy loadedgrep -rn "import.*Modal\|import.*Dialog\|import.*Drawer\|import.*Chart\|import.*Editor\|import.*Map" . --include="*.tsx" | grep -v "lazy\|dynamic" | grep -v "node_modules"
# Check for next/dynamic usagegrep -rn "next/dynamic" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"

Excessive Client-Side JavaScript:

bash
# Find large client component filesgrep -rln "'use client'" . --include="*.tsx" | grep -v "node_modules" | while read f; do  lines=$(wc -l < "$f")  if [ "$lines" -gt 200 ]; then    echo "$f: $lines lines"  fidone
# Check for heavy libraries imported in client componentsgrep -rln "'use client'" . --include="*.tsx" | grep -v "node_modules" | while read f; do  if grep -q "import.*moment\|import.*lodash\b\|import.*d3\b\|import.*chart" "$f"; then    echo "Heavy import in client component: $f"  fidone

6. Styling

Inconsistent Styling Patterns:

bash
# Detect mixed styling approachescss_modules=$(find . -name "*.module.css" -o -name "*.module.scss" | grep -v "node_modules" | wc -l)tailwind=$(grep -rln "className=\".*\(flex\|grid\|p-\|m-\|text-\|bg-\)" . --include="*.tsx" | grep -v "node_modules" | wc -l)styled=$(grep -rln "styled\.\|styled(" . --include="*.tsx" --include="*.ts" | grep -v "node_modules" | wc -l)inline=$(grep -rn "style={{" . --include="*.tsx" | grep -v "node_modules" | wc -l)echo "CSS Modules: $css_modules, Tailwind: $tailwind, Styled Components: $styled, Inline styles: $inline"

Unused Styles:

bash
# Find CSS module classes that may be unusedfind . -name "*.module.css" -not -path "*/node_modules/*" | while read css; do  component="${css%.module.css}.tsx"  if [ -f "$component" ]; then    grep -oP '\.\K[a-zA-Z_][a-zA-Z0-9_-]*' "$css" | while read class; do      if ! grep -q "$class" "$component"; then        echo "Possibly unused class .$class in $css"      fi    done  fidone

!important Abuse:

bash
# Find !important declarationsgrep -rn "!important" . --include="*.css" --include="*.scss" --include="*.module.css" | grep -v "node_modules"

Magic Values:

bash
# Find hardcoded pixel values that should be design tokensgrep -rn "[0-9]\+px" . --include="*.css" --include="*.scss" --include="*.module.css" | grep -v "node_modules" | grep -v "0px\|1px" | head -30
# Find hardcoded colors that should be tokensgrep -rn "#[0-9a-fA-F]\{3,8\}" . --include="*.tsx" --include="*.css" --include="*.scss" | grep -v "node_modules" | head -20

7. Accessibility

Missing ARIA Labels:

bash
# Find interactive elements without accessible labelsgrep -rn "<button\|<a \|<input\|<select\|<textarea" . --include="*.tsx" | grep -v "aria-label\|aria-labelledby\|title=\|<button>.*<\/button>" | grep -v "node_modules" | head -20
# Find icon-only buttons without labelsgrep -rn "<button" . --include="*.tsx" -A3 | grep "Icon\|icon\|svg" | grep -v "aria-label\|sr-only\|visually-hidden" | grep -v "node_modules" | head -20

Non-Semantic HTML:

bash
# Find div/span used where semantic elements should begrep -rn '<div.*onClick\|<span.*onClick' . --include="*.tsx" | grep -v "role=" | grep -v "node_modules" | head -20
# Find missing landmark elementsgrep -rn "<header\|<main\|<nav\|<footer\|<aside\|<section\|<article" . --include="*.tsx" | grep -v "node_modules" | wc -l

Keyboard Navigation:

bash
# Find elements with onClick but no onKeyDown/onKeyUpgrep -rn "onClick" . --include="*.tsx" | grep -v "button\|<a \|<input\|<select\|Link\|Button\|onKeyDown\|onKeyUp\|role=" | grep -v "node_modules" | head -20
# Find custom components with tabIndex but missing keyboard handlersgrep -rn "tabIndex" . --include="*.tsx" | grep -v "onKeyDown\|onKeyUp" | grep -v "node_modules"

Color Contrast and Focus Management:

bash
# Find focus-related styles being removedgrep -rn "outline:\s*none\|outline:\s*0\|:focus.*outline" . --include="*.css" --include="*.scss" --include="*.tsx" | grep -v "focus-visible\|focus-within" | grep -v "node_modules"
# Find missing focus-visible stylesgrep -rn "focus-visible" . --include="*.css" --include="*.scss" --include="*.tsx" | grep -v "node_modules" | wc -l

8. Data Fetching

Waterfall Requests:

bash
# Find sequential awaits that could be parallelizedgrep -rn "await" . --include="*.tsx" --include="*.ts" -A1 | grep -v "node_modules" | grep -A1 "await" | grep "await" | head -20
# Find nested data fetching (fetch inside fetch callback)grep -rn "\.then(.*fetch\|await.*await" . --include="*.tsx" --include="*.ts" | grep -v "node_modules" | head -20

Missing Error and Loading States:

bash
# Find data fetching without error handlinggrep -rn "useQuery\|useSWR\|fetch(" . --include="*.tsx" | grep -v "error\|Error\|catch\|isError" | grep -v "node_modules" | head -20
# Find components with loading state but no error handlinggrep -rln "isLoading\|loading" . --include="*.tsx" | grep -v "node_modules" | while read f; do  if ! grep -q "error\|Error\|isError" "$f"; then    echo "Loading without error state: $f"  fidone

Over-Fetching:

bash
# Find API calls fetching all fields when only some are neededgrep -rn "fetch\|axios\.get\|useQuery" . --include="*.tsx" --include="*.ts" -A5 | grep -v "select\|fields\|pick\|pluck" | grep "\/api\/" | grep -v "node_modules" | head -20

Caching Strategy:

bash
# Check for missing cache/revalidation in Next.js fetchgrep -rn "fetch(" . --include="*.tsx" --include="*.ts" | grep -v "cache\|revalidate\|next:" | grep -v "node_modules" | grep -v "'use client'" | head -20
# Check React Query/SWR stale time configurationgrep -rn "staleTime\|cacheTime\|revalidateOnFocus\|dedupingInterval" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"

9. Bundle Analysis

Large Dependencies With Lighter Alternatives:

bash
# Check for heavy librariesgrep -rn "\"moment\"\|'moment'" package.jsongrep -rn "\"lodash\"\|'lodash'" package.jsongrep -rn "\"date-fns\"\|'date-fns'" package.jsongrep -rn "\"classnames\"\|'classnames'" package.json
# Check for full lodash import instead of specific functionsgrep -rn "import.*from ['\"]lodash['\"]" . --include="*.tsx" --include="*.ts" | grep -v "lodash/" | grep -v "node_modules"
# Check for moment.js (should use date-fns or dayjs)grep -rn "import.*moment\|require.*moment" . --include="*.tsx" --include="*.ts" | grep -v "node_modules"

Barrel File Import Costs:

bash
# Find barrel files (index.ts exporting everything)find . -name "index.ts" -not -path "*/node_modules/*" | while read f; do  exports=$(grep -c "export" "$f")  if [ "$exports" -gt 10 ]; then    echo "Large barrel file ($exports exports): $f"  fidone
# Find imports from barrel filesgrep -rn "from ['\"]\.\.\/\.\.\/" . --include="*.tsx" --include="*.ts" | grep -v "node_modules" | head -20

Dynamic Import Opportunities:

bash
# Find large static imports that could be dynamicgrep -rn "import.*from" . --include="*.tsx" --include="*.ts" | grep -v "node_modules\|type " | grep "Chart\|Editor\|Modal\|Map\|PDF\|Markdown\|CodeMirror\|Monaco" | grep -v "dynamic\|lazy"

10. Audit Report Format

Generate findings in this structure:

markdown
# Frontend Audit Report
## Summary
- Files audited: X- Critical issues: X- Warnings: X- Suggestions: X- Passing checks: X
## Critical (must fix)
| #   | Category      | Issue                     | File:Line                 | Impact                                || --- | ------------- | ------------------------- | ------------------------- | ------------------------------------- || 1   | Accessibility | Button missing aria-label | src/components/Nav.tsx:45 | Screen readers cannot identify action || 2   | Performance   | Unoptimized image in LCP  | src/app/page.tsx:12       | Core Web Vitals regression            |
## Warnings (should fix)
| #   | Category       | Issue                          | File:Line                 | Impact                 || --- | -------------- | ------------------------------ | ------------------------- | ---------------------- || 1   | React Patterns | Missing useEffect dependencies | src/hooks/useAuth.tsx:23  | Stale closure bug risk || 2   | Next.js        | Unnecessary 'use client'       | src/components/Card.tsx:1 | Larger client bundle   |
## Suggestions (nice to have)
| #   | Category | Issue                              | File:Line                    | Impact                   || --- | -------- | ---------------------------------- | ---------------------------- | ------------------------ || 1   | State    | Filter state should use URL params | src/app/products/page.tsx:18 | Non-shareable page state || 2   | Bundle   | Replace moment with dayjs          | package.json:15              | ~65KB bundle reduction   |
## Positive Observations
- Consistent use of next/image for optimized images- Good Suspense boundary coverage on route segments- Proper use of Server Components for data fetching
## Recommended Next Steps
1. Address all Critical accessibility issues first2. Add missing error/loading boundaries to route segments3. Audit 'use client' directives and convert eligible components to Server Components4. Set up bundle analysis in CI to prevent regressions

Severity Guidelines

  • Critical: Accessibility violations blocking users, security issues, data loss risks, broken functionality
  • Warning: Performance regressions, stale closures, missing error states, unnecessary client components, React anti-patterns
  • Suggestion: Bundle size optimizations, code organization improvements, pattern inconsistencies, missing but non-blocking best practices

When to Use This Skill

Use /frontend-audit when:

  • Reviewing a React or Next.js codebase for quality issues
  • Preparing for a production launch
  • Investigating rendering performance problems
  • Checking accessibility compliance
  • Evaluating component architecture before a refactor
  • Auditing bundle size and client-side JavaScript footprint
  • Verifying proper use of Next.js App Router patterns