shadcn
by shadcn-uiUse the shadcn skill to inspect project context, run the right CLI commands, install components, and compose UI with documented patterns for base vs radix, forms, theming, and registries.
This skill scores 85/100, which means it is a strong directory listing candidate for agents working with shadcn/ui projects. Repository evidence shows clear trigger conditions, substantial operational guidance, concrete CLI/MCP references, and rules that reduce common UI implementation mistakes beyond what a generic prompt would reliably handle.
- Strong triggerability: the frontmatter and description explicitly cover shadcn/ui projects, components.json detection, CLI actions like init/add/search/docs/info, and preset switching.
- High agent leverage: SKILL.md, cli.md, mcp.md, and five rule files provide reusable command references, project-context inspection, composition rules, styling guidance, and base-vs-radix differences.
- Good trust signals: the skill includes evals with expected behaviors and examples, plus concrete repository and CLI references instead of placeholder content.
- No install command is provided in SKILL.md, so directory users may need to infer installation/setup flow from the repository structure rather than a dedicated quick start.
- The material is extensive and somewhat fragmented across multiple docs, which may slow initial adoption compared with a shorter task-first guide.
Overview of shadcn skill
What the shadcn skill is for
The shadcn skill helps an AI assistant work correctly inside real shadcn/ui projects: finding components, installing them with the right CLI, composing screens from existing primitives, and avoiding common API mistakes across presets and component families. It is most useful when you want more than “generate a button” and need output that respects components.json, your installed registry items, your template, and the base vs radix differences.
Who should use this shadcn skill
Best fit readers are:
- developers already using
shadcn/ui - teams adopting a preset or registry-driven UI workflow
- people asking AI to add or refactor forms, dialogs, settings pages, dashboards, or theme work
- anyone who wants the assistant to inspect project context before writing JSX
If you are not using shadcn/ui, components.json, or the shadcn CLI, this skill is probably too specific.
The real job-to-be-done
Users do not just want a repo summary. They want the assistant to:
- detect the project’s shadcn setup,
- choose existing components before inventing new ones,
- use the correct CLI commands and documented flags,
- compose UI in the library’s preferred patterns,
- avoid subtle breakage like wrong trigger composition, missing group wrappers, or incorrect form validation wiring.
That is where this shadcn skill adds value over an ordinary UI prompt.
What differentiates shadcn from a generic prompt
The strongest differentiators are practical:
- it starts from
npx shadcn@latest info --jsonproject context - it emphasizes
search,view, anddocsbefore custom implementation - it encodes project rules from files like
rules/composition.md,rules/forms.md,rules/styling.md, andrules/base-vs-radix.md - it covers theming and preset switching, not just component snippets
- it includes MCP guidance for registry search and installation workflows
In short, the shadcn skill is less about “write React” and more about “write the right React for this shadcn setup.”
Important adoption constraints
Before relying on the skill, know these constraints:
- it assumes shadcn CLI access via the project’s package runner:
npx,pnpm dlx, orbunx --bun - it is bounded by documented CLI flags; the skill explicitly warns against inventing flags
- many good outputs depend on a valid
components.json - API details can differ by preset and by
basevsradix, so blindly reusing examples can be wrong
How to Use shadcn skill
Install context for the shadcn skill
Add the skill to your AI environment with the directory’s standard install flow, then use it in a repo that actually contains or intends to contain a shadcn setup. In practice, the repository-side requirement is more important than the skill install command: the assistant needs access to your project files and should be able to run shadcn CLI commands.
Inside the target project, the relevant runtime commands are:
npx shadcn@latest info --jsonnpx shadcn@latest search <query>npx shadcn@latest view <item>npx shadcn@latest docs <component>npx shadcn@latest add <component>
Substitute pnpm dlx shadcn@latest or bunx --bun shadcn@latest if that matches the project’s package manager.
Read these files first before asking for output
For fast, accurate shadcn usage, inspect these files in roughly this order:
SKILL.mdcli.mdrules/composition.mdrules/base-vs-radix.mdrules/forms.mdrules/styling.mdcustomization.mdmcp.md
Why this order works:
SKILL.mddefines trigger conditions and workflowcli.mdprevents guessed commands and flags- the
rules/files capture the mistakes generic codegen often makes customization.mdmatters when you need theme-safe styling, not raw Tailwind color hacksmcp.mdmatters when your assistant can browse registries through MCP rather than shelling out
Start every shadcn task with project discovery
The single best first step is:
npx shadcn@latest info --json
This tells the assistant what is already configured, including component and project context. It is especially useful for:
- checking whether
components.jsonexists - identifying installed components
- detecting setup details that change valid code choices
- confirming the package runner and avoiding wrong command examples
If you skip this, the shadcn skill becomes much closer to a generic prompt.
Turn a rough goal into a strong shadcn prompt
Weak prompt:
Build me a profile dialog with shadcn.
Better prompt:
In this existing
shadcn/uiapp, inspectcomponents.jsonand runnpx shadcn@latest info --jsonfirst. We use theradixsetup andlucide-react. Create a profile edit dialog using existing shadcn components only where possible. Include avatar, name, bio, Save/Cancel actions, accessible title, semantic tokens, and no raw color classes. If a component is missing, tell me the exactshadcn addcommand before generating code.
Why this is stronger:
- it forces project discovery
- it specifies preset-sensitive behavior
- it states icon and styling constraints
- it asks for install steps when dependencies are missing
Use search and docs before custom code
A high-quality shadcn workflow is:
- search registries for existing components,
- inspect docs and examples,
- add missing pieces,
- compose the screen.
Practical commands:
npx shadcn@latest search dialog
npx shadcn@latest docs dialog
npx shadcn@latest view @shadcn/dialog
This is especially important for forms, overlays, navigation, and empty states, where the skill’s rules prefer library patterns over ad hoc div structures.
Compose screens from existing building blocks
The shadcn skill is strongest when you ask for composition, not monolithic custom UI. Good task framing includes:
- “settings page = Tabs + Card + form controls”
- “dashboard = Sidebar + Card + Chart + Table”
- “empty state = Empty component, not a custom centered div”
- “callout = Alert, not hand-rolled border boxes”
This mirrors the skill’s preferred workflow: use existing components first, then adapt variants and wrappers only when needed.
Respect base vs radix differences
One of the biggest adoption blockers is assuming all shadcn examples are interchangeable. They are not.
The skill includes explicit guidance for base vs radix, including:
asChildvsrender- trigger composition differences
nativeButton={false}in specific base-only cases- component API differences such as
Select,ToggleGroup,Slider, andAccordion
If your prompt does not state which setup you use, ask the assistant to detect it from npx shadcn@latest info.
Use styling guidance that survives theming
For shadcn for UI Design, better results come from semantic tokens and CSS variable-driven theming, not hard-coded Tailwind colors.
Prefer:
bg-backgroundtext-foregroundtext-muted-foregroundtext-destructive
Avoid defaulting to:
bg-red-500text-gray-400- lots of manual
dark:overrides
This matters because customization.md explains that components inherit from CSS variables. If the assistant uses semantic tokens, your design scales across light/dark themes and presets much more cleanly.
Handle forms the shadcn way
The evals and rules show that form quality is a real focus. Strong shadcn usage for forms usually means:
- using provided field layout patterns instead of raw stacked
divs - marking invalid state with
data-invalidandaria-invalid - using
Switchfor independent on/off preferences - preferring
gap-*spacing overspace-y-*when the rules call for it
If your task includes validation, say so explicitly. Otherwise many assistants generate visually plausible but library-inconsistent forms.
Use MCP when your editor supports it
If your environment supports MCP, the shadcn skill can become more reliable for registry operations. mcp.md documents tools for:
- listing project registries
- searching registry items
- viewing item details and file contents
- getting examples
- installing items
This is useful when you want the assistant to browse registries conversationally instead of relying only on CLI output. It does not replace info --json for project config.
Practical prompt template for shadcn usage
Use this template when you want higher-quality output:
Use the shadcn skill for this task. First inspect the project with `npx shadcn@latest info --json` and read `components.json` if present. Confirm whether this project uses `base` or `radix`. Search for existing components before building custom UI. If something is missing, give the exact documented `shadcn add` command. Then generate the component using semantic tokens, correct composition rules, and the project’s icon library.
Goal: [what you want to build]
Screen context: [page/dialog/form/dashboard/etc.]
Existing components: [if known]
Framework/template: [Next.js/Vite/Astro/etc.]
Constraints: [icons, validation, dark mode, accessibility, no raw colors, no guessed APIs]
Output needed: [component code, install commands, explanation, refactor diff]
shadcn skill FAQ
Is this shadcn skill only for installing components?
No. shadcn install tasks are part of it, but the skill is broader: project inspection, registry search, component composition, theming, debugging, preset switching, and API-correct refactors are all in scope.
Is the shadcn skill beginner-friendly?
Yes, if you are already comfortable with React and a package manager. The skill reduces guesswork by pointing the assistant toward the right commands and rules. It is less beginner-friendly if you need a full introduction to React, Tailwind, or design systems from scratch.
When is shadcn better than a normal prompt?
Use the shadcn skill when correctness depends on project context:
- existing
components.json - matching installed components
- base vs radix behavior
- using documented CLI flags only
- preserving theme tokens and library composition rules
A normal prompt may produce plausible JSX, but it is more likely to miss installation steps or misuse component APIs.
When should you not use the shadcn skill?
Skip it if:
- your project does not use
shadcn/ui - you only need generic HTML/CSS mockups
- you want a design-system-agnostic answer
- the assistant cannot inspect files or run commands, and you cannot provide the needed context manually
In those cases, a broader frontend skill may be a better fit.
Does the skill help with shadcn for UI Design decisions?
Yes, especially around composition and theming. It nudges the assistant toward reusable primitives, semantic color tokens, correct overlay patterns, and component structures that are easier to maintain than one-off handcrafted layouts.
What usually breaks shadcn usage in AI outputs?
Common failures include:
- inventing unsupported CLI flags
- using wrong trigger composition for
basevsradix - creating custom UI instead of using an existing registry component
- styling with raw colors that fight the theme system
- omitting required subcomponents like titles, groups, or fallbacks
These are exactly the areas this skill is meant to tighten up.
How to Improve shadcn skill
Give the shadcn skill the missing context upfront
The highest-leverage improvement is better input. Include:
- framework or template (
next,vite,astro, etc.) - whether
components.jsonexists baseorradixif already known- current icon set
- target component or screen
- whether the task includes install, refactor, or bugfix work
Even one sentence of concrete context can prevent the assistant from choosing the wrong APIs.
Ask for commands before code when components may be missing
If your project may not have the needed component installed, prompt like this:
Before writing code, check whether the required shadcn components are already present. If not, give me the exact add command and wait.
This improves output because it separates environment changes from implementation, making the result easier to trust and apply.
Force rule-aware output for fragile component types
For forms, dialogs, dropdowns, sheets, drawers, and selects, explicitly ask the assistant to follow the rule files. Example:
Follow the shadcn rules for composition, forms, and base-vs-radix differences. Do not simplify structure if it changes the component API.
This matters because many low-quality generations look fine but break accessibility or composition contracts.
Improve shadcn usage by specifying design constraints
A better UI prompt is not just “make it modern.” Include constraints such as:
- semantic tokens only
- no raw palette utilities
- dark mode must work without manual overrides
- use existing variants before custom classes
- prefer library empty states, alerts, separators, badges, and skeletons
These details materially improve first-pass quality in shadcn for UI Design work.
Iterate with targeted corrections, not full rewrites
After the first output, avoid saying only “try again.” Instead say:
- “Refactor this to use installed shadcn components only.”
- “Make this valid for
base, notradix.” - “Replace raw color classes with semantic tokens.”
- “Add the missing title/fallback/group wrappers required by shadcn.”
- “Show the exact
shadcn addcommands for anything assumed.”
This preserves good work while fixing the parts most likely to be wrong.
Validate against the repository’s strongest signals
To improve trust, compare the output against:
cli.mdfor commands and flagsrules/composition.mdfor structurerules/base-vs-radix.mdfor API correctnessrules/forms.mdfor validation and layout patternsrules/styling.mdandcustomization.mdfor theme-safe stylingevals/evals.jsonfor what “good” looks like in practice
That is the quickest way to tell whether the shadcn skill is producing repository-aligned output rather than generic UI code.
