agentleFS
theyashguptatheyashgupta/dispatch/.claude/skills/add-shadcn-component/SKILL.md

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.

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
  1. Distinctive:

    Run the shadcn CLI:

    line 14
  2. Distinctive:

    Run git status --short. Record each file that the CLI created or changed.

    line 20
  3. Very specific:

    Do not write a new primitive by hand.

    line 27
  4. Very specific:

    Do not move zod or a server package.

    line 34
  5. Very specific:

    Do not install next-themes, react-hook-form or @hookform/resolvers.

    line 35
  6. Very specific:

    Run env -u NODE_ENV npm install to update package-lock.json.

    line 36
  7. Very specific:

    If the class string also has outline-hidden or outline-none, add focus-visible:outline-solid.

    line 46
  8. Very specific:

    If an ancestor with overflow: hidden cuts the outline, use focus-visible:outline-offset-0 at that element.

    line 49
  9. Very specific:

    Run grep -nE '(^|[^a-z-])ring-' <file> on each generated file.

    line 50
  10. Very specific:

    If a token class does not exist in the @theme inline block of src/web/styles/globals.css, add its mapping there.

    line 65
  11. Very specific:

    Keep the @custom-variant dark line in src/web/styles/globals.css.

    line 66
  12. Very specific:

    If the component is sonner, remove the next-themes import from sonner.tsx.

    line 70
  13. Very specific:

    Add the component to src/web/gallery-main.tsx, in the group of its family.

    line 74
  14. Very specific:

    Run env -u NODE_ENV npm run check:static.

    line 78

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Run the shadcn CLI:

    env -u NODE_ENV npx shadcn@latest add <component> -y
  2. Run git status --short. Record each file that the CLI created or changed.
  3. Format the new files. The CLI writes files without semicolons, so format:check fails on them before this step.

    env -u NODE_ENV npx oxfmt <each new file>
  4. 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 cva variant.

Packages

  1. Open package.json. The CLI adds packages to dependencies, for example radix-ui, cn, cmdk and sonner.
    1. Move each web package that the CLI added to devDependencies.
    2. Pin each moved package to an exact version. Remove each ^ and ~.
    3. Do not move zod or a server package.
    4. Do not install next-themes, react-hook-form or @hookform/resolvers.
    5. Run env -u NODE_ENV npm install to update package-lock.json.

Focus outline

  1. 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-ring
    • ring-offset-*
    • aria-invalid:ring-* and dark:aria-invalid:ring-*

    If the class string also has outline-hidden or outline-none, add focus-visible:outline-solid; focus-outline.test.ts enforces it.

  2. Keep aria-invalid:border-destructive.
  3. If an ancestor with overflow: hidden cuts the outline, use focus-visible:outline-offset-0 at that element. Menu and select items use the inset form focus-visible:-outline-offset-2.
  4. Run grep -nE '(^|[^a-z-])ring-' <file> on each generated file. The command must show no line.

Colours

  1. Replace each Tailwind default palette class with a token class. Examples: text-white becomes text-on-accent or text-on-danger, and bg-black/50 becomes bg-scrim.
  2. Replace a raw colour variable in a class, for example hsl(var(--x)), with var(--x).
  3. Open src/web/styles/globals.css. Remove each colour value that the CLI added, for example an oklch() value.
  4. Map each new shadcn colour name to a token that src/web/styles/tokens.css defines. Do not add a shadcn name to tokens.css.
    1. In the :root block of src/web/styles/globals.css, add one custom property for the name. Its value is var() of the token. Example: --card: var(--surface-card);.
    2. In the @theme inline block of src/web/styles/globals.css, add the colour name. Example: --color-card: var(--card);.
    3. tokens.css already defines some names. Do not add a :root line for these names. Map each one in the @theme inline block of src/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-sm and --radius-lg tokens in tokens.css set the other sizes.
  5. If a token class does not exist in the @theme inline block of src/web/styles/globals.css, add its mapping there. Do not write a colour value.
  6. Keep the @custom-variant dark line in src/web/styles/globals.css.

Sonner

  1. If the component is sonner, remove the next-themes import from sonner.tsx. Give the Toaster a theme prop that its consumer sets. Do not import a hook from outside src/web/components/ui/.

Gallery

  1. 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

  1. Run env -u NODE_ENV npm run check:static. It must pass.
  2. Tell the user the new files, the moved packages and their versions.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.