@autono/create-open-pages 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +6 -3
  2. package/dist/cli.js +1 -1
  3. package/package.json +1 -1
  4. package/template/.agents/skills/apply-comments/SKILL.md +4 -4
  5. package/template/.agents/skills/create-page/SKILL.md +26 -8
  6. package/template/.agents/skills/create-theme/SKILL.md +137 -150
  7. package/template/.agents/skills/current-page/SKILL.md +1 -1
  8. package/template/.agents/skills/page-authoring/SKILL.md +97 -42
  9. package/template/.agents/skills/page-authoring/references/interactivity.md +71 -23
  10. package/template/.agents/skills/page-authoring/references/layout-and-responsive.md +38 -17
  11. package/template/.agents/skills/page-authoring/references/typography-and-color.md +50 -32
  12. package/template/.agents/skills/shadcn/SKILL.md +277 -0
  13. package/template/.agents/skills/shadcn/assets/shadcn-small.png +0 -0
  14. package/template/.agents/skills/shadcn/assets/shadcn.png +0 -0
  15. package/template/.agents/skills/shadcn/cli.md +290 -0
  16. package/template/.agents/skills/shadcn/customization.md +209 -0
  17. package/template/.agents/skills/shadcn/mcp.md +105 -0
  18. package/template/.agents/skills/shadcn/registry.md +277 -0
  19. package/template/.agents/skills/shadcn/rules/base-vs-radix.md +306 -0
  20. package/template/.agents/skills/shadcn/rules/chat.md +224 -0
  21. package/template/.agents/skills/shadcn/rules/composition.md +213 -0
  22. package/template/.agents/skills/shadcn/rules/forms.md +192 -0
  23. package/template/.agents/skills/shadcn/rules/icons.md +101 -0
  24. package/template/.agents/skills/shadcn/rules/styling.md +185 -0
  25. package/template/AGENTS.md +7 -4
  26. package/template/README.md +21 -4
  27. package/template/components.json +9 -0
  28. package/template/hooks/use-mobile.ts +19 -0
  29. package/template/lib/utils.ts +6 -0
  30. package/template/package.json +27 -5
  31. package/template/pages/getting-started/index.tsx +51 -45
  32. package/template/styles/globals.css +118 -0
  33. package/template/tsconfig.json +13 -2
  34. package/template/ui/accordion.tsx +64 -0
  35. package/template/ui/alert-dialog.tsx +196 -0
  36. package/template/ui/alert.tsx +66 -0
  37. package/template/ui/aspect-ratio.tsx +11 -0
  38. package/template/ui/attachment.tsx +204 -0
  39. package/template/ui/avatar.tsx +107 -0
  40. package/template/ui/badge.tsx +48 -0
  41. package/template/ui/breadcrumb.tsx +109 -0
  42. package/template/ui/bubble.tsx +125 -0
  43. package/template/ui/button-group.tsx +83 -0
  44. package/template/ui/button.tsx +64 -0
  45. package/template/ui/calendar.tsx +218 -0
  46. package/template/ui/card.tsx +92 -0
  47. package/template/ui/carousel.tsx +241 -0
  48. package/template/ui/chart.tsx +374 -0
  49. package/template/ui/checkbox.tsx +32 -0
  50. package/template/ui/collapsible.tsx +31 -0
  51. package/template/ui/combobox.tsx +308 -0
  52. package/template/ui/command.tsx +182 -0
  53. package/template/ui/context-menu.tsx +252 -0
  54. package/template/ui/dialog.tsx +156 -0
  55. package/template/ui/direction.tsx +22 -0
  56. package/template/ui/drawer.tsx +133 -0
  57. package/template/ui/dropdown-menu.tsx +257 -0
  58. package/template/ui/empty.tsx +104 -0
  59. package/template/ui/field.tsx +246 -0
  60. package/template/ui/form.tsx +167 -0
  61. package/template/ui/hover-card.tsx +42 -0
  62. package/template/ui/input-group.tsx +170 -0
  63. package/template/ui/input-otp.tsx +77 -0
  64. package/template/ui/input.tsx +21 -0
  65. package/template/ui/item.tsx +193 -0
  66. package/template/ui/kbd.tsx +28 -0
  67. package/template/ui/label.tsx +22 -0
  68. package/template/ui/marker.tsx +69 -0
  69. package/template/ui/menubar.tsx +276 -0
  70. package/template/ui/message-scroller.tsx +128 -0
  71. package/template/ui/message.tsx +92 -0
  72. package/template/ui/native-select.tsx +62 -0
  73. package/template/ui/navigation-menu.tsx +168 -0
  74. package/template/ui/pagination.tsx +127 -0
  75. package/template/ui/popover.tsx +87 -0
  76. package/template/ui/progress.tsx +31 -0
  77. package/template/ui/radio-group.tsx +43 -0
  78. package/template/ui/resizable.tsx +53 -0
  79. package/template/ui/scroll-area.tsx +56 -0
  80. package/template/ui/select.tsx +190 -0
  81. package/template/ui/separator.tsx +26 -0
  82. package/template/ui/sheet.tsx +143 -0
  83. package/template/ui/sidebar.tsx +726 -0
  84. package/template/ui/skeleton.tsx +13 -0
  85. package/template/ui/slider.tsx +61 -0
  86. package/template/ui/sonner.tsx +40 -0
  87. package/template/ui/spinner.tsx +16 -0
  88. package/template/ui/switch.tsx +33 -0
  89. package/template/ui/table.tsx +116 -0
  90. package/template/ui/tabs.tsx +89 -0
  91. package/template/ui/textarea.tsx +18 -0
  92. package/template/ui/toggle-group.tsx +81 -0
  93. package/template/ui/toggle.tsx +47 -0
  94. package/template/ui/tooltip.tsx +55 -0
@@ -7,54 +7,72 @@
7
7
  | Hero heading | `text-5xl sm:text-7xl font-bold leading-[1.02] tracking-tight` | one per page |
8
8
  | Page / section heading | `text-3xl sm:text-4xl font-bold tracking-tight` | |
9
9
  | Subsection | `text-xl font-semibold` | |
10
- | Lede | `text-lg sm:text-xl text-<muted>` | under the hero heading |
10
+ | Lede | `text-lg sm:text-xl text-muted-foreground` | under the hero heading |
11
11
  | Body | `text-base leading-relaxed` (16px) | never smaller for running copy |
12
- | Secondary | `text-sm text-<muted>` | captions, metadata, table cells |
13
- | Eyebrow / label | `text-xs font-semibold uppercase tracking-[0.2em]` | above headings |
14
- | Code | `font-mono text-[0.9em]` with a subtle background | |
12
+ | Secondary | `text-sm text-muted-foreground` | captions, metadata, table cells |
13
+ | Eyebrow / label | `text-xs font-semibold uppercase tracking-[0.2em]` or `<Badge variant="secondary">` | above headings |
14
+ | Code | `font-mono text-[0.9em] bg-muted rounded px-1` | |
15
15
 
16
16
  - Line-height: tight (`leading-[1.05]`–`leading-tight`) for display sizes,
17
17
  `leading-relaxed` (1.625) for body.
18
18
  - Measure: cap prose at `max-w-[65ch]` / `max-w-2xl`.
19
19
  - Numbers in tables and prices: `tabular-nums`.
20
- - Fonts: the system stack is the default and is fine. Register a display or
21
- brand font only when the user names one — see `assets-and-fonts.md`.
20
+ - Fonts: `--font-sans` from the tokens is the default (system stack unless a
21
+ theme sets it). Load a display or brand font only when the user names one
22
+ or a theme requires it — see `assets-and-fonts.md`.
22
23
 
23
- ## Palette structure
24
+ ## The token system
24
25
 
25
- One page, one palette. Name the roles up front and reuse them literally:
26
+ `styles/globals.css` defines the shadcn tokens in OKLCH for `:root` (light)
27
+ and `.dark`, and exposes them as utilities through `@theme inline`. Pages
28
+ and `ui/` components read the utilities; themes rewrite the values.
26
29
 
27
- | Role | Light example | Dark example |
30
+ | Token pair | Utilities | Use for |
28
31
  | --- | --- | --- |
29
- | background | `bg-white` | `bg-[#0b0b10]` |
30
- | surface | `bg-slate-50` / `bg-white` cards with `border-slate-200` | `bg-white/[0.04]` with `border-white/10` |
31
- | text | `text-slate-900` | `text-white` |
32
- | muted | `text-slate-600` (never lighter than `slate-500` on white) | `text-white/60` |
33
- | accent | one hue, one shade for fills (`bg-indigo-600`) and one for text (`text-indigo-600`) | `bg-emerald-400 text-black` |
34
- | border | `border-slate-200` | `border-white/10` |
35
-
36
- - Define the palette as repeated utilities or as a small `const` map of class
37
- strings when a page uses many surfaces. Do not build class names at runtime.
38
- - Accent is for actions and one highlight per screen. Two accents means no
39
- accent.
40
- - Dark pages: prefer near-black (`#0b0b10`, `#111`) over pure black; lift
41
- surfaces with translucent white (`bg-white/[0.03]`), not grey hex soup.
32
+ | `--background` / `--foreground` | `bg-background text-foreground` | page root |
33
+ | `--card` / `--card-foreground` | `bg-card text-card-foreground` | panels, `<Card>` |
34
+ | `--popover` / `--popover-foreground` | `bg-popover` | menus, popovers (used by `ui/`) |
35
+ | `--primary` / `--primary-foreground` | `bg-primary text-primary-foreground` | the one accent: primary CTA, active state |
36
+ | `--secondary` / `--secondary-foreground` | `bg-secondary` | secondary buttons, badges |
37
+ | `--muted` / `--muted-foreground` | `bg-muted text-muted-foreground` | subdued surfaces, secondary copy |
38
+ | `--accent` / `--accent-foreground` | `bg-accent` | hover surfaces, selected rows |
39
+ | `--destructive` | `text-destructive`, `<Button variant="destructive">` | delete, errors |
40
+ | `--border`, `--input`, `--ring` | `border-border`, `border-input`, `ring-ring` | dividers, field borders, focus |
41
+ | `--chart-1`…`--chart-5` | `text-chart-1`, `fill-chart-1` | `<Chart>` series |
42
+ | `--sidebar*` | `bg-sidebar` … | `<Sidebar>` shell |
43
+ | `--radius` | `rounded-sm`…`rounded-2xl` | all radii scale from one value |
44
+
45
+ - Always use a pair together: a `bg-primary` without `text-primary-foreground`
46
+ breaks the moment a theme changes the primary hue.
47
+ - Opacity modifiers work on tokens: `bg-primary/10` for a tinted band,
48
+ `border-border/60` for a softer rule.
49
+ - Dark pages: put `dark` on the root element's `className`. Every token flips;
50
+ no manual `dark:` prefixes needed unless a single element must differ.
51
+ - Dark *sections* on a light page: wrap the section in `<div className="dark bg-background text-foreground">`.
52
+ - Raw palette classes (`bg-emerald-400`, `text-slate-600`) are for deliberate
53
+ brand moments a theme should not repaint — a neon launch button, a
54
+ gradient hero. Keep them rare and keep them out of `ui/` components.
42
55
 
43
56
  ## Contrast
44
57
 
45
- - Body text ≥ 4.5:1 against its background; large headings ≥ 3:1.
46
- - Muted text on white: `slate-500` is the floor. On dark: `white/60` is the
47
- floor; `white/40` only for decorative metadata.
48
- - Accent text on white must be a 600+ shade (`indigo-600`, `emerald-700`).
49
- `emerald-400` text on white fails.
50
- - Links inside prose: underline or a clearly different color, not color alone
51
- at low contrast.
58
+ - Body text ≥ 4.5:1 against its background; large headings ≥ 3:1. The token
59
+ pairs pass by construction; `text-muted-foreground` is the floor for
60
+ secondary copy.
61
+ - Do not dim below the floor with opacity: `text-foreground/40` and
62
+ `text-white/30` fail. Decorative metadata at most `text-muted-foreground/80`.
63
+ - Accent text on light backgrounds must be the darker shade a theme sets for
64
+ `--primary`; on dark, the lighter one. Never `bg-primary` text on
65
+ `bg-background` without checking.
66
+ - Links inside prose: `underline underline-offset-4`, not color alone.
52
67
 
53
68
  ## Anti-patterns
54
69
 
55
70
  - ❌ Body text under 16px, or `text-xs` for anything the user must read.
56
71
  - ❌ Three font families. Two is the ceiling (display + body).
57
- - ❌ Pure black on pure white for long text (`text-slate-900` on white reads
58
- better); pure white on pure black for dark pages.
72
+ - ❌ Hardcoding a palette per page (`bg-white text-slate-900` everywhere)
73
+ when `bg-background text-foreground` exists — the page silently opts out of
74
+ every theme.
75
+ - ❌ `dark:bg-…` sprinkled on every element instead of one `dark` on the root.
59
76
  - ❌ Gradient text, drop shadows, and glows on every heading. One flourish, once.
60
- - ❌ Palette drift: a new grey shade every section.
77
+ - ❌ Palette drift: a new grey shade every section. There are `muted`,
78
+ `card`, and `background`; that is the whole grey scale.
@@ -0,0 +1,277 @@
1
+ ---
2
+ name: shadcn
3
+ description: Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for "shadcn init", "create an app with --preset", or "switch to --preset".
4
+ user-invocable: false
5
+ allowed-tools: Bash(npx shadcn@latest *), Bash(pnpm dlx shadcn@latest *), Bash(bunx --bun shadcn@latest *)
6
+ ---
7
+
8
+ # shadcn/ui
9
+
10
+ A framework for building ui, components and design systems. Components are added as source code to the user's project via the CLI.
11
+
12
+ > **IMPORTANT:** Run all CLI commands using the project's package runner: `npx shadcn@latest`, `pnpm dlx shadcn@latest`, or `bunx --bun shadcn@latest` — based on the project's `packageManager`. Examples below use `npx shadcn@latest` but substitute the correct runner for the project.
13
+
14
+ ## Current Project Context
15
+
16
+ ```json
17
+ !`npx shadcn@latest info --json`
18
+ ```
19
+
20
+ The JSON above contains the project config and installed components. Use `npx shadcn@latest docs <component>` to get documentation and example URLs for any component.
21
+
22
+ ## Principles
23
+
24
+ 1. **Use existing components first.** Use `npx shadcn@latest search` to check registries before writing custom UI. Check community registries too.
25
+ 2. **Compose, don't reinvent.** Settings page = Tabs + Card + form controls. Dashboard = Sidebar + Card + Chart + Table.
26
+ 3. **Use built-in variants before custom styles.** `variant="outline"`, `size="sm"`, etc.
27
+ 4. **Use semantic colors.** `bg-primary`, `text-muted-foreground` — never raw values like `bg-blue-500`.
28
+
29
+ ## Critical Rules
30
+
31
+ These rules are **always enforced**. Each links to a file with Incorrect/Correct code pairs.
32
+
33
+ ### Styling & Tailwind → [styling.md](./rules/styling.md)
34
+
35
+ - **`className` for layout, not styling.** Never override component colors or typography.
36
+ - **No `space-x-*` or `space-y-*`.** Use `flex` with `gap-*`. For vertical stacks, `flex flex-col gap-*`.
37
+ - **Use `size-*` when width and height are equal.** `size-10` not `w-10 h-10`.
38
+ - **Use `truncate` shorthand.** Not `overflow-hidden text-ellipsis whitespace-nowrap`.
39
+ - **No manual `dark:` color overrides.** Use semantic tokens (`bg-background`, `text-muted-foreground`).
40
+ - **Use `cn()` for conditional classes.** Don't write manual template literal ternaries.
41
+ - **No manual `z-index` on overlay components.** Dialog, Sheet, Popover, etc. handle their own stacking.
42
+
43
+ ### Forms & Inputs → [forms.md](./rules/forms.md)
44
+
45
+ - **Forms use `FieldGroup` + `Field`.** Never use raw `div` with `space-y-*` or `grid gap-*` for form layout.
46
+ - **`InputGroup` uses `InputGroupInput`/`InputGroupTextarea`.** Never raw `Input`/`Textarea` inside `InputGroup`.
47
+ - **Buttons inside inputs use `InputGroup` + `InputGroupAddon`.**
48
+ - **Option sets (2–7 choices) use `ToggleGroup`.** Don't loop `Button` with manual active state.
49
+ - **`FieldSet` + `FieldLegend` for grouping related checkboxes/radios.** Don't use a `div` with a heading.
50
+ - **Field validation uses `data-invalid` + `aria-invalid`.** `data-invalid` on `Field`, `aria-invalid` on the control. For disabled: `data-disabled` on `Field`, `disabled` on the control.
51
+
52
+ ### Component Structure → [composition.md](./rules/composition.md)
53
+
54
+ - **Items always inside their Group.** `SelectItem` → `SelectGroup`. `DropdownMenuItem` → `DropdownMenuGroup`. `CommandItem` → `CommandGroup`.
55
+ - **Use `asChild` (radix) or `render` (base) for custom triggers.** Check `base` field from `npx shadcn@latest info`. → [base-vs-radix.md](./rules/base-vs-radix.md)
56
+ - **Dialog, Sheet, and Drawer always need a Title.** `DialogTitle`, `SheetTitle`, `DrawerTitle` required for accessibility. Use `className="sr-only"` if visually hidden.
57
+ - **Use full Card composition.** `CardHeader`/`CardTitle`/`CardDescription`/`CardContent`/`CardFooter`. Don't dump everything in `CardContent`.
58
+ - **Button has no `isPending`/`isLoading`.** Compose with `Spinner` + `data-icon` + `disabled`.
59
+ - **`TabsTrigger` must be inside `TabsList`.** Never render triggers directly in `Tabs`.
60
+ - **`Avatar` always needs `AvatarFallback`.** For when the image fails to load.
61
+
62
+ ### Use Components, Not Custom Markup → [composition.md](./rules/composition.md)
63
+
64
+ - **Use existing components before custom markup.** Check if a component exists before writing a styled `div`.
65
+ - **Callouts use `Alert`.** Don't build custom styled divs.
66
+ - **Empty states use `Empty`.** Don't build custom empty state markup.
67
+ - **Toast follows the project base.** Use `toast` from the `toast` component for
68
+ Base UI projects. Use `toast()` from `sonner` for Radix and React Aria
69
+ projects.
70
+ - **Use `Separator`** instead of `<hr>` or `<div className="border-t">`.
71
+ - **Use `Skeleton`** for loading placeholders. No custom `animate-pulse` divs.
72
+ - **Use `Badge`** instead of custom styled spans.
73
+
74
+ ### Icons → [icons.md](./rules/icons.md)
75
+
76
+ - **Icons in `Button` use `data-icon`.** `data-icon="inline-start"` or `data-icon="inline-end"` on the icon.
77
+ - **No sizing classes on icons inside components.** Components handle icon sizing via CSS. No `size-4` or `w-4 h-4`.
78
+ - **Pass icons as objects, not string keys.** `icon={CheckIcon}`, not a string lookup.
79
+
80
+ ### Chat & Messaging → [chat.md](./rules/chat.md)
81
+
82
+ - **Chat UI composes the chat primitives.** Conversations use `MessageScroller`, rows use `Message`, surfaces use `Bubble`. Never hand-rolled bubble `div`s or a raw scroll container.
83
+ - **`MessageScroller` owns scroll behavior.** Streaming follow, anchoring, and jump-to-latest (`MessageScrollerButton`) are built in. Don't write a `useStickToBottom`/`ResizeObserver` hook.
84
+ - **Attachments use `Attachment`; system notes and dividers use `Marker`.** Not `Item` cards or `Separator` + a label.
85
+
86
+ ### CLI
87
+
88
+ - **Never decode preset codes or build preset URLs manually.** Use `npx shadcn@latest preset decode <code>`, `preset url <code>`, or `preset open <code>`. For project-aware preset detection, use `npx shadcn@latest preset resolve`.
89
+ - **Apply preset codes directly with the CLI.** Use `npx shadcn@latest apply <code>` for existing projects, or `npx shadcn@latest init --preset <code>` when initializing.
90
+
91
+ ## Key Patterns
92
+
93
+ These are the most common patterns that differentiate correct shadcn/ui code. For edge cases, see the linked rule files above.
94
+
95
+ ```tsx
96
+ // Form layout: FieldGroup + Field, not div + Label.
97
+ <FieldGroup>
98
+ <Field>
99
+ <FieldLabel htmlFor="email">Email</FieldLabel>
100
+ <Input id="email" />
101
+ </Field>
102
+ </FieldGroup>
103
+
104
+ // Validation: data-invalid on Field, aria-invalid on the control.
105
+ <Field data-invalid>
106
+ <FieldLabel>Email</FieldLabel>
107
+ <Input aria-invalid />
108
+ <FieldDescription>Invalid email.</FieldDescription>
109
+ </Field>
110
+
111
+ // Icons in buttons: data-icon, no sizing classes.
112
+ <Button>
113
+ <SearchIcon data-icon="inline-start" />
114
+ Search
115
+ </Button>
116
+
117
+ // Spacing: gap-*, not space-y-*.
118
+ <div className="flex flex-col gap-4"> // correct
119
+ <div className="space-y-4"> // wrong
120
+
121
+ // Equal dimensions: size-*, not w-* h-*.
122
+ <Avatar className="size-10"> // correct
123
+ <Avatar className="w-10 h-10"> // wrong
124
+
125
+ // Status colors: Badge variants or semantic tokens, not raw colors.
126
+ <Badge variant="secondary">+20.1%</Badge> // correct
127
+ <span className="text-emerald-600">+20.1%</span> // wrong
128
+ ```
129
+
130
+ ## Component Selection
131
+
132
+ | Need | Use |
133
+ | -------------------------- | --------------------------------------------------------------------------------------------------- |
134
+ | Button/action | `Button` with appropriate variant |
135
+ | Form inputs | `Input`, `Select`, `Combobox`, `Switch`, `Checkbox`, `RadioGroup`, `Textarea`, `InputOTP`, `Slider` |
136
+ | Toggle between 2–5 options | `ToggleGroup` + `ToggleGroupItem` |
137
+ | Data display | `Table`, `Card`, `Badge`, `Avatar` |
138
+ | Navigation | `Sidebar`, `NavigationMenu`, `Breadcrumb`, `Tabs`, `Pagination` |
139
+ | Overlays | `Dialog` (modal), `Sheet` (side panel), `Drawer` (bottom sheet), `AlertDialog` (confirmation) |
140
+ | Feedback | `toast` (Base UI), `sonner` (Radix/Aria), `Alert`, `Progress`, `Skeleton`, `Spinner` |
141
+ | Command palette | `Command` inside `Dialog` |
142
+ | Charts | `Chart` (wraps Recharts) |
143
+ | Layout | `Card`, `Separator`, `Resizable`, `ScrollArea`, `Accordion`, `Collapsible` |
144
+ | Empty states | `Empty` |
145
+ | Menus | `DropdownMenu`, `ContextMenu`, `Menubar` |
146
+ | Tooltips/info | `Tooltip`, `HoverCard`, `Popover` |
147
+ | Chat / conversation UI | `MessageScroller`, `Message`, `Bubble`, `Attachment`, `Marker` |
148
+
149
+ ## Key Fields
150
+
151
+ The injected project context contains these key fields:
152
+
153
+ - **`aliases`** → use the actual alias prefix for imports (e.g. `@/`, `~/`), never hardcode.
154
+ - **`isRSC`** → when `true`, components using `useState`, `useEffect`, event handlers, or browser APIs need `"use client"` at the top of the file. Always reference this field when advising on the directive.
155
+ - **`tailwindVersion`** → `"v4"` uses `@theme inline` blocks; `"v3"` uses `tailwind.config.js`.
156
+ - **`tailwindCssFile`** → the global CSS file where custom CSS variables are defined. Always edit this file, never create a new one.
157
+ - **`style`** → component visual treatment (e.g. `nova`, `vega`).
158
+ - **`base`** → primitive library (`radix` or `base`). Affects component APIs and available props.
159
+ - **`iconLibrary`** → determines icon imports. Use `lucide-react` for `lucide`, `@tabler/icons-react` for `tabler`, etc. Never assume `lucide-react`.
160
+ - **`resolvedPaths`** → exact file-system destinations for components, utils, hooks, etc.
161
+ - **`framework`** → routing and file conventions (e.g. Next.js App Router vs Vite SPA).
162
+ - **`packageManager`** → use this for any non-shadcn dependency installs (e.g. `pnpm add date-fns` vs `npm install date-fns`).
163
+ - **`preset`** → resolved preset code and values for the current project. Use `npx shadcn@latest preset resolve --json` when you only need preset information.
164
+
165
+ See [cli.md — `info` command](./cli.md) for the full field reference.
166
+
167
+ ## Component Docs, Examples, and Usage
168
+
169
+ Run `npx shadcn@latest docs <component>` to get the URLs for a component's documentation, examples, and API reference. Fetch these URLs to get the actual content.
170
+
171
+ ```bash
172
+ npx shadcn@latest docs button dialog select
173
+ ```
174
+
175
+ **When creating, fixing, debugging, or using a component, always run `npx shadcn@latest docs` and fetch the URLs first.** This ensures you're working with the correct API and usage patterns rather than guessing.
176
+
177
+ ## Workflow
178
+
179
+ 1. **Get project context** — already injected above. Run `npx shadcn@latest info` again if you need to refresh.
180
+ 2. **Check installed components first** — before running `add`, always check the `components` list from project context or list the `resolvedPaths.ui` directory. Don't import components that haven't been added, and don't re-add ones already installed.
181
+ 3. **Find components** — `npx shadcn@latest search`.
182
+ 4. **Get docs and examples** — run `npx shadcn@latest docs <component>` to get URLs, then fetch them. Use `npx shadcn@latest view` to browse registry items you haven't installed. To preview changes to installed components, use `npx shadcn@latest add --diff`.
183
+ 5. **Install or update** — `npx shadcn@latest add`. When updating existing components, use `--dry-run` and `--diff` to preview changes first (see [Updating Components](#updating-components) below).
184
+ 6. **Fix imports in third-party components** — After adding components from community registries (e.g. `@bundui`, `@magicui`), check the added non-UI files for hardcoded import paths like `@/components/ui/...`. These won't match the project's actual aliases. Use `npx shadcn@latest info` to get the correct `ui` alias (e.g. `@workspace/ui/components`) and rewrite the imports accordingly. The CLI rewrites imports for its own UI files, but third-party registry components may use default paths that don't match the project.
185
+ 7. **Review added components** — After adding a component or block from any registry, **always read the added files and verify they are correct**. Check for missing sub-components (e.g. `SelectItem` without `SelectGroup`), missing imports, incorrect composition, or violations of the [Critical Rules](#critical-rules). Also replace any icon imports with the project's `iconLibrary` from the project context (e.g. if the registry item uses `lucide-react` but the project uses `hugeicons`, swap the imports and icon names accordingly). Fix all issues before moving on.
186
+ 8. **Registry must be explicit** — When the user asks to add a block or component, **do not guess the registry**. If no registry is specified (e.g. user says "add a login block" without specifying `@shadcn`, `@tailark`, `owner/repo`, etc.), ask which registry to use. Never default to a registry on behalf of the user.
187
+ 9. **Switching presets** — Ask the user first: **overwrite**, **partial**, **merge**, or **skip**?
188
+ - **Inspect current preset**: `npx shadcn@latest preset resolve`. Use `--json` when you need structured values.
189
+ - **Inspect incoming preset**: `npx shadcn@latest preset decode <code>`. Use `preset url <code>` or `preset open <code>` to share or open the preset builder.
190
+ - **Overwrite**: `npx shadcn@latest apply <code>`. Overwrites detected components, fonts, and CSS variables.
191
+ - **Partial**: `npx shadcn@latest apply <code> --only theme,font`. Updates only the selected preset parts without reinstalling UI components. Supported values are `theme` and `font`; comma-separated combinations are allowed. `icon` is intentionally not supported, because icon changes may require full component reinstall and transforms.
192
+ - **Merge**: `npx shadcn@latest init --preset <code> --force --no-reinstall`, then run `npx shadcn@latest info` to list installed components, then for each installed component use `--dry-run` and `--diff` to [smart merge](#updating-components) it individually.
193
+ - **Skip**: `npx shadcn@latest init --preset <code> --force --no-reinstall`. Only updates config and CSS, leaves components as-is.
194
+ - **Important**: Always run preset commands inside the user's project directory. `apply` only works in an existing project with a `components.json` file. The CLI automatically preserves the current base (`base` vs `radix`) from `components.json`. If you must use a scratch/temp directory (e.g. for `--dry-run` comparisons), pass `--base <current-base>` explicitly — preset codes do not encode the base.
195
+
196
+ ## Updating Components
197
+
198
+ When the user asks to update a component from upstream while keeping their local changes, use `--dry-run` and `--diff` to intelligently merge. **NEVER fetch raw files from GitHub manually — always use the CLI.**
199
+
200
+ 1. Run `npx shadcn@latest add <component> --dry-run` to see all files that would be affected.
201
+ 2. For each file, run `npx shadcn@latest add <component> --diff <file>` to see what changed upstream vs local.
202
+ 3. Decide per file based on the diff:
203
+ - No local changes → safe to overwrite.
204
+ - Has local changes → read the local file, analyze the diff, and apply upstream updates while preserving local modifications.
205
+ - User says "just update everything" → use `--overwrite`, but confirm first.
206
+ 4. **Never use `--overwrite` without the user's explicit approval.**
207
+
208
+ ## Quick Reference
209
+
210
+ ```bash
211
+ # Create a new project.
212
+ npx shadcn@latest init --name my-app --preset base-nova
213
+ npx shadcn@latest init --name my-app --preset a2r6bw --template vite
214
+
215
+ # Create a monorepo project.
216
+ npx shadcn@latest init --name my-app --preset base-nova --monorepo
217
+ npx shadcn@latest init --name my-app --preset base-nova --template next --monorepo
218
+
219
+ # Initialize existing project.
220
+ npx shadcn@latest init --preset base-nova
221
+ npx shadcn@latest init --defaults # shortcut: --template=next --preset=nova (base style implied)
222
+
223
+ # Apply a preset to an existing project.
224
+ npx shadcn@latest apply a2r6bw
225
+ npx shadcn@latest apply a2r6bw --only theme
226
+ npx shadcn@latest apply a2r6bw --only font
227
+ npx shadcn@latest apply a2r6bw --only theme,font
228
+
229
+ # Inspect preset codes and project preset state.
230
+ npx shadcn@latest preset decode a2r6bw
231
+ npx shadcn@latest preset url a2r6bw
232
+ npx shadcn@latest preset open a2r6bw
233
+ npx shadcn@latest preset resolve
234
+ npx shadcn@latest preset resolve --json
235
+
236
+ # Add components.
237
+ npx shadcn@latest add button card dialog
238
+ npx shadcn@latest add @magicui/shimmer-button
239
+ npx shadcn@latest add owner/repo/item
240
+ npx shadcn@latest add --all
241
+
242
+ # Preview changes before adding/updating.
243
+ npx shadcn@latest add button --dry-run
244
+ npx shadcn@latest add button --diff button.tsx
245
+ npx shadcn@latest add @acme/form --view button.tsx
246
+ npx shadcn@latest add owner/repo/item --dry-run
247
+
248
+ # Search registries.
249
+ npx shadcn@latest search @shadcn -q "sidebar"
250
+ npx shadcn@latest search @tailark -q "stats"
251
+ npx shadcn@latest search owner/repo -q "login"
252
+ npx shadcn@latest search # all configured registries
253
+ npx shadcn@latest search @shadcn -q "menu" -t ui # filter by item type
254
+
255
+ # Get component docs and example URLs.
256
+ npx shadcn@latest docs button dialog select
257
+
258
+ # View registry item details (for items not yet installed).
259
+ npx shadcn@latest view @shadcn/button
260
+ npx shadcn@latest view owner/repo/item
261
+ ```
262
+
263
+ **Named presets:** `nova`, `vega`, `maia`, `lyra`, `mira`, `luma`
264
+ **Templates:** `next`, `vite`, `start`, `react-router`, `astro` (all support `--monorepo`) and `laravel` (not supported for monorepo)
265
+ **Preset codes:** Version-prefixed base62 strings (e.g. `a2r6bw` or `b0`), from [ui.shadcn.com](https://ui.shadcn.com).
266
+
267
+ ## Detailed References
268
+
269
+ - [rules/forms.md](./rules/forms.md) — FieldGroup, Field, InputGroup, ToggleGroup, FieldSet, validation states
270
+ - [rules/composition.md](./rules/composition.md) — Groups, overlays, Card, Tabs, Avatar, Alert, Empty, Toast, Separator, Skeleton, Badge, Button loading
271
+ - [rules/chat.md](./rules/chat.md) — MessageScroller, Message, Bubble, Attachment, Marker; streaming, anchoring, jump-to-latest
272
+ - [rules/icons.md](./rules/icons.md) — data-icon, icon sizing, passing icons as objects
273
+ - [rules/styling.md](./rules/styling.md) — Semantic colors, variants, className, spacing, size, truncate, dark mode, cn(), z-index
274
+ - [rules/base-vs-radix.md](./rules/base-vs-radix.md) — asChild vs render, Select, ToggleGroup, Slider, Accordion
275
+ - [cli.md](./cli.md) — Commands, flags, presets, templates
276
+ - [registry.md](./registry.md) — Authoring source registries, `include`, item definitions, dependencies, GitHub registry rules
277
+ - [customization.md](./customization.md) — Theming, CSS variables, extending components