G
GTM Vault
Browse
  • Dashboard
    • Automations
    • Skills
    • Prompts
    • Makers
  • Sign in
All Skills

shadcn-add

Add a shadcn/ui component correctly — fetch canonical source, fix imports, resolve dependencies

skillFrontend DevelopmentClaude Code SkillsInternal Ops
Original
by Roheel Jain
Skill Content

Add Shadcn Component

The user wants to add a shadcn/ui component. Follow these steps exactly.

Step 1: Pre-flight checks

  1. Read components.json — confirm "style": "new-york". If it says "base-nova", STOP and run /shadcn-init first.
  2. Check if the component file already exists at src/components/ui/{component}.tsx. If it does, read it and check if it imports from @base-ui/react. If so, it needs replacing.

Step 2: Fetch canonical source

Use the mcp__Shadcn_UI__get_component tool to fetch the component:

get_component({ componentName: "<component-name>" })

Read the returned source carefully. Note any imports from @/registry/... paths — these need fixing.

Step 3: Identify dependencies

Before writing anything, check what the fetched component imports:

  • Other UI components (e.g., dialog imports button) — check if they exist and are radix-based
  • Hooks (e.g., use-mobile) — check if src/hooks/ has them
  • External packages (e.g., class-variance-authority, lucide-react) — check package.json

Fetch and prepare ALL missing dependencies first. Do not write partial sets.

Step 4: Fix import paths

Replace all registry paths in the fetched code:

  • @/registry/new-york-v4/ui/... → @/components/ui/...
  • @/registry/new-york-v4/hooks/... → @/hooks/...
  • @/registry/new-york-v4/lib/... → @/lib/...

Step 5: Write files

Write all files (the component + any new dependencies) in parallel.

Step 6: Verify

  1. Run grep -r "@base-ui/react" src/components/ui/{component}.tsx — must return nothing
  2. Run grep -r "@/registry" src/components/ui/{component}.tsx — must return nothing
  3. Run npm run build — zero errors

Report the result to the user.

Tech Stack
JavaScript
JavaScript