Read ds.config.json at the repo root first; every branch below depends on it. If the repo has its own skills/<system>/SKILL.md (written in the foundations phase), its project rules add to these and never replace them. Apply everything below in full.
Component rules
Rules for every component in the new namespace. Each carries the failure it prevents, so an uncovered case is decided by extending the reasoning. Project specifics (paths, primitive library, reviewers, tool flags) come from ds.config.json; read it first.
Route by path
- File under
namespace(defaultsrc/next/): these rules. Legacy conventions (CSS-in-JS macros, Radix, old token names) do not exist here. - File under
legacyPath: bug-fix only. Legacy is frozen from the moment the component rollout starts.
Hard rules
Build visuals with the live kit open, every time. A written spec carries parts and decisions; shape is read only from the canvas. A component built from the spec alone with the design bridge disconnected came out structurally wrong (a bordered box where the kit was a muted tray holding an inset card) with every listed part present. If the bridge is down (
designTool: figma→ MCP status probe;designTool: paper→ the Paper project open), stop and ask; the rewrite costs more than the wait.One kit variant axis = one union prop. Mutually exclusive variants (
Type = Simple | CLI | Editor) becometype: 'simple' | 'cli' | 'editor'. Two booleans make a combination the design does not have representable, and a caller will ship it.Kit "Show X" boolean layers become composition. A canvas cannot omit a layer; code omits the child. Incorrect:
<Block showHeader={false} />. Correct:<Block><Body /></Block>.Raw Tailwind with
cn(), theme tokens only. Every color, radius and spacing resolves to atheme.csstoken: the kit bindsbase/card, code writesbg-card, and the shared name is what keeps dark mode and theming free. Hex lives intheme.cssand nowhere else; avar(--x, #fallback)is a token that can silently stop being one, so tokens are written without fallbacks.Resolve every token in both modes before accepting it.
background/card,accent/muted,secondary/mutedare equal in light and different in dark; the wrong pick is invisible until dark. A surface that reads as a card isbg-card.New Tailwind class ⇒ recompile the namespace CSS. If the stylesheet compiles once at Storybook start, a class written afterward does not exist and the element renders unstyled, masquerading as a component bug. Verify:
grep -c '<class>' <generated css>; zero means absent.State selectors belong to the primitive library in
ds.config.json. Under Base UI, Radix'sdata-[state=open]matches nothing; usedata-open,data-closed,data-pressed,data-starting-style,data-ending-style. Before declaring a selector dead, check who renders the attribute: a consumer-spreaddata-invalid={true}is alive. Grep per component before the PR:grep -rn "data-\[state=\|data-\[motion" <namespace>returns zero.Requalify utilities the base layer guards. With
[data-slot] { font-family: sans }intheme.css, plainfont-monoloses by source order. Incorrect:<div data-slot="x" className="font-mono">. Correct:data-[slot=x]:font-mono, on every slotted mono element.React.forwardRefon every part a consumer could compose or pass a ref to while the library ships to React 18. The ref drops silently: the component renders, the downstream behavior (tooltip opening, popup anchoring) disappears. The test is not "does it use the primitive library inside" but "could a consumer wrap it in a trigger". Tag every shim "remove on the React 19 upgrade".Motion:
motion-safe:on the animation itself, transform and opacity only,ease-outfor user-initiated enters, paired elements share duration and easing.motion-reduce:animate-noneloses by source order to adata-*variant animation. Measure the cycle (close, reopen), never the resting state.Icon-only controls get
aria-labelbefore the props spread. Upstream registries do not name icon buttons; the accessibility gate fails per story. Scroll containers gettabIndex={0},role="region", a label. Repeated landmarks get distinct labels. A Select's visible value is not its name.Truncation in fixed-height rows:
truncateon the cell as the safety net plus<span className="truncate">around the value.truncateon a flex container does not ellipsize bare text, and the anonymous item never yields width. If a story needs a hand-added class to look right, the component is missing it.Header actions: constant meaning → icon-only with tooltip (copy, download); meaning that inverts with state → visible label (
Show all↔Show less), because touch has no hover. A leading glyph flips with the label or contradicts it.Page shell is a grid row, never a viewport subtraction. Incorrect:
h-[calc(100vh-81px)]. Correct:grid h-dvh grid-rows-[auto_1fr]with<main className="overflow-y-auto">.Code-highlighting themes are chosen by measured contrast against your backgrounds, scoped to the component (
[data-slot=code-block-pre],data-language), never by taste and never with a globallanguage-*class a legacy stylesheet also matches.Manifest edits go to the component's own file (
manifests.parity/<key>.json), by targeted string replacement. Generated docs (PARITY.md,LEGACY-MAP.md,MIGRATION.md) are regenerated withnode scripts/ds-manifest.mjs docs; a hand edit is overwritten by the next run and failscheckuntil then.Read the usage doc before composing with a namespace component; write it before declaring parity.
manifests.usage/<key>.mdis the caller's contract (when, which variant, what to compose, the owner's warnings); the manifest is the builder's. A screen built from prop names alone picks the variant that compiles, not the one the product means. When the usage doc and the code disagree, fix the doc in the same PR; a stale contract is the one agents follow with confidence.Docs ship inside the package, where the consumer's agent reads them. Usage docs,
MIGRATION.mdand the manifests go tomanifests.ship, indexed byllms.txtat the package root;package.jsonfilescovers both and a script runsds-manifest.mjs shiponprepack. The consumer is migrated by agents in its own repo, so a package that shipsdist/alone hands them compiled JS and a recipe nobody wrote down.checkfails on a missingfilesentry or a missing script;npm pack --dry-runis the proof.parityis a verified mirror, stamped against a kit version. Every kit axis value has its code value or an axisnotesaying why not; every other deliberate difference is inasymmetrieswith its reason;verifiedcarries the level, the date and the kit version id, written byds-manifest.mjs verifyafter the audit.audit codeproves the code half;check --kit-versionshows which entries the kit has since moved past. A manifest that saysparityon the strength of the build day is how forty components ship and a QA pass afterwards finds two kinds of drift at once.
Build procedure (kit-first)
- Read
manifests.parity/<key>.json(thenotecarries the decisions) and the tracker issue iftracker != none. - Audit the live set. Figma: analyze the component set, walk the tree resolving tokens (fills, strokes, radii, padding, text styles), and read
textTruncationandmaxLineson every TEXT node by name (the tree walk omits them). Paper: open the component, read every property and the applied tokens, export one image per variant. Record measurements in the PR description draft; do not eyeball. - Core component:
npx shadcn add <name>then adapt, keeping the file diffable. Composite: compose from namespace parts. Zero raw<button>/<select>. - Verify computed styles in the running Storybook, light and dark: fonts, colors, row heights, scroll behavior, every state via its story (never a scripted
click()). - Update the component's manifest file to
parityonly after step 4 matches per axis; write the usage doc (phases/component.md, step 5); run the generator; run the guards.
Done when: every recorded measurement matches in both modes in the browser.
Confidence gate
Score each decision. High confidence: decide silently, record in the manifest note. Low confidence: bring the design owner a tradeoff in design language ("the primitive's Menu gives keyboard navigation free but has no nested submenus; a custom part covers them and puts a11y on us. Which?"), never a technical question ("should I use the primitive's Menu?"). Bringing every decision equals bringing none.
Budgets
- Visual match: 5 iterations max. An iteration that moves no recorded measurement ends the loop; report the delta.
- Same failure twice: stop. The model of the problem is wrong.
- a11y P1: 3 attempts, then leave it red and say so. A finding downgraded to green a check is worse than a red check.
- A fix that breaks a passing measurement is reverted, never layered on.
Pre-flight (before "ready for review")
- Kit audit against the live set; computed styles verified, light and dark
- CSS recompiled after the last new class; greps > 0
- Type check and lint clean on touched files
- a11y gate items (rule 11); inputs in stories carry
aria-labelin metaargs(a placeholder is not a label) - Stories demonstrate behavior for real (an overflow story overflows; every state has a story)
- Dead-selector grep zero; console free of ref warnings across stories
-
codeConnect: true→<key>.figma.tsxwritten andnpx figma connect parse --dir <namespace>passes - Manifest file updated; axes mirrored or noted,
asymmetriescomplete;verifystamped andaudit codeok; usage doc filled, Owner notes answered; legacyrecipes written; generator run; guards green - Every commit passes commitlint locally; subject starts with
commitSubjectPrefix - Self-review pass on the diff (see
phases/component.md, step 7) - Design-owner preview in Storybook, handed off with the hand-off list
Hand-off list (what no gate reaches)
Deliver with the preview, every time: screen-reader announcement; hover with a real pointer; whether motion feels right; 2x pixel check on custom indicators; detached frames in the kit (customization or drift?); anything the kit visuals do not disambiguate (single vs multi select).
Closing: classify every finding
- Tier 1, the agent needed a rule: into this file if it generalizes, into the manifest
noteif not. - Tier 2, a tooling gap: into the tracker as an issue. This is the tier teams lose.
- Tier 3, resists automation: onto the hand-off list, never into a rule.
Trap catalog
Each fails silently and masquerades as a component bug or a design decision. Check the method before blaming the component.
| Trap | Symptom | Rule |
|---|---|---|
| Namespace CSS compiled once, not watched | new class renders unstyled | recompile after every new class; grep the generated file |
Bare git stash in a shared worktree |
someone else's stash pops onto your tree | git stash push -u -m <tag>, apply by SHA, or a WIP commit |
| Tokens equal in light, different in dark | surface vanishes only in dark | resolve both modes; nothing automated renders dark unless you make it |
| Cached kit screenshots of new nodes | render contradicts data | screenshot the parent frame; vary the scale; data wins until a third method decides |
| Synthesizing a state with a scripted click | measurements from a transient DOM | use the story that has the state; if none, add it and say so |
| Tree walk omits text truncation | free-wrapping text documented as intentional | read textTruncation and maxLines per TEXT node |
| Radix selectors under Base UI | animation or state style never applies | selector table; grep per component; confirm attributes in the DOM |
motion-reduce vs data-* animation |
animation runs under reduced motion | motion-safe: on the animation; measure the cycle |
[data-slot] font guard |
font-mono renders sans |
requalify: data-[slot=x]:font-mono |
| React 18 ref drop | popups anchored wrong or never open | forwardRef on every composable part; console probe; reason about call sites |
| Unlayered legacy preflight | buttons transparent | compile utilities unlayered |
| Placeholder passes the axe label rule | inputs unnamed in the app | aria-label in story args; Field in app usage |
| Upstream icon buttons unnamed | button-name violations |
default aria-label before the props spread; record the deviation |
| Hand-copied counts in docs | doc says 20 of 20, manifests say 23 | generate docs; guard equality |
| Shared manifest file across PRs | every merge conflicts the other approved PRs | one manifest file per component; no shared edits |
Storybook networkidle never resolves |
probe hangs | domcontentloaded + waitForSelector on a concrete control |
| Stale build cache after branch switch | phantom syntax errors in stories | clear the cache before diagnosing |
| Instance modes | set-level mode does not protect instances | unbind and rename the layers |
| Diagnosing by flipping a collection mode | frames resize, bindings lost | test on a throwaway instance |
| Hidden node measured in auto-layout | stale geometry | show, measure, hide |
Unanchored .gitignore entry |
a source folder silently ignored | anchor paths (/lib/) |
| Merge commits with a body in a stacked chain | commitlint fails every PR above | native Merge branch 'x' into y, no body |
| Two merges seconds apart | two publish runs compute the same version; every later release fails | merge one, wait for green publish, merge the next; concurrency group on the workflow |
| Deleting a stacked PR's base branch by API | the stacked PR auto-closes and cannot reopen after a force-push | retarget to main before merging the base |
| Rerun of a PR check after main moved | tests the old merge ref | synchronize event: empty commit or close/reopen |
| Docs-only PR under conventional commits | a release ships with an empty changelog | expect it; tell people |
| Self-review finding taken on faith | a fix for a jump that does not exist | measure the finding frame by frame before fixing |
| Definition-of-done living in a status update | the artifact is forgotten for weeks (36 mappings for 55 modules) | turn it into a guard that fails per component |
--color-* alias in hand-written CSS |
dark wrapper white, children dark | reference raw tokens (var(--background)) in theme.css; aliases compute once on :root |
Console probe against storybook build |
green on a component that drops refs | probe against storybook dev; production React strips every warning |
&:is(.dark *) with the class on a wrapper |
wrapper background stays light | &:where(.dark, .dark *), commented so a diff does not revert it |
| Tailwind auto source detection | a class appears because of where a file sits | source(none) plus explicit @source per folder |
@base-ui-components/react |
pinned at an rc, deprecation notice | the package is @base-ui/react |
Package ships dist/ only |
the consumer's agent finds compiled JS and no recipes | run ship on prepack, files covering it; prove with npm pack --dry-run |
parity declared on the build day and never revisited |
the QA pass at the end finds kit edits after merge and components never at mirror | stamp verified {level, at, kitVersion}; run check --kit-version before cleanup and quarterly |
| Axis values copied from the kit once | manifest and code keep an old value set the kit renamed | run audit code against the cva; re-read the kit at re-audit |
| A kit≠code difference that lives in someone's head | the auditor flags it as drift, or worse, "fixes" it | list it in asymmetries with the owner's reason |
MIGRATION.md written once undecided is empty |
the canary and the first consumer waves migrate with no recipes | generate from the legacy map at the first replaced; render undecided as "do not migrate yet" |