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)
---
name: shadcn-ui-knowledge-patch
description: shadcn/ui
version: "4.23.0"
license: MIT
metadata:
author: Nevaberry
---
# shadcn/ui compatibility guidance
Load this skill when configuring shadcn/ui projects, migrating components,
consuming or publishing registries, or using the registry and MCP APIs.
Use the topic references for complete guidance and examples.
## Reference index
| Reference | Topics |
| --- | --- |
| [Upgrade and Styling](references/upgrade-and-styling.md) | Utility, icon, RTL, and primitive migrations; Tailwind transition; theme tokens and dark palette |
| [Programmatic APIs](references/programmatic-apis.md) | Registry packages, schemas, fetch and resolve APIs, installation, search, errors, preset codes, MCP server |
| [Projects, CLI, and Presets](references/projects-cli-and-presets.md) | Project templates, primitive selection, styles, presets, inspection, docs, agent tooling, CLI project handling |
| [Registry Consumption](references/registry-consumption.md) | Namespaces, authentication, configuration, discovery, pagination, previews, private GitHub access, proxies |
| [Registry Authoring](references/registry-authoring.md) | Includes, validation, publication, dependencies, file targets, design systems, fonts, CSS, environment defaults, dynamic responses |
| [Component Bases and Content](references/component-bases-and-content.md) | Primitive adaptation, React Aria styles, Toast, Questionnaire, Typeset, scripted chats and approvals |
## API migrations and schema compatibility
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 projects still using Zod 3, import the exported types (`RegistryItem`,
`RegistryItemFile`, `Config`) and compose schemas with their own methods:
```ts
import { registryItemSchema, type RegistryItem } from "shadcn/schema"
export function parseRegistryItems(input: unknown): RegistryItem[] {
return registryItemSchema.array().parse(input)
}
```
Read validation errors from `error.issues` and expect Zod 4 message wording.
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 now an `McpServer`:
use `server.registerTool(...)` for tools and
`server.server.setRequestHandler(...)` for low-level request handlers.
Create a fresh `createServer()` instance per connection.
## Component and styling migrations
### Adopt the cn package
New registry components import `{ cn }` from `cn`; `add` installs the package
when needed. `init` generates `lib/utils.ts` with `export { cn } from "cn"`,
so existing imports from that module still work.
```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 source files.
### Tailwind transition and deprecated style
At the Tailwind v4 and React 19 transition, adding components to an existing
Tailwind v3 and React 18 project installs versions for that stack until upgrade.
The transition deprecates the `default` style and switches new projects at that
point to `new-york`.
After the upgrade codemod, move `:root` and `.dark` out of `@layer base` and
turn bare HSL channels into complete `hsl()` values there. Reference those
values directly from `@theme inline`. Once chart tokens hold complete colors,
use `var(--chart-1)` directly in `chartConfig`, removing the old `hsl()` wrapper.
For projects with the component dependencies from this transition, update the
installed Radix packages and companion libraries alongside Tailwind and React;
the reference contains the dependency command and dark-palette refresh steps.
Updated buttons use the default cursor; add `cursor-pointer` if the UI needs
the previous pointer behavior.
### Other migration commands
| Command | Behavior and scope |
| --- | --- |
| `migrate icons` | Rewrites imports and JSX in the configured UI directory, reports unmapped icons, installs the target package, and updates `iconLibrary` on unscoped runs; accepts a file or glob |
| `migrate rtl` | Sets `rtl: true` in `components.json`, converts physical classes to logical classes, and adds `rtl:` variants where needed; scans the UI directory by default and accepts a file or glob |
| `migrate radix` | Replaces individual `@radix-ui/react-*` imports with `radix-ui` imports and adds the package to `package.json`; scans the UI directory by default and accepts a file or glob |
| `eject` | Inlines `@import "shadcn/tailwind.css"` in global CSS and removes the `shadcn` dependency; in a monorepo, target the workspace containing `components.json` and the global stylesheet |
For Radix-to-Base UI migration, ask the installed skill to migrate one component
and its usages at a time while both libraries coexist, or request the whole
project. It updates APIs such as `asChild` to `render`, flags behavior changes
for manual review, typechecks and builds, and leaves a report in
`.migration/<component>.md` and a branch commit per component.
## Project setup, primitives, and presets
New projects initialize with Base UI by default, including registry-based setup
when a `registry:base` item does not pin the library. Pass `-b radix` in
non-interactive `init` scripts that expect Radix. `init --base` also accepts
`aria` for React Aria.
`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
pnpm dlx shadcn@latest init --template next --monorepo
pnpm dlx shadcn@latest init --base aria
```
A preset code bundles theme, colors, icon library, fonts, and radius.
Generate and preview codes in [shadcn/create](https://ui.shadcn.com/create).
Use `init --preset` to scaffold or reconfigure an existing design system and
installed components. Use `--no-reinstall` to skip reinstalling existing UI
components when switching presets through `init`.
```sh
pnpm dlx shadcn@latest init --preset a2r6bw --no-reinstall
pnpm dlx shadcn@latest apply a2r6bw --only theme
pnpm dlx shadcn@latest preset decode a2r6bw --json
pnpm dlx shadcn@latest preset resolve --json
```
`apply --only font` limits a preset change to fonts. `preset decode` reads a
supplied code; `preset resolve` derives a preset from the current project.
In `create`, Vega provides the classic layout, Nova reduces padding and margins,
Maia uses rounded components and generous spacing, Lyra uses sharp corners, and
Mira suits dense interfaces. Styles change generated spacing and structure.
React Aria is selectable in presets and `create` and also supports Luma, Rhea,
and Sera; its state selectors and dependencies come from the Aria registry.
## Inspect projects and registry installs
`info` reports framework and version, CSS variables, installed components, and
links to documentation and examples. `docs` prints component documentation,
example source, and primitive API links. `docs --base` overrides the project
base for the lookup and accepts `base`, `radix`, or `aria`; `--json` produces
machine-readable output.
```sh
pnpm dlx shadcn@latest info
pnpm dlx shadcn@latest docs combobox --base aria --json
pnpm dlx shadcn@latest add button --dry-run
pnpm dlx shadcn@latest add button --diff button.tsx
pnpm dlx shadcn@latest add button --view
```
The three `add` preview flags are read-only: `--dry-run` previews installation,
`--diff` compares registry files with local copies to check for updates, and
`--view` displays the registry payload. `--diff` and `--view` accept a path to
restrict the preview to one file.
Starting in 4.22.1, `add --all` and the component picker include only components
available for the project's style.
## Consume and authenticate registries
Register namespaces in `components.json` with URL templates containing `{name}`.
Use `@registry/name` with `add` and in `registryDependencies`; dependencies can
come from several registries in one install, including the default `@shadcn`.
The CLI also merges registry definitions from `package.json` in memory without
copying them into `components.json` for `add`, `search`, `view`, and `init`.
Authenticated entries use `url` and `headers`. Registries support basic auth,
bearer tokens, query-parameter API keys, and custom headers; the CLI accepts
variable values from `.env` or `.env.local` and reports missing variables.
`{style}` selects the configured style; `params` supplies query parameters.
`${VAR_NAME}` references expand in both `url` and `params`.
Use `view` to inspect code and dependencies, `search` to query one or more
registries, and `list` for a registry's items. `search` and `list` display up to
100 items per registry by default; page with `--limit` and `--offset`.
For GitHub registries, 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 credentials from `gh auth login`.
In CI without `gh`, set `GH_TOKEN` or `GITHUB_TOKEN` with repository read access;
a fine-grained token needs read-only Contents permission.
## Author and compose registry items
Use `include` in the root `registry.json` to compose manifests. Included
manifests can omit root `name` and `homepage`; their file paths are relative to
their own directories. `shadcn build` flattens manifests, drops `include`, and
writes paths relative to the root. Run `registry validate` before building or
publishing to check manifests, schemas, duplicate names, include rules, and paths.
Commit source manifests and item files with `registry.json` at a public GitHub
repository's root; the CLI resolves includes and reads declared files directly.
Dependencies resolve before items that use them. The last file for each resolved
target path wins, including across items in one `add` command. The CLI deep-merges
`tailwind`, `cssVars`, `css`, and `envVars` across resolved items.
GitHub dependencies need full `owner/repo/item` addresses even in the same
repository; a bare name resolves to a built-in item. Pin each independently
with a tag or full commit SHA.
Use alias-relative targets beginning with `@components/`, `@ui/`, `@lib/`, or
`@hooks/`; `~/` places bundled project files relative to the project root.
`registry:page` and `registry:file` entries require targets.
`registry:base` bundles a design system; `registry:font` distributes fonts and
configures their CSS variables. See the reference for complete item examples,
CSS rules, environment defaults, post-install messages, and dynamic responses.
## Use the registry engine and content components
`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 when `config`
is omitted. Responses are cached by resolved URL for the process lifetime by
default; pass `{ useCache: false }` for fresh reads in a long-running process.
Base UI `toast` supports status variants, actions, promise notifications,
stacking, and swipe dismissal. `questionnaire` supports multi-step forms across
Base UI, React Aria, and Radix and is an unstyled primitive in `@shadcn/react`.
Keep the Typeset stylesheet and apply `typeset` to HTML or rendered Markdown
containers; it uses the project theme, adapts to container size, and keeps
earlier blocks stable during streaming.
`@shadcn/helpers/ai-sdk` replays scripted conversations through the real `useChat`
lifecycle with `chat.get(0)` and `chat.transport()`. It can wait for user-supplied
tool results or approvals. `@shadcn/helpers/tanstack-ai` supplies a TanStack AI
`useChat` connection streaming AG-UI events. See the content reference for examples.