一键导入
shadcn-component-install
Install shadcn/ui components via CLI with mandatory dry-run preview before write. Workflow: info → search → docs → diff → install.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Install shadcn/ui components via CLI with mandatory dry-run preview before write. Workflow: info → search → docs → diff → install.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Review existing Architecture Decision Records. Flag ADRs whose aging signals may have triggered given current state. Categorizes each as valid / aged / superseded and suggests follow-up actions.
Author an Architecture Decision Record (ADR). Captures decisions with implications beyond the current change — lasts months, affects multiple files, hard to reverse. Records context, alternatives considered, consequences, and aging signals so the decision can be revisited when conditions change.
4-phase loop-detection and recovery protocol. Fires when an agent detects it is stuck or repeating the same tool call with no progress — before tool-loop-detection circuit-breaks at 30 calls.
Socratic exploration of requirements before implementation. Refines spec through targeted questions. Use when user asks to 'explore options', 'refine requirements', or mentions 'unclear requirements'.
Generate structured changelog from git history. Groups commits by type, filters noise, produces Keep a Changelog format. Single source of truth — no /commands wrapper.
Generate pipe-delimited commits: Tipo|IdTarea|YYYYMMDD|Descripción. Single source of truth — no /commands wrapper.
| name | shadcn-component-install |
| description | Install shadcn/ui components via CLI with mandatory dry-run preview before write. Workflow: info → search → docs → diff → install. |
| version | 1.0.0 |
| when | {"keywords":["shadcn","ui component","button","dialog","accordion","card","install component","shadcn-ui","radix","registry"]} |
| allowed-tools | ["Bash(npx shadcn@latest *)","Bash(pnpm dlx shadcn@latest *)","Bash(bunx shadcn@latest *)","Read","Grep","Glob"] |
Whenever the user asks to "add a button", "install a dialog", "scaffold an accordion" or any shadcn/ui component — DO NOT copy code from documentation into the project manually. Always use the shadcn CLI. The CLI resolves dependencies, applies registry config (style, baseColor, aliases), wires cn() and Tailwind tokens, and keeps components upgradeable.
If components.json is missing, run init first.
ui.shadcn.com directly into the project.--dry-run step on a project that already has components installed (collisions silently overwrite files otherwise).shadcn@latest.pnpm-lock.yaml → pnpm dlx; bun.lockb → bunx; default → npx).components.json before installing, so style/baseColor/aliases match.info: confirm project is shadcn-readynpx shadcn@latest info
Reads components.json, prints framework, style, baseColor, iconLibrary, and resolved aliases. If the command fails with "components.json not found", run:
npx shadcn@latest init
and stop to confirm style + baseColor with the user before proceeding.
search: find the exact component slugnpx shadcn@latest search <query>
Example:
npx shadcn@latest search dialog
npx shadcn@latest search "data table"
Use the slug from the output (e.g. dialog, data-table) for the next steps. If the search returns multiple registries (e.g. @shadcn/dialog, @magicui/dialog), ask the user which one they want — do NOT guess.
view: read component docs and dependenciesnpx shadcn@latest view <slug>
Example:
npx shadcn@latest view dialog
This prints the component's files, registryDependencies (other shadcn components it pulls in), and npm dependencies. Surface this to the user before writing — especially the npm deps, since they affect lockfile and bundle size.
--dry-run: preview the diffnpx shadcn@latest add <slug> --dry-run
Example:
npx shadcn@latest add dialog --dry-run
The CLI lists every file it would create or overwrite. If any line says OVERWRITE, STOP and ask the user — do not proceed unless they say "yes, overwrite".
For multiple components in one go:
npx shadcn@latest add dialog button label --dry-run
Only after the dry-run is reviewed:
npx shadcn@latest add <slug>
If overwrites were approved, append --overwrite. If the user wants a specific path override, append --path src/components/ui.
After install, run the project's typecheck (e.g. pnpm tsc --noEmit) to confirm imports resolve. Do NOT skip this — registry mismatches surface as TS errors first.
test -f pnpm-lock.yaml && echo "pnpm dlx shadcn@latest"
test -f bun.lockb && echo "bunx shadcn@latest"
test -f yarn.lock && echo "yarn dlx shadcn@latest"
# default
echo "npx shadcn@latest"
Use the detected runner consistently across all 5 steps. Mixing runners triggers cache misses and slower installs.
| Anti-pattern | Why it breaks | Correct replacement |
|---|---|---|
Copy <Dialog> source from ui.shadcn.com into src/components/ui/dialog.tsx | Skips registryDependencies, breaks future diff upgrades, hardcodes wrong cn alias | npx shadcn@latest add dialog |
npx shadcn add dialog (no --dry-run first) | Silent overwrite of customized components | Run dry-run, review, then add |
npm install @radix-ui/react-dialog then write your own wrapper | Misses Tailwind tokens, animation classes, a11y wiring | Use the registry component as base, customize after |
Using shadcn-ui@0.x (deprecated) | Old CLI with broken registry resolution | shadcn@latest (no -ui suffix) |
| Pasting from a chat answer that includes the source | Same as #1, plus stale snapshots | Always add from CLI |
button · dialog · dropdown-menu · form · input · label · select · sheet · table · tabs · toast · tooltip · accordion · alert · alert-dialog · avatar · badge · calendar · card · checkbox · command · data-table · date-picker · popover · progress · radio-group · scroll-area · separator · skeleton · slider · switch · textarea · toggle
When unsure, run search (Step 2) — never guess slugs.