react
React coding style and best practices.
When & Why to Use This Skill
This Claude skill enforces modern React coding standards and best practices to ensure high-quality, maintainable, and performant codebases. It focuses on React 19+ patterns, efficient DOM structures, and consistent naming conventions, helping developers avoid common pitfalls and technical debt.
Use Cases
- Automated Code Quality Audits: Use the skill to automatically review React components (.jsx/.tsx) for adherence to modern standards, such as using Fragments instead of unnecessary div wrappers.
- React 19 Migration and Refactoring: Assist in upgrading legacy code to utilize modern patterns like Server Actions, the 'use' hook for promises, and 'useFormStatus'.
- Standardizing Error Handling: Ensure consistent user feedback across the application by enforcing the use of toast notifications over console errors in catch blocks.
- Performance Optimization: Prevent 'over-optimization' by identifying and removing unnecessary useCallback and useMemo hooks where React's default rendering is sufficient.
- Enforcing Team Style Guides: Maintain a uniform codebase by automatically checking for PascalCase component naming, camelCase props, and the 'logic-first' component structure.
| name | react |
|---|---|
| description | React coding style and best practices. |
| pattern | \.(jsx|tsx)(\s|$) |
- Use
toast.error(error.message)in catch blocks. Noconsole.errorallowed! - Minimal DOM nesting. Use
<Fragment>or<>instead of useless<div>wrappers - Modern React 19+ patterns only (e.g.
usefor promises/context, Server Actions,useFormStatus) - Boolean props shorthand:
<Component prop />not<Component prop={true} /> - Component names in PascalCase, props in camelCase
- Logic first: Define hooks/state at the top, then return JSX. Keep components lean
- Prefer
onChangeoveruseEffectfor syncing state whenever possible - Map directly on components/fragments, don't wrap
items.mapin a stray<div> - Avoid
useCallback/useMemounless it's actually heavy. React is fast enough, don't be extra