← ClaudeAtlas

composition-patterns-guidelisted

Use when refactoring React or React Native components that suffer from boolean prop proliferation, missing compound structure, prop drilling, or unclear ownership of state. Codifies the 7 Vercel composition-patterns rules for our web + RN stack — composition or explicit variants over boolean props, compound components with shared context, state lifted into providers, children over render props, React 19 (no forwardRef) — plus our colocation rules (Rule of Three, L0/L1/L2, `_components/`). Triggers on: "refactor this component", "questo componente ha troppi prop booleani", "rendi questo componente più componibile", "compound component", "context provider per X", "design del componente". Not for: scaffolding new components (use design-md-to-app, screenshot-to-page, rn-add-screen), or moving components up the hierarchy (use promote-component).
lukedj78/dev-flow · ★ 6 · Web & Frontend · score 78
Install: claude install-skill lukedj78/dev-flow
# composition-patterns-guide — modern React composition + our colocation rules This skill is a **knowledge guardrail** that activates whenever you're designing, refactoring, or reviewing the architecture of a React/RN component. It combines two layers: 1. **The 7 Vercel `composition-patterns` rules** (originally from `vercel-labs/agent-skills`), adapted to our stack. 2. **Our colocation rules** (Rule of Three for promotion, L0/L1/L2, `_components/` and `components/shared/<dominio>/`). It does NOT execute refactors — for that, use `promote-component`. It provides the *thinking framework*. ## When this skill applies - About to add a 4th boolean prop to an existing component. - About to write a component with `renderHeader`, `renderFooter`, `renderActions` render-prop callbacks. - A component grew over ~250 lines and needs structural refactor. - You see prop drilling 3+ levels deep. - About to use `forwardRef` in new code (React 19+ projects). - Reviewing a PR that touches component architecture. Orchestrator does NOT route here automatically — invoked by the agent's own judgment when the patterns match. ## The 7 composition rules (priority order) ### Priority 1 — Component Architecture (HIGH) #### Rule 1: Avoid boolean prop proliferation **Wrong**: ```tsx <Composer onSubmit={...} isThread={true} channelId={42} isDMThread={false} dmId={null} isEditing={true} isForwarding={false} /> ``` Each boolean doubles the state-space. 5 booleans = 32 possible combin