Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat: add react-patterns, design-review, and react-native skills
Jeremy Dawesdedae3b589e8
diff --git a/CLAUDE.md b/CLAUDE.mdindex 7c368fb1..a85b4eaf 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -16,7 +16,7 @@ Production workflow skills for Claude Code CLI. Each skill guides Claude through```claude-skills/-├── plugins/ # 11 plugins, 56 skills+├── plugins/ # 11 plugins, 59 skills│ ├── cloudflare/ # Cloudflare Workers, Hono, D1/Drizzle, Vite, TanStack Start│ │ └── skills/│ │ ├── cloudflare-worker-builder/@@ -30,12 +30,15 @@ claude-skills/│ ├── web-design/ # Local business SEO│ │ └── skills/│ │ └── seo-local-business/-│ ├── frontend/ # Tailwind v4 + shadcn/ui + landing pages + showcases+│ ├── frontend/ # Tailwind v4 + shadcn/ui + landing pages + showcases + React│ │ └── skills/│ │ ├── tailwind-theme-builder/│ │ ├── shadcn-ui/│ │ ├── landing-page/-│ │ └── product-showcase/+│ │ ├── product-showcase/+│ │ ├── react-patterns/+│ │ ├── design-review/+│ │ └── react-native/│ ├── design-assets/ # Colour palettes, favicons, icons, image processing, AI images│ │ └── skills/│ │ ├── color-palette/diff --git a/README.md b/README.mdindex 77831a45..4e4dfe7a 100644--- a/README.md+++ b/README.md@@ -4,7 +4,7 @@Production workflow skills for [Claude Code](https://claude.com/claude-code). Each skill guides Claude through a recipe to produce tangible output — scaffolded projects, generated assets, professional documents, deployed services.-11 plugins. 56 skills. Every one produces something.+11 plugins. 59 skills. Every one produces something.## Quick Start@@ -34,7 +34,7 @@ Then just ask Claude what you need — installed skills trigger automatically fr| Plugin | Skills | What it does ||--------|--------|-------------|-| **frontend** | tailwind-theme-builder, shadcn-ui, landing-page, product-showcase | Tailwind v4 theming with CSS variables + dark mode, shadcn/ui component installation and customisation, single-file landing pages, app showcase sites from real screenshots |+| **frontend** | tailwind-theme-builder, shadcn-ui, landing-page, product-showcase, react-patterns, design-review, react-native | Tailwind v4 theming, shadcn/ui, landing pages, app showcases, React 19 performance/composition patterns, visual design quality review, React Native + Expo mobile patterns || **design-assets** | color-palette, favicon-gen, icon-set-generator, image-processing, ai-image-generator | Accessible colour palettes from a single hex, favicon packages, custom SVG icon sets, image resize/convert/optimise, AI image generation (Gemini/GPT) || **web-design** | seo-local-business | Local business SEO: JSON-LD schema, meta tags, robots.txt, sitemap.xml |@@ -53,7 +53,7 @@ Then just ask Claude what you need — installed skills trigger automatically fr| **integrations** | gws-setup, gws-install, google-chat-messages, google-apps-script, elevenlabs-agents, mcp-builder, nemoclaw-setup, parcel-tracking | Google Workspace MCP setup, Google Chat webhooks, Apps Script automation, ElevenLabs voice agents, MCP server building, NVIDIA NemoClaw agent platform setup, Australian parcel tracking via Gmail || **basalt** | basalt-cortex | Mine knowledge from Gmail, Chat, Slack, Drive, local files, MCP, web into an Obsidian-compatible vault (~/.cortex/) |-## All 56 Skills+## All 59 Skills<details><summary>Full skill list with trigger phrases</summary>@@ -73,6 +73,9 @@ Then just ask Claude what you need — installed skills trigger automatically fr| `shadcn-ui` | "shadcn", "install components" || `landing-page` | "landing page", "marketing page", "one-page site" || `product-showcase` | "showcase site", "product page", "show off the app" |+| `react-patterns` | "react patterns", "react performance", "reduce re-renders" |+| `design-review` | "design review", "does this look good", "visual review" |+| `react-native` | "react native", "expo", "mobile app" || `color-palette` | "colour palette", "color palette from hex" || `favicon-gen` | "favicon", "generate icons" || `icon-set-generator` | "icon set", "svg icons" |diff --git a/plugins/frontend/commands/design-review.md b/plugins/frontend/commands/design-review.mdnew file mode 100644index 00000000..6d5f1026--- /dev/null+++ b/plugins/frontend/commands/design-review.md@@ -0,0 +1,8 @@+---+description: Review visual design quality — layout, typography, spacing, colour, consistency+argument-hint: "[url]"+---++Load the `design-review` skill.++If $ARGUMENTS contains a URL, review that page. Otherwise check for a deployed URL or running dev server. Produces a design findings report with severity-ranked issues and fix recommendations.diff --git a/plugins/frontend/commands/react-native.md b/plugins/frontend/commands/react-native.mdnew file mode 100644index 00000000..3eca8df5--- /dev/null+++ b/plugins/frontend/commands/react-native.md@@ -0,0 +1,13 @@+---+description: React Native and Expo patterns for building performant mobile apps+argument-hint: "[file-path|setup|review]"+---++Load the `react-native` skill.++Parse $ARGUMENTS:+- File path → review the file against React Native patterns+- `setup` → guide through new Expo project setup+- `review` → review the current project's mobile code++Examples: `/react-native src/screens/Home.tsx`, `/react-native setup`, `/react-native review`diff --git a/plugins/frontend/commands/react-patterns.md b/plugins/frontend/commands/react-patterns.mdnew file mode 100644index 00000000..fe713eb0--- /dev/null+++ b/plugins/frontend/commands/react-patterns.md@@ -0,0 +1,8 @@+---+description: Review React code for performance and composition patterns — 50+ rules ranked by impact+argument-hint: "[file-or-component-path]"+---++Load the `react-patterns` skill.++If $ARGUMENTS contains a file path, review it against the patterns in priority order. Otherwise review the current project's React code starting from the most critical categories.diff --git a/plugins/frontend/skills/design-review/SKILL.md b/plugins/frontend/skills/design-review/SKILL.mdnew file mode 100644index 00000000..afbd0cad--- /dev/null+++ b/plugins/frontend/skills/design-review/SKILL.md@@ -0,0 +1,154 @@+---+name: design-review+description: "Review a web app or page for visual design quality — layout, typography, spacing, colour, hierarchy, consistency, interaction patterns, and responsive behaviour. Not a UX audit (that checks usability) — this checks whether it looks professional and polished. Produces a design findings report with screenshots. Triggers: 'design review', 'does this look good', 'review the design', 'check the layout', 'is this polished', 'visual review', 'design audit', 'make it look better', 'it looks off'."+compatibility: claude-code-only+---++# Design Review++Review a web app or page for visual design quality. This is not a UX audit (usability, workflow, friction) — this checks whether the design is **professional, consistent, and polished**.++The goal: would a design-conscious person look at this and think "this is well made" or "this looks like a developer designed it"?++## When to Use++- Before showing something to a client or team+- When something "looks off" but you can't pinpoint why+- After building a feature, before calling it done+- Periodic quality check on a shipped product+- After a UX audit — this is the visual companion++## Browser Tool Detection++Same as ux-audit — Chrome MCP, Playwright MCP, or playwright-cli.++## URL Resolution++Same as ux-audit — prefer deployed/live over localhost.++## What to Check++### 1. Layout and Spacing++| Check | Good | Bad |+|-------|------|-----|+| **Consistent spacing** | Same gap between all cards in a grid, same padding in all sections | Some cards have 16px gap, others 24px. Header padding differs from body |+| **Alignment** | Left edges of content align vertically across sections | Heading starts at one indent, body text at another, cards at a third |+| **Breathing room** | Generous whitespace around content, elements don't feel cramped | Text touching container edges, buttons crowded against inputs |+| **Grid discipline** | Content follows a clear column grid | Elements placed freely, no underlying structure |+| **Responsive proportions** | Sidebar/content ratio looks intentional at every width | Sidebar takes 50% on tablet, content is squeezed |+| **Vertical rhythm** | Consistent vertical spacing pattern (e.g. 8px/16px/24px/32px scale) | Random spacing: 13px here, 27px there, 8px somewhere else |++### 2. Typography++| Check | Good | Bad |+|-------|------|-----|+| **Hierarchy** | Clear visual difference between h1 → h2 → h3 → body | Headings and body text look the same size/weight |+| **Line length** | Body text 50-75 characters per line | Full-width text running 150+ characters — hard to read |+| **Line height** | Body text 1.5-1.7, headings 1.1-1.3 | Cramped text or excessive line height |+| **Font sizes** | Consistent scale (e.g. 14/16/20/24/32) | Random sizes: 15px, 17px, 22px with no relationship |+| **Weight usage** | Regular for body, medium for labels, semibold for headings, bold sparingly | Everything bold, or everything regular with no hierarchy |+| **Truncation** | Long text truncates with ellipsis, title attribute shows full text | Text overflows container, wraps awkwardly, or is cut off without ellipsis |++### 3. Colour and Contrast++| Check | Good | Bad |+|-------|------|-----|+| **Semantic colour** | Using design tokens (bg-primary, text-muted-foreground) | Raw Tailwind colours (bg-blue-500, text-gray-300) |+| **Contrast ratio** | Text meets WCAG AA (4.5:1 for body, 3:1 for large text) | Light grey text on white, or dark text on dark backgrounds |+| **Colour consistency** | Same blue means the same thing everywhere (primary = action) | Blue means "clickable" in one place and "informational" in another |+| **Dark mode** | All elements visible, borders defined, no invisible text | Elements disappear, text becomes unreadable, images look wrong |+| **Status colours** | Green=success, yellow=warning, red=error consistently | Green used for both success and "active" with different meanings |+| **Colour overuse** | 2-3 colours + neutrals | Rainbow of colours with no clear hierarchy |++### 4. Visual Hierarchy++| Check | Good | Bad |+|-------|------|-----|+| **Primary action** | One clear CTA per page, visually dominant | Three equally styled buttons competing for attention |+| **Squint test** | Squinting at the page, the most important element stands out | Everything is the same visual weight — nothing draws the eye |+| **Progressive disclosure** | Most important info visible, details available on interaction | Everything shown at once — overwhelming |+| **Grouping** | Related items are visually grouped (proximity, borders, backgrounds) | Related items scattered, unrelated items touching |+| **Negative space** | Intentional empty space that frames content | Empty space that looks accidental (uneven, trapped white space) |++### 5. Component Consistency++| Check | Good | Bad |+|-------|------|-----|+| **Button styles** | One primary style, one secondary, one destructive — used consistently | 5 different button styles across the app |+| **Card styles** | All cards have the same border-radius, shadow, padding | Some cards rounded, some sharp, some with shadows, some without |+| **Form inputs** | All inputs same height, same border style, same focus ring | Mix of heights, border styles, focus behaviours |+| **Icon style** | One icon family (Lucide, Heroicons), consistent size and stroke | Mixed icon families, different sizes, some filled some outlined |+| **Border radius** | Consistent radius scale (e.g. 4px inputs, 8px cards, 12px modals) | Random radius values: 3px, 7px, 10px, 16px |+| **Shadow** | One or two shadow levels used consistently | Every component has a different shadow depth |++### 6. Interaction Design++| Check | Good | Bad |+|-------|------|-----|+| **Hover states** | Buttons, links, and clickable cards change on hover | No hover feedback — user unsure what's clickable |+| **Focus states** | Keyboard focus visible on all interactive elements | Focus ring missing or invisible against background |+| **Active states** | Nav items, tabs, sidebar links show current selection | Active item looks the same as inactive |+| **Transitions** | Subtle transitions on hover/focus (150-200ms ease) | No transitions (jarring) or slow transitions (laggy) |+| **Loading indicators** | Skeleton screens or spinners during async operations | Content pops in without warning, layout shifts |+| **Disabled states** | Disabled elements are visually muted, cursor changes | Disabled buttons look clickable, no cursor change |++### 7. Responsive Quality++| Check | Good | Bad |+|-------|------|-----|+| **Mobile nav** | Clean hamburger/sheet menu, easy to tap | Desktop nav squished into mobile, tiny tap targets |+| **Image scaling** | Images fill containers proportionally | Images stretched, cropped badly, or overflowing |+| **Table responsiveness** | Horizontal scroll on mobile, or stack to cards | Table wider than screen with no way to see columns |+| **Touch targets** | At least 44x44px on mobile | Tiny links, close buttons, checkboxes |+| **Tablet** | Layout works at 768px (not just desktop and phone) | Layout breaks at tablet widths, awkward gaps |++## Severity Guide++| Level | Meaning | Example |+|-------|---------|---------|+| **High** | Looks broken or unprofessional | Invisible text in dark mode, buttons different heights inline |+| **Medium** | Looks unpolished | Inconsistent spacing, mixed icon styles, truncation without ellipsis |+| **Low** | Nitpick | 1-2px alignment, slightly different border-radius, shadow too strong |++## Output++Write findings to `.jez/artifacts/design-review.md`:++```markdown+# Design Review: [App Name]+**Date**: YYYY-MM-DD+**URL**: [url]++## Overall Impression+[1-2 sentences — professional / unpolished / inconsistent / clean]++## Findings++### High+- **[issue]** at [page/component] — [what's wrong] → [fix]++### Medium+- **[issue]** at [page/component] — [what's wrong] → [fix]++### Low+- **[issue]** — [description]++## What Looks Good+[Patterns that are well-executed and should be preserved]++## Top 3 Fixes+1. [highest visual impact change]+2. [second]+3. [third]+```++Take screenshots of findings where the issue is visual (most of them).++## Tips++- Check dark mode AND light mode — most issues appear in one but not the other+- The squint test is the fastest way to find hierarchy problems+- Component inconsistency is the most common issue in dev-built UIs+- "Looks off" usually means spacing — check margins and padding first+- If you can't identify the issue, compare to a well-designed app in the same categorydiff --git a/plugins/frontend/skills/react-native/SKILL.md b/plugins/frontend/skills/react-native/SKILL.mdnew file mode 100644index 00000000..25e44687--- /dev/null+++ b/plugins/frontend/skills/react-native/SKILL.md@@ -0,0 +1,182 @@+---+name: react-native+description: "React Native and Expo patterns for building performant mobile apps. Covers list performance, animations with Reanimated, navigation, UI patterns, state management, platform-specific code, and Expo workflows. Use when building or reviewing React Native code. Triggers: 'react native', 'expo', 'mobile app', 'react native performance', 'flatlist', 'reanimated', 'expo router', 'mobile development', 'ios app', 'android app'."+compatibility: claude-code-only+allowed-tools:+ - Read+ - Write+ - Edit+ - Glob+ - Grep+ - Bash+---++# React Native Patterns++Performance and architecture patterns for React Native + Expo apps. Rules ranked by impact — fix CRITICAL before touching MEDIUM.++This is a starting point. The skill will grow as you build more mobile apps.++## When to Apply++- Building new React Native or Expo apps+- Optimising list and scroll performance+- Implementing animations+- Reviewing mobile code for performance issues+- Setting up a new Expo project++## 1. List Performance (CRITICAL)++Lists are the #1 performance issue in React Native. A janky scroll kills the entire app experience.++| Pattern | Problem | Fix |+|---------|---------|-----|+| **ScrollView for data** | `<ScrollView>` renders all items at once | Use `<FlatList>` or `<FlashList>` — virtualised, only renders visible items |+| **Missing keyExtractor** | FlatList without `keyExtractor` → unnecessary re-renders | `keyExtractor={(item) => item.id}` — stable unique key per item |+| **Complex renderItem** | Expensive component in renderItem re-renders on every scroll | Wrap in `React.memo`, extract to separate component |+| **Inline functions in renderItem** | `renderItem={({ item }) => <Row onPress={() => nav(item.id)} />}` | Extract handler: `const handlePress = useCallback(...)` |+| **No getItemLayout** | FlatList measures every item on scroll (expensive) | Provide `getItemLayout` for fixed-height items: `(data, index) => ({ length: 80, offset: 80 * index, index })` |+| **FlashList** | FlatList is good, FlashList is better for large lists | `@shopify/flash-list` — drop-in replacement, recycling architecture |+| **Large images in lists** | Full-res images decoded on main thread | Use `expo-image` with placeholder + transition, specify dimensions |++### FlatList Checklist++Every FlatList should have:+```tsx+<FlatList+ data={items}+ keyExtractor={(item) => item.id}+ renderItem={renderItem} // Memoised component+ getItemLayout={getItemLayout} // If items are fixed height+ initialNumToRender={10} // Don't render 100 items on mount+ maxToRenderPerBatch={10} // Batch size for off-screen rendering+ windowSize={5} // How many screens to keep in memory+ removeClippedSubviews={true} // Unmount off-screen items (Android)+/>+```++## 2. Animations (HIGH)++Native animations run on the UI thread. JS animations block the JS thread and cause jank.++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Animated API for complex animations** | `Animated` runs on JS thread, blocks interactions | Use `react-native-reanimated` — runs on UI thread |+| **Layout animation** | Item appears/disappears with no transition | `LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)` |+| **Shared element transitions** | Navigate between screens, element teleports | `react-native-reanimated` shared transitions or `expo-router` shared elements |+| **Gesture + animation** | Drag/swipe feels laggy | `react-native-gesture-handler` + `reanimated` worklets — all on UI thread |+| **Measuring layout** | `onLayout` fires too late, causes flash | Use `useAnimatedStyle` with shared values for instant response |++### Reanimated Basics++```tsx+import Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated';++function AnimatedBox() {+ const offset = useSharedValue(0);+ const style = useAnimatedStyle(() => ({+ transform: [{ translateX: withSpring(offset.value) }],+ }));++ return (+ <GestureDetector gesture={panGesture}>+ <Animated.View style={[styles.box, style]} />+ </GestureDetector>+ );+}+```++## 3. Navigation (HIGH)++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Expo Router** | File-based routing (like Next.js) for React Native | `app/` directory with `_layout.tsx` files. Preferred for new Expo projects. |+| **Heavy screens on stack** | Every screen stays mounted in the stack | Use `unmountOnBlur: true` for screens that don't need to persist |+| **Deep linking** | App doesn't respond to URLs | Expo Router handles this automatically. For bare RN: `Linking` API config |+| **Tab badge updates** | Badge count doesn't update when tab is focused | Use `useIsFocused()` or refetch on focus: `useFocusEffect(useCallback(...))` |+| **Navigation state persistence** | App loses position on background/kill | `onStateChange` + `initialState` with AsyncStorage |++### Expo Router Structure++```+app/+├── _layout.tsx # Root layout (tab navigator)+├── index.tsx # Home tab+├── (tabs)/+│ ├── _layout.tsx # Tab bar config+│ ├── home.tsx+│ ├── search.tsx+│ └── profile.tsx+├── [id].tsx # Dynamic route+└── modal.tsx # Modal route+```++## 4. UI Patterns (HIGH)++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Safe area** | Content under notch or home indicator | `<SafeAreaView>` or `useSafeAreaInsets()` from `react-native-safe-area-context` |+| **Keyboard avoidance** | Form fields hidden behind keyboard | `<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>` |+| **Platform-specific code** | iOS and Android need different behaviour | `Platform.select({ ios: ..., android: ... })` or `.ios.tsx` / `.android.tsx` files |+| **Status bar** | Status bar overlaps content or wrong colour | `<StatusBar style="auto" />` from `expo-status-bar` in root layout |+| **Touch targets** | Buttons too small to tap | Minimum 44x44pt. Use `hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}` |+| **Haptic feedback** | Taps feel dead | `expo-haptics` — `Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light)` on important actions |++## 5. Images and Media (MEDIUM)++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Image component** | `<Image>` from react-native is basic | Use `expo-image` — caching, placeholder, transition, blurhash |+| **Remote images without dimensions** | Layout shift when image loads | Always specify `width` and `height`, or use `aspectRatio` |+| **Large images** | OOM crashes on Android | Resize server-side or use `expo-image` which handles memory |+| **SVG** | SVG support isn't native | `react-native-svg` + `react-native-svg-transformer` for SVG imports |+| **Video** | Video playback | `expo-av` or `expo-video` (newer API) |++## 6. State and Data (MEDIUM)++| Pattern | Problem | Fix |+|---------|---------|-----|+| **AsyncStorage for complex data** | JSON parse/stringify on every read | Use MMKV (`react-native-mmkv`) — 30x faster than AsyncStorage |+| **Global state** | Redux/MobX boilerplate for simple state | Zustand — minimal, works great with React Native |+| **Server state** | Manual fetch + loading + error + cache | TanStack Query — same as web, works in React Native |+| **Offline first** | App unusable without network | TanStack Query `persistQueryClient` + MMKV, or WatermelonDB for complex offline |+| **Deep state updates** | Spread operator hell for nested objects | Immer via Zustand: `set(produce(state => { state.user.name = 'new' }))` |++## 7. Expo Workflow (MEDIUM)++| Pattern | When | How |+|---------|------|-----|+| **Development build** | Need native modules | `npx expo run:ios` or `eas build --profile development` |+| **Expo Go** | Quick prototyping, no native modules | `npx expo start` — scan QR code |+| **EAS Build** | CI/CD, app store builds | `eas build --platform ios --profile production` |+| **EAS Update** | Hot fix without app store review | `eas update --branch production --message "Fix bug"` |+| **Config plugins** | Modify native config without ejecting | `app.config.ts` with `expo-build-properties` or custom config plugin |+| **Environment variables** | Different configs per build | `eas.json` build profiles + `expo-constants` |++### New Project Setup++```bash+npx create-expo-app my-app --template tabs+cd my-app+npx expo install expo-image react-native-reanimated react-native-gesture-handler react-native-safe-area-context+```++## 8. Testing (LOW-MEDIUM)++| Tool | For | Setup |+|------|-----|-------|+| **Jest** | Unit tests, hook tests | Included with Expo by default |+| **React Native Testing Library** | Component tests | `@testing-library/react-native` |+| **Detox** | E2E tests on real devices/simulators | `detox` — Wix's testing framework |+| **Maestro** | E2E with YAML flows | `maestro test flow.yaml` — simpler than Detox |++## Common Gotchas++| Gotcha | Fix |+|--------|-----|+| Metro bundler cache | `npx expo start --clear` |+| Pod install issues (iOS) | `cd ios && pod install --repo-update` |+| Reanimated not working | Must be first import: `import 'react-native-reanimated'` in root |+| Expo SDK upgrade | `npx expo install --fix` after updating SDK version |+| Android build fails | Check `gradle.properties` for memory: `org.gradle.jvmargs=-Xmx4g` |+| iOS simulator slow | Use physical device for performance testing — simulator doesn't reflect real perf |diff --git a/plugins/frontend/skills/react-patterns/SKILL.md b/plugins/frontend/skills/react-patterns/SKILL.mdnew file mode 100644index 00000000..347d3821--- /dev/null+++ b/plugins/frontend/skills/react-patterns/SKILL.md@@ -0,0 +1,140 @@+---+name: react-patterns+description: "React 19 performance patterns and composition architecture for Vite + Cloudflare projects. 50+ rules ranked by impact — eliminating waterfalls, bundle optimisation, re-render prevention, composition over boolean props, server/client boundaries, and React 19 APIs. Use when writing, reviewing, or refactoring React components. Triggers: 'react patterns', 'react review', 'react performance', 'optimise components', 'react best practices', 'composition patterns', 'why is it slow', 'reduce re-renders', 'fix waterfall'."+compatibility: claude-code-only+allowed-tools:+ - Read+ - Glob+ - Grep+---++# React Patterns++Performance and composition patterns for React 19 + Vite + Cloudflare Workers projects. Use as a checklist when writing new components, a review guide when auditing existing code, or a refactoring playbook when something feels slow or tangled.++Rules are ranked by impact. Fix CRITICAL issues before touching MEDIUM ones.++## When to Apply++- Writing new React components or pages+- Reviewing code for performance issues+- Refactoring components with too many props or re-renders+- Debugging "why is this slow?" or "why does this re-render?"+- Building reusable component libraries+- Code review before merging++## 1. Eliminating Waterfalls (CRITICAL)++Sequential async calls where they could be parallel. The #1 performance killer.++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Await in sequence** | `const a = await getA(); const b = await getB();` | `const [a, b] = await Promise.all([getA(), getB()]);` |+| **Fetch in child** | Parent renders, then child fetches, then grandchild fetches | Hoist fetches to the highest common ancestor, pass data down |+| **Suspense cascade** | Multiple Suspense boundaries that resolve sequentially | One Suspense boundary wrapping all async siblings |+| **Await before branch** | `const data = await fetch(); if (condition) { use(data); }` | Move await inside the branch — don't fetch what you might not use |+| **Import then render** | `const Component = await import('./Heavy'); return <Component />` | Use `React.lazy()` + `<Suspense>` — renders fallback instantly |++**How to find them**: Search for `await` in components. Each `await` is a potential waterfall. If two awaits are independent, they should be parallel.++## 2. Bundle Size (CRITICAL)++Every KB the user downloads is a KB they wait for.++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Barrel imports** | `import { Button } from '@/components'` pulls the entire barrel file | `import { Button } from '@/components/ui/button'` — direct import |+| **No code splitting** | Heavy component loaded on every page | `React.lazy(() => import('./HeavyComponent'))` + `<Suspense>` |+| **Third-party at load** | Analytics/tracking loaded before the app renders | Load after hydration: `useEffect(() => { import('./analytics') }, [])` |+| **Full library import** | `import _ from 'lodash'` (70KB) | `import debounce from 'lodash/debounce'` (1KB) |+| **Lucide tree-shaking** | `import * as Icons from 'lucide-react'` (all icons) | Explicit map: `import { Home, Settings } from 'lucide-react'` |+| **Duplicate React** | Library bundles its own React → "Cannot read properties of null" | `resolve.dedupe: ['react', 'react-dom']` in vite.config.ts |++**How to find them**: `npx vite-bundle-visualizer` — shows what's in your bundle.++## 3. Composition Architecture (HIGH)++How you structure components matters more than how you optimise them.++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Boolean prop explosion** | `<Card isCompact isClickable showBorder hasIcon isLoading>` | Explicit variants: `<CompactCard>`, `<ClickableCard>` |+| **Compound components** | Complex component with 15 props | Split into `<Dialog>`, `<Dialog.Trigger>`, `<Dialog.Content>` with shared context |+| **renderX props** | `<Layout renderSidebar={...} renderHeader={...} renderFooter={...}>` | Use children + named slots: `<Layout><Sidebar /><Header /></Layout>` |+| **Lift state** | Sibling components can't share state | Move state to parent or context provider |+| **Provider implementation** | Consumer code knows about state management internals | Provider exposes interface `{ state, actions, meta }` — implementation hidden |+| **Inline components** | `function Parent() { function Child() { ... } return <Child /> }` | Define Child outside Parent — inline components remount on every render |++**The test**: If a component has more than 5 boolean props, it needs composition, not more props.++## 4. Re-render Prevention (MEDIUM)++Not all re-renders are bad. Only fix re-renders that cause visible jank or wasted computation.++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Default object/array props** | `function Foo({ items = [] })` → new array ref every render | Hoist: `const DEFAULT = []; function Foo({ items = DEFAULT })` |+| **Derived state in effect** | `useEffect(() => setFiltered(items.filter(...)), [items])` | Derive during render: `const filtered = useMemo(() => items.filter(...), [items])` |+| **Object dependency** | `useEffect(() => {...}, [config])` fires every render if config is `{}` | Use primitive deps: `useEffect(() => {...}, [config.id, config.type])` |+| **Subscribe to unused state** | Component reads `{ user, theme, settings }` but only uses `user` | Split context or use selector: `useSyncExternalStore` |+| **State for transient values** | `const [mouseX, setMouseX] = useState(0)` on mousemove | Use `useRef` for values that change frequently but don't need re-render |+| **Inline callback props** | `<Button onClick={() => doThing(id)} />` — new function every render | `useCallback` or functional setState: `<Button onClick={handleClick} />` |++**How to find them**: React DevTools Profiler → "Why did this render?" or `<React.StrictMode>` double-renders in dev.++## 5. React 19 Specifics (MEDIUM)++Patterns that changed or are new in React 19.++| Pattern | Old (React 18) | New (React 19) |+|---------|---------------|----------------|+| **Form state** | `useFormState` | `useActionState` — renamed |+| **Ref forwarding** | `forwardRef((props, ref) => ...)` | `function Component({ ref, ...props })` — ref is a regular prop |+| **Context** | `useContext(MyContext)` | `use(MyContext)` — works in conditionals and loops |+| **Pending UI** | Manual loading state | `useTransition` + `startTransition` for non-urgent updates |+| **Route-level lazy** | Works with `createBrowserRouter` only | Still true — `<Route lazy={...}>` is silently ignored with `<BrowserRouter>` |+| **Optimistic updates** | Manual state management | `useOptimistic` hook |+| **Metadata** | Helmet or manual `<head>` management | `<title>`, `<meta>`, `<link>` in component JSX — hoisted to `<head>` automatically |++## 6. Rendering Performance (MEDIUM)++| Pattern | Problem | Fix |+|---------|---------|-----|+| **Layout shift on load** | Content jumps when async data arrives | Skeleton screens matching final layout dimensions |+| **Animate SVG directly** | Janky SVG animation | Wrap in `<div>`, animate the div instead |+| **Large list rendering** | 1000+ items in a table/list | `@tanstack/react-virtual` for virtualised rendering |+| **content-visibility** | Long scrollable content renders everything upfront | `content-visibility: auto` on off-screen sections |+| **Conditional render with &&** | `{count && <Items />}` renders `0` when count is 0 | Use ternary: `{count > 0 ? <Items /> : null}` |++## 7. Data Fetching (MEDIUM)++| Pattern | Problem | Fix |+|---------|---------|-----|+| **No deduplication** | Same data fetched by 3 components | TanStack Query or SWR — automatic dedup + caching |+| **Fetch on mount** | `useEffect(() => { fetch(...) }, [])` — waterfalls, no caching, no dedup | TanStack Query: `useQuery({ queryKey: ['users'], queryFn: fetchUsers })` |+| **No optimistic update** | User clicks save, waits 2 seconds, then sees change | `useMutation` with `onMutate` for instant visual feedback |+| **Stale closure in interval** | `setInterval` captures stale state | `useRef` for the interval ID and current values |+| **Polling without cleanup** | `setInterval` in useEffect without `clearInterval` | Return cleanup: `useEffect(() => { const id = setInterval(...); return () => clearInterval(id); })` |++## 8. Vite + Cloudflare Specifics (MEDIUM)++| Pattern | Problem | Fix |+|---------|---------|-----|+| **`import.meta.env` in Node scripts** | Undefined — only works in Vite-processed files | Use `loadEnv()` from vite |+| **React duplicate instance** | Library bundles its own React | `resolve.dedupe` + `optimizeDeps.include` in vite.config.ts |+| **Radix Select empty string** | `<SelectItem value="">` throws | Use sentinel: `<SelectItem value="__any__">` |+| **React Hook Form null** | `{...field}` passes null to Input | Spread manually: `value={field.value ?? ''}` |+| **Env vars at edge** | `process.env` doesn't exist in Workers | Use `c.env` (Hono context) or `import.meta.env` (Vite build-time) |++## Using as a Review Checklist++When reviewing code, go through categories 1-3 (CRITICAL + HIGH) for every PR. Categories 4-8 only when performance is a concern.++```+/react-patterns [file or component path]+```++Read the file, check against rules in priority order, report findings as:+```+file:line — [rule] description of issue+```