/dev-flow:composition-patterns-guidefrom dev-flow
Provides a thinking framework for refactoring React/RN components with boolean prop proliferation, prop drilling, or unclear state ownership. Codifies Vercel composition patterns and colocation rules.
Ships in dev-flow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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:
composition-patterns rules (originally from vercel-labs/agent-skills), adapted to our stack._components/ and components/shared/<dominio>/).It does NOT execute refactors — for that, use promote-component. It provides the thinking framework.
renderHeader, renderFooter, renderActions render-prop callbacks.forwardRef in new code (React 19+ projects).Orchestrator does NOT route here automatically — invoked by the agent's own judgment when the patterns match.
Every rule below is about how to compose. What to compose is fixed by golden rule 3 (references/contracts.md §Golden rules): the primitives of the library meta.json#stack declares. Before writing a component, search components/ui/ (shadcn monorepo: packages/ui/src/components/; mobile: React Native / Expo core components and components/shared/) for a primitive that covers the pattern; if it is there, use it, and if two together cover it, compose them. Never hand-roll one the library ships, never import a second component library, never change a primitive beyond its cva variants and tokens. A compound component here is built from those primitives (Card, Tabs, Dialog…), never a parallel <Tabs.Root> of your own; a truly new primitive needs a recorded exception with its reason (ADR or meta.json#stack_config.primitive_exceptions).
The primitive renders the design. A compound component's parts are primitives too, so a Composer.Header is a CardHeader or an Item, not a div with rounded-xl border, and a Composer.Action is a Button, not a <button>. A raw element or a div/span whose classes redraw a Card, Badge, Alert or Separator is a golden-rule-3 violation even with no import: the lint rule design/no-handmade-ui reports it with the primitive to use, and on web projects with a Tailwind UI the write-time guard (scripts/guard/primitives-guard.mjs, a Claude Code hook) refuses the write. When a part must look different from the primitive, tune the primitive — a cva variant recorded first in DESIGN.md, the tokens it reads — never classes on the part that rebuild the look; when no primitive can render it without a fork, stop and ask the user. Pattern → primitive: design-md-to-app/references/primitives-first.md.
Wrong:
<Composer
onSubmit={...}
isThread={true}
channelId={42}
isDMThread={false}
dmId={null}
isEditing={true}
isForwarding={false}
/>
Each boolean doubles the state-space. 5 booleans = 32 possible combinations, most of which are invalid or untested.
Right (composition):
<Composer>
<Composer.Header />
<Composer.Input />
<Composer.ThreadField channelId={42} />
<Composer.EditActions />
<Composer.Footer onSubmit={...} />
</Composer>
The consumer composes the parts they need. No invalid states.
A complex component should expose subcomponents that share context, not a single API with N props.
Wrong:
function Card({ title, body, footer, showAvatar, avatarUrl }) {
return <div>...</div>;
}
Right:
function Card({ children }) {
return <div className="card">{children}</div>;
}
function CardHeader({ children }) { return <div className="card-header">{children}</div>; }
function CardBody({ children }) { return <div className="card-body">{children}</div>; }
Card.Header = CardHeader;
Card.Body = CardBody;
// usage:
<Card>
<Card.Header><Avatar src="..." /><h2>Title</h2></Card.Header>
<Card.Body>...</Card.Body>
</Card>
If the subcomponents share state (e.g., a Disclosure that opens/closes), wrap in a context provider.
A provider should expose { state, actions, meta } — a generic interface — not surface every state variable as a separate prop.
Wrong:
<DialogProvider isOpen={isOpen} setIsOpen={setIsOpen} title={title} setTitle={setTitle}>
Right:
<DialogProvider value={dialogStore}> {/* zustand/jotai/use-state hook returns {state, actions, meta} */}
Then consumers use useDialog() and get the same interface regardless of how the state is stored.
When siblings need to share state, move it into a provider that wraps both. Don't drill props through their parent.
{state, actions, meta} shapeThe provider's context value follows a predictable shape:
type CardContext = {
state: { isExpanded: boolean };
actions: { toggle: () => void };
meta: { id: string };
};
This makes contexts mockable in tests (mockContext({state: {...}, actions: {...}})) and substitutable in Storybook.
Wrong:
<DataTable renderHeader={() => <Header />} renderRow={(row) => <Row data={row} />} />
Right:
<DataTable>
<DataTable.Header />
{rows.map(r => <DataTable.Row key={r.id} data={r} />)}
</DataTable>
JSX as children is more readable, more compose-able, and supports tooling (highlighting, refactor, ref forwarding) better than render props.
For variants that change visual identity significantly, create explicit named exports:
// Instead of:
<Button variant="primary" size="lg">Save</Button>
<Button variant="ghost" size="sm">Cancel</Button>
// Consider:
<PrimaryButton>Save</PrimaryButton>
<GhostButton size="sm">Cancel</GhostButton>
⚠️ Caveat: shadcn / Radix use variant props heavily (via cva) and that's idiomatic in those libraries. The "explicit variants" rule applies more to application-level components than primitives.
In React 19, ref is a normal prop. Don't use forwardRef for new code. (The snippets below are the shape of a primitive inside components/ui/ — the one place a raw <button> belongs; application code imports that Button.)
Wrong:
const Button = forwardRef<HTMLButtonElement, Props>((props, ref) => (
<button ref={ref} {...props} />
));
Right:
function Button({ ref, ...props }: Props & { ref?: Ref<HTMLButtonElement> }) {
return <button ref={ref} {...props} />;
}
Same for use() instead of useContext():
const ctx = use(MyContext); // React 19+, supports conditional reads
Composition decisions above interact with the Server/Client split — get this wrong and a compound component either forces the whole tree client-side or fails to render at all:
useState/context for shared state (Rule 4/5) — mark it "use client". That does not force its subcomponents client-side too: a Server Component can still be passed as children into a Client Component's slot (e.g., <ClientProvider>{await ServerFetchedContent()}</ClientProvider> composed from a parent Server Component) — React keeps the Server-rendered subtree server-rendered even though the wrapping provider is a Client Component."use client" to a compound component just because one subcomponent needs interactivity. Push the directive down to the smallest leaf that actually needs it (the button, the toggle), not up to the compound root — this preserves rung-1 colocation and avoids client-bundling the whole component for one onClick.children-over-render-props (Rule 6) is also the standard way to keep a Server Component inside a Client Component's layout: the Client Component (e.g., a <Tabs> shell needing useState for the active tab) renders {children} it received from a Server Component parent, rather than importing and rendering Server-fetched content itself (a Client Component cannot import and render a Server Component directly — only receive one as a prop/children from above).references/colocation-rules.md)| Level | Path | Use case |
|---|---|---|
| L0 (default) | app/<route>/_components/<Name>.tsx | Used by 1 page only |
| L1 | app/(group)/_components/<Name>.tsx | Used by 2+ pages of same route group |
| L2 | components/shared/<dominio>/<Name>.tsx | Used by pages of multiple route groups |
| UI primitives | components/ui/<name>.tsx | shadcn/Base UI/MUI primitives |
| Theme system | components/theme/<name>.tsx | ThemeProvider, ModeToggle |
Rule of Three: stay at L0 until 3rd use, then promote. Use promote-component skill to automate.
<Card.Root> + <Card.Header> in NativeWind, no API difference.forwardRef issue (RN is React 19+ since 2024).store/ automatically: a Zustand store is for cross-feature state. Within a single feature, context + useState is correct.className prop. NativeWind v4 handles the compositions cleanly.renderHeader / renderFooter / renderXxx render props → suggest children or compound.useState then drilled through 3+ levels → suggest lifting to provider.forwardRef in React 19+ code → suggest plain ref prop.useContext in React 19+ for conditional access → suggest use().components/ui/ (a custom dropdown, modal, tabs, tooltip, skeleton) → golden rule 3: use or compose the primitive; a new one only as a recorded exception.composition-patterns skill: https://github.com/vercel-labs/agent-skills/tree/main/skills/composition-patternsdocs/superpowers/specs/2026-06-06-folder-structure-refactor.mdWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub lukedj78/dev-flow --plugin dev-flow57 skills in this plugin
/animated-iconsAdd a Motion-animated icon to a Next.js app from a shadcn registry instead of hand-animating an SVG. Two registries, picked from the project's icon set: **heroicons-animated** (316 icons, `shadcn add @heroicons-animated/<name>`) and **hugeicons-animated** (165 icons, `shadcn add @hugeicons-animated/<name>`, which also installs a shared `lib/use-icon-animation.ts`). Both MIT, both on the `motion` runtime, both copied into your repo as source. This skill owns the install plus the two things the raw components lack: a `prefers-reduced-motion` guard and timing aligned to the project motion tokens (`lib/motion/`). Use when the user says "animated icon", "animate this icon", "make the bell/heart/menu icon animate on hover", "aggiungi un'icona animata", or wants an icon micro-interaction. Refuses outside Next.js web — for React Native use `rn-animations-gestures`. Not for: static icons, a whole motion system (`transitions`), or installing the runtime itself (`module-add motion`)./app-securityCheck whether an app's own code can be attacked before it ships — vulnerable dependencies, secrets in the code and in git history, Next.js authorization gaps (Server Actions and route handlers without a session check, queries by id with no owner filter — IDOR), data over-exposure, secrets in public env vars, raw SQL — then read the flagged code against an OWASP checklist, with an opt-in dynamic level (Strix) that proves exploits against the app running locally. The fifth pre-deploy gate, beside compliance-audit, vercel-doctor, shadscan and launch-audit; reports and routes, never blocks. Triggers: "security review", "è sicura l'app?", "controllo di sicurezza prima del deploy", "IDOR", "secrets in the repo", "pentest". Not for: GDPR and legal (compliance-audit), UI quality (shadscan), cost (vercel-doctor), launch readiness (launch-audit), a review of one branch diff (Claude Code's /security-review), third-party registry code (registry-intake)./app-verificationGive a project a manual for proving its features on the real app, written once and kept true: `.claude/skills/verify-<app>/` with how to launch it until it is usable, a read-only doctor check, how to drive it with the repo's real selectors, what counts as proof and where it goes, how to stop only what it started — plus one feature file per PRD story, seeded from the wireframe screen inventory, and a headless-Chrome render probe (overflow, wrapped headings, text hidden under reduced motion). Two modes: create (scaffold, fill from the code, prove it live once, record `meta.json#verification`) and maintain (re-read every feature from source, drive them all live, fix the manual, report real regressions). Web, Expo and eve. Triggers: "verify the app", "prova che funziona", "verification skill", "come si avvia l'app per provarla", "maintain the verify skill", "il manuale di verifica è aggiornato?". Not for: writing tests (write-tests), UI audits (shadscan), security (app-security), deploying (vercel-deploy)./compliance-auditRun a GDPR + EU AI Act compliance audit on an existing dev-flow project (web / mobile / eve agent) and remediate what it finds. Two modes: Audit (scan the codebase and `meta.json#stack` against a 11-point risk register — DSAR, consent/cookies, EU data residency, retention and PII-scrubbing, AI-transparency Art.50, high-risk Annex III, sub-processors — into a report with severity, evidence and article mapping) and Remediate (apply the safe mechanical mitigations, flag the ones needing a legal decision, never deciding legal basis or high-risk for the user). A pre-deploy gate; run it any time. Triggers: "audit GDPR", "compliance check", "AI Act", "siamo conformi?", "DSAR / cancellazione account / cookie consent / data residency". Not for: the other pre-deploy gates (vercel-doctor, shadscan, launch-audit, app-security), legal advice or DPIA sign-off (a DPO confirms), building features, or writing the PRD (use prd-from-idea)./coss-uiSet up or extend a Next.js web app with Coss/UI — the official Cal.com design system, built on Base UI + Tailwind CSS v4 and installed through the shadcn CLI via the namespaced `@coss/*` registry. Two modes: Init (`shadcn init @coss/style` on a new project) and Add (pull `@coss/ui` primitives, single `@coss/<name>` components, or particles into an existing one). Sets `meta.json#stack.ui = "coss"`. Triggers: "usa Coss/UI", "coss.com/ui", "Cal.com design system", "aggiungi un componente Coss", "init @coss/style", "scaffold con Coss UI", or dev-flow routing when `stack.ui = "coss"`. Requires Tailwind CSS v4 and carries a mixed MIT/AGPLv3 license. Not for: writing the DESIGN.md (use figma-to-design-md / image-to-design-md), the generic Next.js scaffold (design-md-to-app owns it), backend modules (module-add), or React Native (RN uses NativeWind, not Coss)./data-fetchingRead data in a Next.js 16 App Router app the canonical way — async Server Components first, URL `searchParams` for filter state, `use()` + `<Suspense>` when a Client Component needs server data, Route Handlers + SWR/React Query only as a last resort. Server Actions are for mutations, never reads. Use when the user is about to load data via a Server Action, about to add `useEffect` to fetch, about to convert a page to `"use client"` for filter state, or pastes `useState + useEffect + fetch` in a Client Component. Also owns Next.js 16 Cache Components — `cacheComponents`, `use cache`, `cacheLife`, `revalidateTag`, `partialPrefetching`, Instant Navigation — and any question about caching, prefetching or navigation speed. Refuses outside Next.js 16 web. Not for: form persistence (`forms`), local UI state (`state-discipline`), React Native (`rn-data-fetching`), or mutations.