shadcn-adapt-guide
Skill4 starsChanged 15 days agoMITView on GitHub
Adapt a shadcn/ui component into a first-class nxds component. Use when porting, adapting, converting, or translating a shadcn (or shadcn/ui) component to nxds — mapping tokens via shadcn-divergences.md, applying the nx: prefix, data attributes, component sizing, the focus-ring pattern, and Storybook play-fn tests. Triggers on "adapt X to nxds", "port shadcn X", "add the X component" for the Component library epic, or a shadcn source URL/issue asking to bring a component into the design system.
In this repository25 other files it gives its agents.
- AGENTS.mdAGENTS.md
- analyze-deps-guideSkill
- design-planSkill
- docs-writingSkill
- frontend-designSkill
- implement-guideSkill
- implement-test-guideSkill
- modern-web-guidanceSkill
- pr-fix-guideSkill
- pr-review-follow-upSkill
- pr-review-guideSkill
- shadcnSkill
- ui-audit-guideSkill
- analyze-deps-guideSkill
- design-planSkill
- docs-writingSkill
- frontend-designSkill
- implement-guideSkill
- implement-test-guideSkill
- pr-fix-guideSkill
- pr-review-follow-upSkill
- pr-review-guideSkill
- shadcn-adapt-guideSkill
- shadcnSkill
- ui-audit-guideSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 40
Before writing, read the closest shipped nxds component and mirror it exactly — structure, data-slot, focus, exports, JSDoc.
- Very specific: line 56
If a tracked issue exists: gh issue view {N} --json title,body — it specifies the exports, dep, remaps, icons, and acceptance for this …
- Very specific: line 75
Add the dep to packages/react/package.json (alphabetical) → pnpm install.
- Very specific: line 76
Add any new internal icon to packages/react/src/lib/icons.ts (Phosphor) and to each set in lib/icon-libraries/, in React and Vue.
- Very specific: line 78
Import another component by its file ('../button/button'), never its folder.
- Very specific: line 82
Run these and fix everything before reporting — no deferral (no-follow-up-deferral.md):
- Distinctive: line 90
Read at the start; re-fire whenever a trigger lights up.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Shadcn Adapt Guide
Purpose
Deterministically turn one shadcn/ui component into a first-class nxds component that meets the full component bar. The mapping is known, so this is a recipe, not open-ended implementation: orient → transform → verify. Do not write a multi-phase plan or wait for approval — the steps below are the plan.
Rules are the spec — reference, never duplicate
The authoritative rules live in .claude/rules/*.md. This guide orchestrates them; it never copies the token tables inline (that would drift from the source). Open a rule file when the Reflex Check points you at it.
| Rule | What it owns |
shadcn-divergences.md | THE shadcn→nxds token mapping, sizing, data-attrs, focus, checklist |
base-*.json (surface/nav tokens) | Surface/elevation tokens (container/popover/overlay), the nav-* namespace |
testing-react.md | Required stories, play-fns, a11y, and story coverage audit |
packages/core/tokens/ | Token names — verify a token exists before using it |
code-quality.md, composition-over-render-props.md, extract-inline-handlers.md, guard-clauses.md, useeffect-escape-hatch.md, code-comments.md, no-follow-up-deferral.md, project-stage.md | General code discipline |
Input
One component (e.g. checkbox), a shadcn source URL, or a tracked issue (#162–#177 under epic #161). One component per run → one commit → one PR.
Archetype → reference component
Before writing, read the closest shipped nxds component and mirror it exactly — structure, data-slot, focus, exports, JSDoc. Don't invent a new shape.
| If the component is… | Mirror | Examples |
| A Radix form control | switch.tsx | checkbox, radio-group, progress |
| An overlay (portal + overlay + z-index) | dialog.tsx | alert-dialog, sheet, popover |
| A menu/list with items | select.tsx, dropdown-menu.tsx | command |
| CVA enum/compound variants | button.tsx, badge.tsx | (variant-heavy components) |
| A styled element + focus/aria-invalid | input.tsx | textarea, input-otp slot |
| Pure markup, no Radix | compose primitives + cn | table, skeleton, separator, label |
| Nav / sidebar chrome | nav-* tokens | sidebar |
Process
Step 1 — Orient (read before write)
- If a tracked issue exists:
gh issue view {N} --json title,body— it specifies the exports, dep, remaps, icons, and acceptance for this component. - Pick the archetype above and read that reference file end-to-end. It is your template.
- Skim the relevant rows of
shadcn-divergences.md.
Step 2 — Get the canonical shadcn source
- Fetch via the
shadcnskill, the shadcn registry (https://ui.shadcn.com/r/...), or WebFetch of the source. Read the whole file. - Research the npm dep you'll add (Radix primitive /
cmdk/sonner/input-otp/react-hook-form) — don't guess its API:"{lib} {version} docs".
Step 3 — Transform (deterministic + Reflex Check)
Rewrite the source into the nxds component, mirroring the archetype and applying the Reflex Check below. Preserve the public API shape — prop names, the asChild pattern, handler signatures, and the destructive variant name.
Step 4 — Stories
Author {Name}.stories.tsx per testing-react.md: Default, one per variant + size, Disabled, interaction (click/keyboard) with play-fns, WithDataAttributes (play), and a render-based AllVariants. a11y runs automatically. For a non-standard showcase name or interaction equivalence, follow the archetype equivalence policy in testing-react.md.
Step 5 — Wire
- Add the dep to
packages/react/package.json(alphabetical) →pnpm install. - Add any new internal icon to
packages/react/src/lib/icons.ts(Phosphor) and to each set inlib/icon-libraries/, in React and Vue.ICON_SETSfails typecheck until every set has it. export * from './components/{name}/{name}'inpackages/react/src/index.ts.- Import another component by its file (
'../button/button'), never its folder.
Step 6 — Verify (real gates; fix until green)
Run these and fix everything before reporting — no deferral (no-follow-up-deferral.md):
pnpm --filter @nxds/react typecheckpnpm lint— the canonical gate (eslint . --max-warnings 0), and it passes on a current tree (.claude/worktrees/is config-ignored, soeslint .doesn't recurse it). For a faster loop while iterating, scope to your files:npx eslint packages/react/src/components/{name}/{name}.tsx.- Story tests per
testing-react.md(pnpm test:storybook); a11y violations fail the run.
Reflex Check
Read at the start; re-fire whenever a trigger lights up. The trigger is the thing you're about to type; the arrow is what to do instead.
- Pasting a shadcn
className? → strip raw Tailwind; putnx:before every modifier (nx:hover:…, nothover:nx:…); map each utility to a semantic token viashadcn-divergences.md— neverbg-primary(incomplete) orbg-blue-500(primitive). (shadcn-divergences.md) - See
bg-accent/text-accent-foreground/hover:bg-accent? → there is noaccenttoken in nxds; map by context — ghost/control hover →background-hover, menu/dropdown item →popover-hover, list/card row →container-hover. If the surface isn't inferable, ask rather than guess. (shadcn-divergences.md§ Accent) - See a
dark:modifier? → delete it. Semantic tokens already carry their dark value. (shadcn-divergences.md) - See
ring-*/focus:ring/ring-offset? → usenx:focus-visible:outline-2 nx:focus-visible:outline-focus-default(Button addsnx:focus-visible:outline-offset-2; fields swapoutline-2fornx:focus-visible:outline-defaultplusnx:focus-visible:border-focus-default); invalid fields addnx:aria-invalid:focus-visible:outline-focus-error nx:aria-invalid:focus-visible:border-focus-error. Drop anyoutline-noneon the same element, and swapnx:transition-colorsfornx:transition-control(ornx:transition-fieldon a field) —transition-colorscarriesoutline-color, which fades the ring in, andpnpm lintfails the pair. (mirrorinput.tsx; spec:/foundations/focus) - Sizing a control? → copy the
sizevariants straight frombutton.tsx(it covers both the text and icon-only shapes) orinput.tsx. Don't derive a scale of your own. - Adding any element? →
data-slot="{name}"(+data-variant/data-sizeif it has them). - shadcn uses
destructive? → keep the variant namedestructivein the public API; map internals toerror-*tokens. (shadcn-divergences.md) - Overlay / portal / floating layer? → mirror
dialog.tsx:nx:bg-overlayscrim,nx:bg-container/nx:bg-popoversurface,nx:z-modal(dialog/sheet/alert-dialog) ornx:z-popover(popover/command), tw-animate-css fade/zoom/slide. - Nav / sidebar chrome? →
nav-*namespace (nx:bg-nav-background,nx:hover:bg-nav-item-hover,nx:border-nav-border), not the base surface tokens. - Defining a prop typed
(…) => ReactNode/ComponentType/ amodediscriminator? → usechildren/named slots or per-mode components. (composition-over-render-props.md) - Inline JSX handler 3+ lines or branching? → extract a named
handleXabovereturn. (extract-inline-handlers.md) - Reaching for
useEffect? → external systems only (subscriptions, DOM measurement); never to sync React state. (useeffect-escape-hatch.md) - Typing
// TODO/ "for now" / "follow-up"? → don't. Fix in this PR, or// TODO(#N):against a tracked issue. (code-comments.md,no-follow-up-deferral.md) - Tempted by a backcompat shim / deprecation / feature flag? → delete or rename in place; this is pre-production. (
project-stage.md) - A semantic token you need doesn't exist? → stop and surface it. Don't reach for a primitive or invent one; the token set is the contract. (
packages/core/tokens/)
Definition of done
- Public API shape preserved;
asChildwhere interactive nx:prefix before all modifiers; semantic token paths only; nodark:on semantic tokensdata-slot(+data-variant/data-size); sizing copied from the archetype component- Named interface + JSDoc on custom props; focus ring =
outline-focus-default, with the 2px offset on Button only - Stories with play-fns + AllVariants; a11y clean
- Dep added + installed; icons added; exported from
src/index.ts typecheck+eslint packages+ story tests all green- One component, one commit,
Closes #N
Notes
- Spacing: a control sizes itself with a fixed height plus numeric inline padding — mirror the archetype rather than deriving a scale. Role-named spacing utilities still exist, but only for container and layout roles;
packages/tailwind/spacing-utilities.cssis the current set. There is nocontrol-*spacing family — it was dropped in #489 when every component moved to numeric spacing. - Don't over-plan. The recipe above is the plan — no planning doc, no approval gate. Orient, transform, verify, report.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

