/new-component
Scaffold a new React component following project conventions.
Steps
Ask the user:
- Component name
- Which app:
flow-factoryorflow-global(or a shared package inpackages/) - Feature directory (e.g.,
app/orders/_lib/components/)
Before creating anything, search for something to reuse or extend. Hand-rolling a primitive that already exists is the most-flagged review defect. Search the full shared tier, not just one package:
packages/ui-toolkit/src/— primitives (Button, Alert, Link, inputs)packages/shared-utils/,packages/part-utils/and other domain*-utilspackages- any domain toolkit/UI package matching the feature (e.g.
part-toolkit,factory-execution-ui— list them withls packages/) - the target package's source directly — its
package.jsonexportsmap and thesrc/files it points to show what already exists. If a close match exists, extend or compose it instead of starting from scratch.
Create the component file:
- Add
'use client'directive only if it uses hooks, event handlers, or browser APIs - Import UI primitives from
@hadrian-mtv/ui-toolkit/* - Use
@hadrian-mtv/classname-variantsfor variant styling - Use
cnMergefrom@hadrian-mtv/ui-toolkitfor conditional classes - Use Tailwind design tokens (
surface-*,content-*,border-*) not hardcoded neutrals - Export with a named export (not default)
- Prefer composition over boolean-prop accretion. A handful of
isX/showY/hideZbooleans that combine into impossible states is a design smell — acceptchildrenor slot props (e.g.header,actions) so callers compose what they need.
- Add
Create a types file in
_lib/if the component has non-trivial propsCreate a co-located
.test.tsxby default. Skip it only if the user explicitly opts out. The test must assert rendered DOM or behavior — not that a helper returned a value:@testing-library/reactto render,@testing-library/user-eventfor interactions- Assert what the user sees: queried text/roles are present, the right state shows after an interaction. A test that renders without asserting anything is not a test.
- Reuse mocks from
@hadrian-mtv/vitest-utilswhere available
Gotchas
- flow-frontend has no per-package
SKILL.mdindexes. Read package sources (package.jsonexports and thesrc/files behind them) — don't assume index files exist.