Component API
FreeShape a React component's props around composition and a small variant set, not boolean soup.
Purpose
Keep generated components reusable without a prop for every visual tweak.
Procedure
--- name: component-api description: Shape a React component's props around composition and a small variant set, not boolean soup. ---
Component API
Purpose
Keep generated components reusable without a prop for every visual tweak.
Procedure
Before adding a component, search for an existing one that already does the job.
API rules:
- Required data is a required prop. Do not default a label to "Submit" if the caller always knows the label.
- Prefer children and slots over renderFoo props.
- Variants express a real difference (primary, quiet, danger). Do not add size or tone enums "for later".
- className may be forwarded for layout (margin, width) but the component owns its own colors, radius, and type.
- Refs forward only if a caller needs them. Do not add useEffect to sync props into state.
Accessibility:
- A control that navigates is a link. A control that acts is a button. Do not put an onClick on a div.
- Icon-only buttons have an accessible name.
File shape: one component per file, props type exported, no sample data inside the component. Do not generate a story file unless the repository already uses that format.
Example requests
1. Extract a button
Request: Extract the primary and quiet buttons into one component using Component API. Do not add sizes nobody uses. Expected: One component with two variants and no unused boolean props.
Dependencies
None. Work in the repository that is already open. Do not add packages unless the procedure names one.
Compatibility
This document follows the Agent Skills layout (a folder named component-api containing SKILL.md). Claude Code, Cursor, Codex, and Gemini CLI can load that file from the paths in the Skilling installation guide. GitHub Copilot does not load SKILL.md. Use the Copilot instructions copy, and narrow applyTo before you commit it.
Example prompts
Extract a button
Extract the primary and quiet buttons into one component using Component API. Do not add sizes nobody uses.
Expected: One component with two variants and no unused boolean props.
Choose the agent
This skill is installed for one agent at a time. Pick the section you are using.
Related
- Tailwind Discipline
Use the existing Tailwind tokens and scale. No arbitrary values, no copied utility salads.
- Interface Craft
Design a screen around one job, one primary action, and the empty, loading, and error states before any decoration.
- Form States
Build forms with labels, inline errors, pending submits, and no silent failure.
Reviews
No reviews yet.
Sign in to review.
Report a problem
Inaccurate steps, an unsafe instruction, or a licensing concern.
Sign in to report.