Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Shadcn Ui Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-shadcn-ui-knowledge-patch-nevaberry-plugins)
---
name: shadcn-ui-knowledge-patch
description: shadcn/ui
version: "4.23.0"
license: MIT
metadata:
author: Nevaberry
---
# shadcn/ui Knowledge Patch
Load this skill when setting up or migrating shadcn/ui projects, choosing
component primitives, or working with registries and their programmatic APIs.
The references contain the full guidance and examples for each workflow.
## Reference index
| Reference | Topics |
| --- | --- |
| [CLI workflows and migrations](references/cli-and-migrations.md) | Class utilities, icons, RTL, Radix imports, previews, discovery, documentation, MCP |
| [Components and primitive bases](references/components-and-bases.md) | Primitive adaptation and migration, toast, questionnaire, scripted chats, Typeset |
| [Project setup and styling](references/project-setup-and-styling.md) | Templates, primitive defaults, presets, visual styles, Tailwind and theme migration |
| [Registries and programmatic APIs](references/registries-and-programmatic-apis.md) | API compatibility, authentication, GitHub, manifests, targets, fonts, search, schemas, caching |
## Breaking changes and deprecations
### Registry API and schema migration
Replace deprecated `fetchRegistry` with `getRegistry`, and
`resolveRegistryTree` with `resolveRegistryItems`. Import registry schemas
from `shadcn/schema` instead of `shadcn/registry`.
In 4.22.0, `shadcn/schema` and `@shadcn/registry/schema` export Zod 4 schemas.
They are incompatible with Zod 3's `z.infer` and `z.array`. In Zod 3 projects,
use the exported `RegistryItem`, `RegistryItemFile`, and `Config` types and
compose schemas with their own methods, such as `registryItemSchema.array()`.
Read validation errors from `error.issues` and expect Zod 4 message wording.
### Primitive defaults and migration
New projects initialize with Base UI by default. This also applies to a
`registry:base` setup that does not pin the library. Pass `-b radix` in
non-interactive `init` scripts that expect Radix; `init --base aria` selects
React Aria.
The installed shadcn skill can migrate one component and its usages at a time
while Radix and Base UI coexist, or migrate the whole project. It updates APIs
such as `asChild` to `render`, flags behavior changes for manual review,
typechecks and builds, and leaves `.migration/<component>.md` and a branch
commit per component.
### Class utility migration
New registry components import `{ cn }` from `cn`; `add` installs it when
needed. `init` generates `lib/utils.ts` with `export { cn } from "cn"`, keeping
existing imports from that module working.
```sh
pnpm dlx shadcn@latest migrate cn
```
The migration rewrites imports and `twMerge(clsx(...))` calls, then removes
`clsx` and `tailwind-merge` once they have no remaining references. Starting
in 4.20.0, it can also replace `cnfast` in Tailwind CSS v4 projects; starting
in 4.20.1, it preserves leading comments in rewritten files.
### MCP server API
In 4.23.0, `shadcn mcp` uses MCP TypeScript SDK v2
(`@modelcontextprotocol/server`) and supports protocol `2026-07-28` alongside
earlier versions. The server exported by `shadcn/mcp` is an `McpServer`.
Use `server.registerTool(...)` for tools and
`server.server.setRequestHandler(...)` for low-level request handlers.
Create a fresh `createServer()` instance per connection.
### Tailwind transition
At the Tailwind v4 and React 19 transition, new projects start on that stack;
existing Tailwind v3 and React 18 projects receive component versions for
their stack until upgraded. That transition deprecates the `default` style
and switches new projects at that point to `new-york`.
After the upgrade codemod, move `:root` and `.dark` outside `@layer base`,
convert bare HSL channels there to complete `hsl()` values, and reference them
directly from `@theme inline`. Once chart tokens hold complete colors, use
`var(--chart-1)` directly in `chartConfig`, removing each old `hsl()` wrapper.
Updated buttons use the default cursor; add `cursor-pointer` if the UI needs
the previous pointer behavior. For the refreshed dark palette in projects
created on Tailwind v4, commit local edits before re-adding components with
`add --all --overwrite`, update `.dark` in `globals.css` to the new OKLCH base
colors, then review the diff and reapply customizations.
## Other migration commands
- `migrate icons` rewrites imports and JSX in the configured UI directory,
reports unmapped icons, installs the target package, and updates
`iconLibrary` on unscoped runs. A file or glob scopes the rewrite.
- `migrate rtl` sets `rtl: true` in `components.json`, converts physical
classes such as `ml-4` to logical classes such as `ms-4`, and adds `rtl:`
variants where needed. It accepts a file or glob.
- `migrate radix` replaces individual `@radix-ui/react-*` imports with
`radix-ui` and adds that package to `package.json`. It accepts a file or glob.
- `eject` replaces `@import "shadcn/tailwind.css"` with the stylesheet contents
in global CSS and removes the `shadcn` dependency. In a monorepo, target the
workspace containing `components.json` and the global stylesheet.
## Project setup and presets
`init` can scaffold Next.js, Vite, TanStack Start, React Router, Astro, and
Laravel. Next.js and Vite include dark mode; `--monorepo` scaffolds a monorepo.
`init --defaults` selects the `next` template and `nova` preset; `--name`
supplies the project name.
```sh
pnpm dlx shadcn@latest init --name my-app --defaults
```
A preset code bundles theme, colors, icon library, fonts, and radius.
Generate and preview codes in [shadcn/create](https://ui.shadcn.com/create).
`init --preset` also reconfigures existing apps and installed components.
Use `--no-reinstall` to skip reinstalling existing UI components when switching
presets. `apply --only theme` or `apply --only font` changes only that part.
```sh
pnpm dlx shadcn@latest init --preset a2r6bw --no-reinstall
pnpm dlx shadcn@latest apply a2r6bw --only theme
```
`preset decode` reads a code; `preset resolve` derives one from the current
project. Both accept `--json`. Programmatic `encodePreset` and `decodePreset`
come from `shadcn/preset`; decoding returns a full config or `null` for a
missing or invalid code.
## Inspect before installing
`add --dry-run` previews an install, `add --diff` compares registry files with
local copies, and `add --view` displays the registry payload. All three are
read-only. A path after `--diff` or `--view` restricts the preview to one file.
```sh
pnpm dlx shadcn@latest add button --dry-run
pnpm dlx shadcn@latest add button --diff button.tsx
```
`info` reports framework and version, CSS variables, installed components,
and links to their documentation and examples. `docs` prints component
documentation, example-source, and primitive API links. `docs --base` accepts
`base`, `radix`, or `aria` to override the project base; `--json` gives
machine-readable output.
`view` inspects an item's code and dependencies; `search` queries one or more
registries; `list` lists registry items. `search` and `list` show up to 100
items per registry by default; page with `--limit` and `--offset`.
## Registry configuration and composition
Register namespace URL templates with `{name}` in `components.json`, then use
`@registry/name` with `add` and `registryDependencies`. Dependencies can span
registries, including `@shadcn`. The CLI also merges registry definitions from
`package.json`; `add`, `search`, `view`, and `init` resolve those definitions
in memory without copying them into `components.json`.
Authenticated entries use `url` and `headers`; missing referenced environment
variables are reported, and values can come from `.env` or `.env.local`.
For GitHub, use `owner/repo/item` with `add` or `view`, and `owner/repo` with
`list`, `search`, or `registry validate`. The CLI tries anonymous access first,
then can use `gh auth login` credentials. CI without `gh` can use `GH_TOKEN`
or `GITHUB_TOKEN` with repository read access; fine-grained tokens need
read-only Contents permission.
Source registries can compose manifests with `include`. Run `registry validate`
before building or publishing. `shadcn build` flattens manifests, drops
`include`, and writes paths relative to the root. A public GitHub repository
can publish the root `registry.json`, included manifests, and item files
directly as source.
Dependencies resolve before the items that use them; the last file for each
resolved target wins, including across items passed to one `add` command. The CLI
deep-merges `tailwind`, `cssVars`, `css`, and `envVars`. Use full
`owner/repo/item` dependency addresses even within the same GitHub repository;
a bare name resolves to a built-in item. Pin each GitHub dependency separately.
## Registry items and APIs
`registry:base` packages components, dependencies, CSS variables, fonts, and
configuration as one install. `registry:font` installs a font and configures
its CSS variable. `registry:item` can bundle `registry:file` entries with
`~/` targets relative to the installing project's root. Alias-relative targets
start with `@components/`, `@ui/`, `@lib/`, or `@hooks/`.
`getRegistryItems(names, { config })` returns requested items as an array;
`resolveRegistryItems(names, { config })` follows dependencies and returns one
merged object. Fetch and resolve calls use built-in registries if `{ config }`
is omitted. Responses are cached by resolved URL for the process lifetime by
default; use `{ useCache: false }` for fresh reads in a long-running process.
`getRegistry` requires a flattened remote catalog. Resolve disk `include`
with `loadRegistry({ cwd, registryFile: "registry.json" })`.
`addRegistryItems` needs explicit config for non-interactive installation;
the registry reference details when a config containing only `registries`
suffices and when aliases and `resolvedPaths` are required.
## Components and scripted conversations
The CLI adapts registry installs to the project's primitive library, including
remote components. Base UI offers `toast`; `questionnaire` supports Base UI,
React Aria, and Radix and is also an unstyled `@shadcn/react` primitive.
`@shadcn/helpers/ai-sdk` replays scripted conversations through the real
`useChat` lifecycle with `chat.get(0)` and `chat.transport()`. It can wait for
user tool results or approvals. `@shadcn/helpers/tanstack-ai` provides a
`useChat` connection streaming AG-UI events.
Keep the Typeset stylesheet and apply `typeset` to a container for HTML or
rendered Markdown. It uses the project theme, adapts to container size, and
keeps earlier blocks stable as content streams in. Tune it with
`--typeset-size`, `--typeset-leading`, and `--typeset-flow`.