From d13d42d434a76bab2636a6bf982efd249531f86d Mon Sep 17 00:00:00 2001 From: Frank <97429702+tsubasakong@users.noreply.github.com> Date: Sun, 8 Mar 2026 21:54:17 -0700 Subject: [PATCH 1/2] docs: preserve base when switching preset codes --- skills/shadcn/SKILL.md | 7 ++++--- skills/shadcn/cli.md | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/skills/shadcn/SKILL.md b/skills/shadcn/SKILL.md index 022142ad53..020d09d409 100644 --- a/skills/shadcn/SKILL.md +++ b/skills/shadcn/SKILL.md @@ -173,9 +173,10 @@ npx shadcn@latest docs button dialog select 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. 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`, etc.), ask which registry to use. Never default to a registry on behalf of the user. 9. **Switching presets** — Ask the user first: **reinstall**, **merge**, or **skip**? - - **Reinstall**: `npx shadcn@latest init --preset --force --reinstall`. Overwrites all components. - - **Merge**: `npx shadcn@latest init --preset --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. - - **Skip**: `npx shadcn@latest init --preset --force --no-reinstall`. Only updates config and CSS, leaves components as-is. + - **First preserve the current base**: read `npx shadcn@latest info` (or `components.json`) and keep the existing component-library base (`base` vs `radix`) when applying a preset code. **Preset codes are opaque and do not tell you which base to switch to.** If you need to run the command outside the target project (for example in a scratch/merge workflow), pass `--base ` explicitly. + - **Reinstall**: `npx shadcn@latest init --preset --base --force --reinstall`. Overwrites all components. + - **Merge**: `npx shadcn@latest init --preset --base --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. + - **Skip**: `npx shadcn@latest init --preset --base --force --no-reinstall`. Only updates config and CSS, leaves components as-is. ## Updating Components diff --git a/skills/shadcn/cli.md b/skills/shadcn/cli.md index 32124036dd..5406aeba28 100644 --- a/skills/shadcn/cli.md +++ b/skills/shadcn/cli.md @@ -245,11 +245,15 @@ Three ways to specify a preset via `--preset`: 3. **URL:** `--preset "https://ui.shadcn.com/init?base=radix&style=nova&..."` > **IMPORTANT:** Never try to decode, fetch, or resolve preset codes manually. Preset codes are opaque — pass them directly to `npx shadcn@latest init --preset ` and let the CLI handle resolution. +> +> When switching a preset in an existing project, preserve the current component-library base (`base` vs `radix`). Get it from `npx shadcn@latest info` or `components.json`, and if you are running the preset command outside that project (for example in a scratch/merge workflow), pass `--base ` explicitly. Do not infer the base from the preset code. ## Switching Presets Ask the user first: **reinstall**, **merge**, or **skip** existing components? -- **Re-install** → `npx shadcn@latest init --preset --force --reinstall`. Overwrites all component files with the new preset styles. Use when the user hasn't customized components. -- **Merge** → `npx shadcn@latest init --preset --force --no-reinstall`, then run `npx shadcn@latest info` to get the list of installed components and use the [smart merge workflow](./SKILL.md#updating-components) to update them one by one, preserving local changes. Use when the user has customized components. -- **Skip** → `npx shadcn@latest init --preset --force --no-reinstall`. Only updates config and CSS variables, leaves existing components as-is. +Before running the command, read `npx shadcn@latest info` (or `components.json`) and preserve the current component-library base (`base` vs `radix`). Preset codes are base-agnostic. If you are applying the preset in a scratch/temp project during a merge workflow, pass `--base ` explicitly. + +- **Re-install** → `npx shadcn@latest init --preset --base --force --reinstall`. Overwrites all component files with the new preset styles. Use when the user hasn't customized components. +- **Merge** → `npx shadcn@latest init --preset --base --force --no-reinstall`, then run `npx shadcn@latest info` to get the list of installed components and use the [smart merge workflow](./SKILL.md#updating-components) to update them one by one, preserving local changes. Use when the user has customized components. +- **Skip** → `npx shadcn@latest init --preset --base --force --no-reinstall`. Only updates config and CSS variables, leaves existing components as-is. From cadc3f96de148faf94c89d4926b41fe3eb8db73c Mon Sep 17 00:00:00 2001 From: shadcn Date: Fri, 13 Mar 2026 08:59:07 +0400 Subject: [PATCH 2/2] chore: small nit in phrasing --- skills/shadcn/SKILL.md | 8 ++++---- skills/shadcn/cli.md | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/skills/shadcn/SKILL.md b/skills/shadcn/SKILL.md index 020d09d409..8a76cc0dc2 100644 --- a/skills/shadcn/SKILL.md +++ b/skills/shadcn/SKILL.md @@ -173,10 +173,10 @@ npx shadcn@latest docs button dialog select 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. 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`, etc.), ask which registry to use. Never default to a registry on behalf of the user. 9. **Switching presets** — Ask the user first: **reinstall**, **merge**, or **skip**? - - **First preserve the current base**: read `npx shadcn@latest info` (or `components.json`) and keep the existing component-library base (`base` vs `radix`) when applying a preset code. **Preset codes are opaque and do not tell you which base to switch to.** If you need to run the command outside the target project (for example in a scratch/merge workflow), pass `--base ` explicitly. - - **Reinstall**: `npx shadcn@latest init --preset --base --force --reinstall`. Overwrites all components. - - **Merge**: `npx shadcn@latest init --preset --base --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. - - **Skip**: `npx shadcn@latest init --preset --base --force --no-reinstall`. Only updates config and CSS, leaves components as-is. + - **Reinstall**: `npx shadcn@latest init --preset --force --reinstall`. Overwrites all components. + - **Merge**: `npx shadcn@latest init --preset --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. + - **Skip**: `npx shadcn@latest init --preset --force --no-reinstall`. Only updates config and CSS, leaves components as-is. + - **Important**: Always run preset commands inside the user's project directory. 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 ` explicitly — preset codes do not encode the base. ## Updating Components diff --git a/skills/shadcn/cli.md b/skills/shadcn/cli.md index 5406aeba28..bdbfe401cb 100644 --- a/skills/shadcn/cli.md +++ b/skills/shadcn/cli.md @@ -245,15 +245,13 @@ Three ways to specify a preset via `--preset`: 3. **URL:** `--preset "https://ui.shadcn.com/init?base=radix&style=nova&..."` > **IMPORTANT:** Never try to decode, fetch, or resolve preset codes manually. Preset codes are opaque — pass them directly to `npx shadcn@latest init --preset ` and let the CLI handle resolution. -> -> When switching a preset in an existing project, preserve the current component-library base (`base` vs `radix`). Get it from `npx shadcn@latest info` or `components.json`, and if you are running the preset command outside that project (for example in a scratch/merge workflow), pass `--base ` explicitly. Do not infer the base from the preset code. ## Switching Presets Ask the user first: **reinstall**, **merge**, or **skip** existing components? -Before running the command, read `npx shadcn@latest info` (or `components.json`) and preserve the current component-library base (`base` vs `radix`). Preset codes are base-agnostic. If you are applying the preset in a scratch/temp project during a merge workflow, pass `--base ` explicitly. +- **Re-install** → `npx shadcn@latest init --preset --force --reinstall`. Overwrites all component files with the new preset styles. Use when the user hasn't customized components. +- **Merge** → `npx shadcn@latest init --preset --force --no-reinstall`, then run `npx shadcn@latest info` to get the list of installed components and use the [smart merge workflow](./SKILL.md#updating-components) to update them one by one, preserving local changes. Use when the user has customized components. +- **Skip** → `npx shadcn@latest init --preset --force --no-reinstall`. Only updates config and CSS variables, leaves existing components as-is. -- **Re-install** → `npx shadcn@latest init --preset --base --force --reinstall`. Overwrites all component files with the new preset styles. Use when the user hasn't customized components. -- **Merge** → `npx shadcn@latest init --preset --base --force --no-reinstall`, then run `npx shadcn@latest info` to get the list of installed components and use the [smart merge workflow](./SKILL.md#updating-components) to update them one by one, preserving local changes. Use when the user has customized components. -- **Skip** → `npx shadcn@latest init --preset --base --force --no-reinstall`. Only updates config and CSS variables, leaves existing components as-is. +Always run preset commands inside the user's project directory. 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 ` explicitly — preset codes do not encode the base.