Skip to content

avibebuilder/claude-prime / .claude/starter-skills/frontend-development

frontend-development

Verified

Use this skill for ANY work involving React, Next.js, TypeScript, or Tailwind in the browser layer. This includes building components and pages, but equally covers debugging and fixing frontend issues: CSS/Tailwind classes not applying, form validation behavior, hydration mismatches between server and client renders, styling bugs, layout shifts, and rendering problems. Also use for refactoring components (e.g., splitting Server vs Client Components), data fetching patterns, state management, bundle optimization, and frontend tooling. If the problem involves what users see or interact with in a web browser — whether building, fixing, or refactoring — use this skill. Not for backend APIs, databases, infrastructure, or DevOps.

references/react/patterns.md

View on GitHub
# React Patterns & Conventions

## Component Conventions

- **ALWAYS** use `function` syntax for components (not arrow functions)
- **ALWAYS** use named exports (no `export default` except Next.js pages/layouts)
- **NEVER** use `React.FC` — use explicit props typing: `function MyComponent({ title }: Props)`
- **ALWAYS** prefix handlers with `handle` (`handleClick`, `handleSubmit`)
- **ALWAYS** prefix callback props with `on` (`onClick`, `onSubmit`)

### Function vs Arrow Usage

| Use `function` | Use arrow `=>` |
|----------------|----------------|
| Components | Inline event handlers |
| Reused utility functions | Array methods (`.map`, `.filter`) |
| Complex event handlers | Callback arguments |
| Custom hooks | Small one-line utilities |

## Hook Conventions

- Custom hooks **MUST** return objects (not arrays)
  - Arrays break when consumers don't need all values
  - Objects allow destructuring only what's needed

```tsx
// WRONG
return [value, setValue, reset] as const;

// RIGHT
return { value, setValue, reset };
```

## React 19 Hooks

> Applies when React 19+ is detected. Reference: https://react.dev/blog/2024/12/05/react-19

**ALWAYS** prefer React 19 built-in hooks over manual implementations:

| Old Pattern | React 19 Replacement |
|-------------|---------------------|
| `useFormState` (react-dom) | `useActionState` |
| Manual pending state tracking | `useFormStatus` |
| Manual state + rollback logic | `useOptimistic` |
| `useEffect` for data fetching | `use()` with Suspense |

## Immutable Array Methods

**ALWAYS** prefer immutable array methods — `.sort()` mutates in place and breaks React state/props.

| Mutating (NEVER) | Immutable (ALWAYS) |
|-------------------|--------------------|
| `.sort()` | `.toSorted()` |
| `.reverse()` | `.toReversed()` |
| `.splice()` | `.toSpliced()` |
| direct index assignment | `.with(index, value)` |

## Context

> Reference: https://react.dev/reference/react/createContext

| Use Context | Use Zustand/Query |
|-------------|-------------------|
| Server-provided data (user session) | Client UI state |
| Theme/locale settings | Complex state logic |
| Rarely changing data | Frequently changing data |

- **ALWAYS** create a custom hook wrapper — never expose `useContext` directly
- **ALWAYS** throw error if used outside provider
- **ALWAYS** use `undefined` as default value (not `null`) for type safety
- **NEVER** store frequently changing data in Context (causes full subtree re-renders)

## Forms (RHF + Zod + shadcn)

> Setup guide: https://ui.shadcn.com/docs/components/form

**Required stack**: `react-hook-form` + `@hookform/resolvers` + `zod` + `@/components/ui/form` (shadcn)

- **MUST** initialize ALL fields in `defaultValues`
- **ALWAYS** use `FormMessage` for errors (never custom error display)
- **ALWAYS** spread `{...field}` on inputs when props match
- **NEVER** manually manage `id`/`htmlFor`/ARIA attributes

**Hierarchy (STRICT)**: `Form → form → FormField → FormItem → FormLabel/FormControl/FormMessage`

Context-based wiring depends on this exact nesting. Breaking the hierarchy breaks auto-wiring of labels, error messages, and accessibility attributes.

When input props don't match field props, map explicitly:

```tsx
<FormControl>
  <CustomSelect onSelectChange={field.onChange} customValue={field.value} />
</FormControl>
```

## Lazy Loading

- **ALWAYS** lazy load pages, modals, sheets, dialogs with `React.lazy`
- **ALWAYS** wrap lazy components in `Suspense`
- **ALWAYS** use named exports → `.then(m => ({ default: m.ComponentName }))`
- Use `lazyRetry` wrapper for pages if available in project (handles chunk load errors)
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 321kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall