Skip to main content
skill CX Codex

shadcn · pymodel — Claude Code skill: shadcn/ui best practices

A skill that hands your agent a rulebook for shadcn/ui: component architecture, accessibility, theming, forms and tables. Useful whenever it writes or edits React UI.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add PyModel/react-frontend-skills --skill shadcn -a claude-code
Open on GitHub

What shadcn does

The skill sets the order in which an agent works with shadcn/ui. First it checks whether the checked-in components use Radix UI or Base UI, since their composition APIs differ. Base UI is the default for new projects. Component installs and upgrades go through CLI v4, which resolves namespaced registries.

The rules sit in eight priority categories. The critical ones cover component architecture and accessibility preservation: the agent must not strip Radix ARIA attributes, focus trapping in modals or keyboard navigation. Then come styling and theming with CSS variables, form patterns with React Hook Form and Zod, data display through TanStack Table and list virtualization, composition, performance and state. Each rule carries a prefix such as arch- or ally- and has its own file under references/.

Check which primitive library your project already uses before letting the agent touch components. Advice for Radix and Base UI is not interchangeable, and following one set blindly will break the other. The skill ships under the MIT license.

What it helps with

  • tell whether a project is built on Radix or Base UI
  • keep ARIA attributes and focus trapping intact when editing modals
  • wire up a React Hook Form with Zod validation
  • render a large table with sorting and filtering
  • add dark mode backed by CSS variables

Example prompts for the agent

  • add a new Dialog component following the shadcn rules in the skill
  • review my components for accessibility and tell me what to fix
  • build a form with React Hook Form and Zod validation

How to install shadcn

1Skills CLI (Vercel)

npx skills add PyModel/react-frontend-skills --skill shadcn -a claude-code

2Manually: put the files in place

~/.claude/skills/shadcn/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/shadcn/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about shadcn

How do I install shadcn in Claude?

Run npx skills add PyModel/react-frontend-skills --skill shadcn -a claude-code. The skill file lands at ~/.claude/skills/shadcn/SKILL.md.

What does the shadcn skill do?

It gives the agent a rulebook for shadcn/ui covering component architecture, accessibility, theming, forms, tables, composition, performance and state. The agent consults it while writing or editing UI.

How do the Radix UI and Base UI rules differ?

The two libraries expose different composition APIs, so the skill asks you to check which one your project uses first. New projects default to Base UI.

Source text

SKILL.md · MIT
---
name: shadcn
description: shadcn/ui components on Radix or Base UI.
---

# shadcn/ui Community Best Practices

Current best-practices guide for shadcn/ui applications. Before applying primitive-specific guidance, inspect whether the checked-in components use Radix UI or Base UI; current shadcn supports both (Base UI is the default for new projects) and their composition APIs differ. Component installs and upgrades go through the current CLI (v4), which resolves namespaced registries.

## When to Apply

Reference these guidelines when:
- Writing new shadcn/ui components or composing primitives
- Implementing forms with React Hook Form and Zod validation
- Building data tables or handling large dataset displays
- Customizing themes or adding dark mode support
- Reviewing code for accessibility compliance

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Component Architecture | CRITICAL | `arch-` |
| 2 | Accessibility Preservation | CRITICAL | `ally-` |
| 3 | Styling & Theming | HIGH | `style-` |
| 4 | Form Patterns | HIGH | `form-` |
| 5 | Data Display | MEDIUM-HIGH | `data-` |
| 6 | Component Composition | MEDIUM | `comp-` |
| 7 | Performance Optimization | MEDIUM | `perf-` |
| 8 | State Management | LOW-MEDIUM | `state-` |

## Quick Reference

### 1. Component Architecture (CRITICAL)

- [`arch-use-asChild-for-custom-triggers`](references/arch-use-asChild-for-custom-triggers.md) - Use the generated primitive's composition API
- [`arch-current-cli-registry`](references/arch-current-cli-registry.md) - Use the current CLI for component lifecycle (v4, registries, MCP)
- [`arch-unified-radix-package`](references/arch-unified-radix-package.md) - Import primitives from the unified radix-ui package
- [`arch-preserve-radix-primitive-structure`](references/arch-preserve-radix-primitive-structure.md) - Maintain Radix compound component hierarchy
- [`arch-extend-variants-with-cva`](references/arch-extend-variants-with-cva.md) - Use Class Variance Authority for type-safe variants
- [`arch-use-cn-for-class-merging`](references/arch-use-cn-for-class-merging.md) - Use cn() utility for safe Tailwind class merging
- [`arch-forward-refs-for-composable-components`](references/arch-forward-refs-for-composable-components.md) - Forward refs for form and focus integration
- [`arch-isolate-component-variants`](references/arch-isolate-component-variants.md) - Separate base styles from variant-specific styles

### 2. Accessibility Preservation (CRITICAL)

- [`ally-preserve-aria-attributes`](references/ally-preserve-aria-attributes.md) - Keep Radix ARIA attributes intact
- [`ally-provide-sr-only-labels`](references/ally-provide-sr-only-labels.md) - Add screen reader labels for icon buttons
- [`ally-maintain-focus-management`](references/ally-maintain-focus-management.md) - Preserve focus trapping in modals
- [`ally-preserve-keyboard-navigation`](references/ally-preserve-keyboard-navigation.md) - Keep WAI-ARIA keyboard patterns
- [`ally-ensure-color-contrast`](references/ally-ensure-color-contrast.md) - Maintain WCAG color contrast ratios

### 3. Styling & Theming (HIGH)

- [`style-use-css-variables-for-theming`](references/style-use-css-variables-for-theming.md) - Use CSS variables for theme colors
- [`style-avoid-important-overrides`](references/style-avoid-important-overrides.md) - Prefer variants and class composition over important overrides
- [`style-use-tailwind-theme-extend`](references/style-use-tailwind-theme-extend.md) - Define Tailwind v4 theme tokens in CSS
- [`style-consistent-spacing-scale`](references/style-consistent-spacing-scale.md) - Use consistent Tailwind spacing scale
- [`style-responsive-design-patterns`](references/style-responsive-design-patterns.md) - Apply mobile-first responsive design
- [`style-dark-mode-support`](references/style-dark-mode-support.md) - Support dark mode with CSS variables

### 4. Form Patterns (HIGH)

- [`form-use-react-hook-form-integration`](references/form-use-react-hook-form-integration.md) - Integrate with React Hook Form
- [`form-use-zod-for-schema-validation`](references/form-use-zod-for-schema-validation.md) - Use Zod for type-safe validation
- [`form-show-validation-errors-correctly`](references/form-show-validation-errors-correctly.md) - Show errors at appropriate times
- [`form-handle-async-validation`](references/form-handle-async-validation.md) - Debounce async validation calls
- [`form-reset-form-state-correctly`](references/form-reset-form-state-correctly.md) - Reset form state after submission

### 5. Data Display (MEDIUM-HIGH)

- [`data-use-tanstack-table-for-complex-tables`](references/data-use-tanstack-table-for-complex-tables.md) - Use TanStack Table for sorting/filtering
- [`data-virtualize-large-lists`](references/data-virtualize-large-lists.md) - Virtualize lists with 100+ items
- [`data-use-skeleton-loading-states`](references/data-use-skeleton-loading-states.md) - Use Skeleton for loading states
- [`data-paginate-server-side`](references/data-paginate-server-side.md) - Paginate large datasets server-side
- [`data-empty-states-with-guidance`](references/data-empty-states-with-guidance.md) - Provide actionable empty states

### 6. Component Composition (MEDIUM)

- [`comp-compose-with-compound-components`](references/comp-compose-with-compound-components.md) - Use compound component patterns
- [`comp-use-drawer-for-mobile-modals`](references/comp-use-drawer-for-mobile-modals.md) - Use Drawer on mobile devices
- [`comp-combine-command-with-popover`](references/comp-combine-command-with-popover.md) - Create searchable selects with Command
- [`comp-nest-dialogs-correctly`](references/comp-nest-dialogs-correctly.md) - Manage nested dialog focus correctly
- [`comp-create-reusable-form-fields`](references/comp-create-reusable-form-fields.md) - Extract reusable form field components
- [`comp-use-slot-pattern-for-flexibility`](references/comp-use-slot-pattern-for-flexibility.md) - Use slot pattern for flexible content

### 7. Performance Optimization (MEDIUM)

- [`perf-lazy-load-heavy-components`](references/perf-lazy-load-heavy-components.md) - Lazy load components over 50KB
- [`perf-memoize-expensive-renders`](references/perf-memoize-expensive-renders.md) - Memoize list items and expensive components
- [`perf-optimize-icon-imports`](references/perf-optimize-icon-imports.md) - Use direct imports for Lucide icons
- [`perf-avoid-unnecessary-rerenders-in-forms`](references/perf-avoid-unnecessary-rerenders-in-forms.md) - Isolate form field watching
- [`perf-debounce-search-inputs`](references/perf-debounce-search-inputs.md) - Debounce search and filter inputs

### 8. State Management (LOW-MEDIUM)

- [`state-prefer-uncontrolled-for-simple-inputs`](references/state-prefer-uncontrolled-for-simple-inputs.md) - Use uncontrolled for simple forms
- [`state-lift-state-to-appropriate-level`](references/state-lift-state-to-appropriate-level.md) - Lift state to lowest common ancestor
- [`state-use-controlled-dialog-state`](references/state-use-controlled-dialog-state.md) - Control dialogs for programmatic access
- [`state-colocate-state-with-components`](references/state-colocate-state-with-components.md) - Keep state close to where it's used

## How to Use

Run in the project root first:

```bash
npx -y @pymodel/react-frontend-skills detect  # installed vs. targeted versions
```

Read `references/<rule-id>.md` for each rule above that matches the task: why it matters, then incorrect vs. correct code.

© PyModel · MIT · PyModel/react-frontend-skills

Similar skills

Everything for Frontend and UI →

shadcn by other authors comes first.

shadcn shadcn-ui A skill that keeps your agent on the rails with shadcn/ui: adds components, searches registries, fixes markup and builds a design system from your spec. CX Codex +1 123,300installs shadcn typeui.sh Gives the agent a shadcn/ui-style design system: tokens, typography, component states and accessibility criteria. CX Codex +1 2,500installs shadcn official Vercel Labs This skill guides Codex through adding shadcn/ui components and configuring themes. Use it when building a React interface with Tailwind CSS. CX Codex GP ChatGPT 72installs shadcn pedronauck Guides AI agents through shadcn/ui and Radix UI best practices. Prevents broken themes and keeps component accessibility intact. CX Codex +1 369installs shadcn pproenca A skill with 58 shadcn/ui rules that tells your agent how to add components, build forms and keep accessibility intact. CX Codex +1 724installs shadcn-component-review mattbx Reviews finished components and layouts against shadcn patterns: spacing, semantic tokens, primitive composition, and the project's chosen visual style. CX Codex +1 635installs shadcn-ui giuseppe-trisciuoglio A skill that tells the agent how to install and configure shadcn/ui components: buttons, dialogs, tables, and forms with React Hook Form and Zod. CX Codex +1 22,400installs shadcn-layouts jwynia Teaches the agent the CSS models behind shadcn and Tailwind layouts, so height, scroll and flex/grid problems get fixed instead of guessed at. CX Codex +1 457installs ui-design-system samhvw8 A skill for reviewing and building React interfaces with TailwindCSS, Radix UI and shadcn/ui. Useful when your components have drifted apart. CX Codex +1 3,200installs radix-ui-design-system sickn33 Builds accessible design systems and headless UI components with Radix UI primitives. Useful for custom component libraries and WCAG 2.1 compliance. CX Codex +1 1,300installs avoid-ai-design ungspirit A skill that audits frontend code for the patterns that make a UI look AI-generated, then rewrites it around one deliberate design direction. Useful when a Claude or Codex build looks like everyone else's. CX Codex +1 641installs

From the same set10

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor