Skill v1.0.0
currentLLM-judged scan90/100version: "1.0.0" name: react-conventions description: Use when writing, reviewing, or refactoring React code. Defines project-specific component patterns, typing, state management, hooks, and code quality conventions.
React Conventions
Core principle: Explicit, readable components over clever abstractions.
Portability note: This skill defines universal React patterns. Specific library choices (state manager, form library, bundler, package manager) are project-specific — check the project'sCLAUDE.mdfirst. IfCLAUDE.mdspecifies a library, use it. If not, the recommendations below are sensible defaults — but always ask the user before installing.
Conventions
Components, TypeScript & File Structure
See component-patterns.md for rules on:
- Functional component structure (arrow functions +
export const) - Props typing and default values
- Directory layout, one entity per file, barrel exports policy
- Constants grouping by domain
Coding Style
See coding-style.md for rules on:
- Naming conventions (PascalCase, camelCase, UPPER_SNAKE_CASE, boolean prefixes)
- File naming by type
- Prettier config and ESLint plugins
- Import order
State Management & Hooks
See state-and-hooks.md for rules on:
- Local vs global state boundaries
- Server state management
- Custom hooks for logic extraction
- Memoization (
useMemo,useCallback) anduseEffectdiscipline
Error Handling
See error-handling.md for rules on:
- Error Boundary placement and granularity
- Async
try/catchin event handlers - Error states in UI (see also async-ui-states.md)
Approval required before adding Error Boundaries or restructuring error handling.
Forms
See forms.md for rules on:
- Form library usage (match what the project uses; ask if none present)
- Schema-based validation (
zod/yup) - Field-level errors, submit state, disabled button during submission
Approval required before installing a form library or changing form architecture.
Security
See security.md for rules on:
dangerouslySetInnerHTML— forbidden by default,DOMPurifyrequired if approvedhref/srcwith user input — validate protocol- For deep review: use
agents/code-reviewerandskills/find-bugs
Async UI States
See async-ui-states.md for rules on:
- Handling loading / error / empty / data states
useMutationpending and error states- Suspense — only if already adopted in the project
Context API
See context-api.md for rules on:
- When Context is appropriate (theme, auth, compound components)
- Provider + typed hook co-location pattern
- What NOT to use Context for (server state, high-frequency updates)
Approval required before introducingReact.createContext.
Composition Patterns
See composition-patterns.md for rules on:
- Slot-like API (named
ReactNodeprops for layout components) - Compound components (
Tabs.Tab,Tabs.Panel) with scoped Context childrenvs named props vs compound components decision table
Testing
Follow `skills/test-driven-development` -- no production code without a failing test first.
- Jest + React Testing Library for component behavior (not implementation details)
- E2E: Playwright for critical scenarios (by request)
- Unit tests for hooks and utilities
- Use
agents/test-engineerfor test generation
Red Flags
Agent MUST NOT do any of the following without explicit approval:
- Deviate from the agreed plan
- Make "nice to have" changes outside the scope
- Install packages not specified in the plan
- Configure or use a global state manager without confirmed need
Performance
See performance.md for rules on:
- Algorithmic complexity (Map/Set over nested loops)
- Derived state, memoization, large collections, inline objects
Code Quality
- Declarative style:
map+filterover manual loops - Comments only for non-obvious logic
- Custom hooks for any repeated logic