<< All versions

Skill v1.0.0

currentLLM-judged scan90/100
opsrv/skills-agents/react-conventions
──Details
PublishedOctober 24, 2026 at 01:36 AM
Content Hashsha256:f9b6d2500942ab06...
Git SHA11261cb2d556
──Files
Files (1 file, 4.1 KB)
SKILL.md4.1 KBactive
SKILL.md · 116 lines · 4.1 KB

version: "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's CLAUDE.md first. If CLAUDE.md specifies 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) and useEffect discipline

Error Handling

See error-handling.md for rules on:

  • Error Boundary placement and granularity
  • Async try/catch in 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, DOMPurify required if approved
  • href / src with user input — validate protocol
  • For deep review: use agents/code-reviewer and skills/find-bugs

Async UI States

See async-ui-states.md for rules on:

  • Handling loading / error / empty / data states
  • useMutation pending 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 introducing React.createContext.

Composition Patterns

See composition-patterns.md for rules on:

  • Slot-like API (named ReactNode props for layout components)
  • Compound components (Tabs.Tab, Tabs.Panel) with scoped Context
  • children vs 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-engineer for 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 + filter over manual loops
  • Comments only for non-obvious logic
  • Custom hooks for any repeated logic
All versions