add-shadcn-component
Skill3 starsChanged 12 days agoMITView on GitHub
Use for /add-shadcn-component <component>. Adds a shadcn component to src/web/components/ui/ with the outline focus, token colours, exact package pins and gallery entry.
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- scaffold-backend-sliceSkill
- scaffold-moduleSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 2 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 14
Run the shadcn CLI:
- Distinctive: line 20
Run git status --short. Record each file that the CLI created or changed.
- Very specific: line 27
Do not write a new primitive by hand.
- Very specific: line 34
Do not move zod or a server package.
- Very specific: line 35
Do not install next-themes, react-hook-form or @hookform/resolvers.
- Very specific: line 36
Run env -u NODE_ENV npm install to update package-lock.json.
- Very specific: line 46
If the class string also has outline-hidden or outline-none, add focus-visible:outline-solid.
- Very specific: line 49
If an ancestor with overflow: hidden cuts the outline, use focus-visible:outline-offset-0 at that element.
- Very specific: line 50
Run grep -nE '(^|[^a-z-])ring-' <file> on each generated file.
- Very specific: line 65
If a token class does not exist in the @theme inline block of src/web/styles/globals.css, add its mapping there.
- Very specific: line 66
Keep the @custom-variant dark line in src/web/styles/globals.css.
- Very specific: line 70
If the component is sonner, remove the next-themes import from sonner.tsx.
- Very specific: line 74
Add the component to src/web/gallery-main.tsx, in the group of its family.
- Very specific: line 78
Run env -u NODE_ENV npm run check:static.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Add a shadcn component
The rules are in docs/standards/frontend-architecture.md, in the sections "The only-shadcn rule" and "Shared tiers".
<component> is the registry name of the component. Example: dropdown-menu.
Procedure
Run the shadcn CLI:
env -u NODE_ENV npx shadcn@latest add <component> -y- Run
git status --short. Record each file that the CLI created or changed. Format the new files. The CLI writes files without semicolons, so
format:checkfails on them before this step.env -u NODE_ENV npx oxfmt <each new file>- Do not write a new primitive by hand. Do not change a generated file, except with the edits in steps 5 to 17 or with a
cvavariant.
Packages
- Open
package.json. The CLI adds packages todependencies, for exampleradix-ui,cn,cmdkandsonner.- Move each web package that the CLI added to
devDependencies. - Pin each moved package to an exact version. Remove each
^and~. - Do not move
zodor a server package. - Do not install
next-themes,react-hook-formor@hookform/resolvers. - Run
env -u NODE_ENV npm installto updatepackage-lock.json.
- Move each web package that the CLI added to
Focus outline
In each generated file, replace each of these classes with
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring:focus-visible:ring-*focus-visible:border-ringring-offset-*aria-invalid:ring-*anddark:aria-invalid:ring-*
If the class string also has
outline-hiddenoroutline-none, addfocus-visible:outline-solid; focus-outline.test.ts enforces it.- Keep
aria-invalid:border-destructive. - If an ancestor with
overflow: hiddencuts the outline, usefocus-visible:outline-offset-0at that element. Menu and select items use the inset formfocus-visible:-outline-offset-2. - Run
grep -nE '(^|[^a-z-])ring-' <file>on each generated file. The command must show no line.
Colours
- Replace each Tailwind default palette class with a token class. Examples:
text-whitebecomestext-on-accentortext-on-danger, andbg-black/50becomesbg-scrim. - Replace a raw colour variable in a class, for example
hsl(var(--x)), withvar(--x). - Open
src/web/styles/globals.css. Remove each colour value that the CLI added, for example anoklch()value. - Map each new shadcn colour name to a token that
src/web/styles/tokens.cssdefines. Do not add a shadcn name totokens.css.- In the
:rootblock ofsrc/web/styles/globals.css, add one custom property for the name. Its value isvar()of the token. Example:--card: var(--surface-card);. - In the
@theme inlineblock ofsrc/web/styles/globals.css, add the colour name. Example:--color-card: var(--card);. tokens.cssalready defines some names. Do not add a:rootline for these names. Map each one in the@theme inlineblock ofsrc/web/styles/globals.css:accent:--color-accent: var(--surface-card-hover);destructive:--color-destructive: var(--destructive);border:--color-border: var(--border);radius:--radius-md: var(--radius);. The--radius-smand--radius-lgtokens intokens.cssset the other sizes.
- In the
- If a token class does not exist in the
@theme inlineblock ofsrc/web/styles/globals.css, add its mapping there. Do not write a colour value. - Keep the
@custom-variant darkline insrc/web/styles/globals.css.
Sonner
- If the component is
sonner, remove thenext-themesimport fromsonner.tsx. Give theToasterathemeprop that its consumer sets. Do not import a hook from outsidesrc/web/components/ui/.
Gallery
- Add the component to
src/web/gallery-main.tsx, in the group of its family. If this file does not exist, skip this step and tell the user.
Checks
- Run
env -u NODE_ENV npm run check:static. It must pass. - Tell the user the new files, the moved packages and their versions.
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.

