Upgrade Shadcn

This command upgrades all shadcn/ui components in lib/platform-bible-react/src/components/shadcn-ui/ to the latest version define…

paranext 27 updated 22d ago
Claude CodeGeneric
View source ↗
# Upgrade Shadcn

This command upgrades all shadcn/ui components in `lib/platform-bible-react/src/components/shadcn-ui/` to the latest version defined by a shadcn preset, while preserving all project-specific customizations. It will: archive the existing components, apply a shadcn preset to establish a clean new baseline, propagate relevant changes to extension files, re-apply every customization from `CUSTOMIZATIONS.md` via parallel subagents, and create a PR.

**Preset parameter**: This command accepts an optional preset argument (e.g. `/upgrade-shadcn <preset-url-or-name>`). If no preset is provided, see [Determining the Preset](#determining-the-preset) below.

**Before doing anything else**, read [shadcn/ui Guidelines](../../.context/standards/Code-Style-Guide.md#shadcnui-guidelines). It is the authoritative source for all conventions used in this command: folder structure, boilerplate baseline, `// CUSTOM:` annotations, and the standard customizations. If anything in this command conflicts with that section, trust the section.

## Determining the Preset

If a preset argument was provided to this command, record it as `$PRESET` and skip to [Pre-flight Checks](#pre-flight-checks).

If no preset was provided:

1. Run the following to detect the most recently used preset:

```bash
cd lib/platform-bible-react && npm run get-latest-preset
  1. Note the preset URL/name from the output and ask the user:

The last-used preset is: <detected-preset>

Would you like to:

  • Reuse this preset (just type "reuse" or press enter)
  • Provide a different preset (paste or type the new preset URL/name)

Record whichever preset the user confirms as $PRESET.

Pre-flight Checks

Perform these checks in sequence. Do not proceed past a failed check.

Check 1 — CUSTOMIZATIONS.md exists and is current

CUSTOMIZATIONS.md is the source of truth for every project-specific customization that must be re-applied after the upstream shadcn baseline is replaced. This file is not kept in the repo between upgrades — it is regenerated on demand. If it does not exist, you must regenerate it before continuing.

  1. Verify the file exists: check whether lib/platform-bible-react/src/components/shadcn-ui/CUSTOMIZATIONS.md is present.

    If it does not exist, instruct the user:

    lib/platform-bible-react/src/components/shadcn-ui/CUSTOMIZATIONS.md does not exist. This file is required to drive the upgrade and must be regenerated from the current shadcn-ui components before continuing.

    Please run /shadcn-customizations to generate it, then run /shadcn-customizations again after applying any fixes to confirm everything is documented. Let me know when it is in place and current.

    Do not continue until the file exists.

  2. Verify it is current: ask the user:

    Is lib/platform-bible-react/src/components/shadcn-ui/CUSTOMIZATIONS.md up to date? (i.e., have you already run /shadcn-customizations, applied fixes, and run it again to confirm everything is documented?)

    If the user says no: tell them they must run /shadcn-customizations first and confirm all customizations are documented before continuing. Do not continue until they confirm it is current.

Check 2 — shadcn-ui-old/ does not exist

Check whether lib/platform-bible-react/src/components/shadcn-ui-old/ exists. If it does, instruct the user:

A shadcn-ui-old/ folder already exists. Please review and delete or move it, then let me know when it's gone.

  • Linux / macOS / WSL2: rm -rf lib/platform-bible-react/src/components/shadcn-ui-old
  • Windows (PowerShell): Remove-Item -Recurse -Force lib\platform-bible-react\src\components\shadcn-ui-old

Do not continue until the user confirms it is gone and you have verified the folder is absent.

Create Branch

After both checks pass, create a new branch:

FIRST_NAME=$(git config user.name | awk '{print tolower($1)}')
TODAY=$(date +%m-%d-%Y)
git checkout -b "ai/feature/upgrade-shadcn-${FIRST_NAME}-${TODAY}"

Step 0 — Verify Standard Customizations Are In Sync

After reading the shadcn/ui Guidelines, compare the standard customizations listed there against the standard customizations this command tracks — named in Step 0 and the Step 5 subagent instructions (currently: "TSDocs on all exports?" and "pr-twp on DOM-rendered components?").

If the style guide lists standard customizations that are not represented as table columns, or vice versa, stop immediately and tell the user:

The standard customizations in shadcn/ui Guidelines no longer match what this command tracks. Please update this command (the standard customizations named in Step 0 and the Step 5 subagent instructions), all other shadcn commands, and the shadcn-customization-tracker agent to reflect the current standard customizations before running.

Suggested prompt to fix this:

The shadcn/ui Guidelines section of .context/standards/Code-Style-Guide.md defines these standard customizations: [fill in from what you read in the style guide]. The shadcn commands and `shadcn-customization-tracker` agent are out of date — they still track: [fill in from what you read in the commands]. Read the commands and agent to determine what parts need to be updated, and update them to match the style guide.

Step 1 — Copy Files to shadcn-ui-old/

Run the appropriate platform command. No subagent is needed — the operation produces no file-content output.

# Linux / macOS / WSL2:
mkdir -p lib/platform-bible-react/src/components/shadcn-ui-old
cp lib/platform-bible-react/src/components/shadcn-ui/*.tsx lib/platform-bible-react/src/components/shadcn-ui-old/

# Windows (PowerShell):
New-Item -ItemType Directory -Force lib\platform-bible-react\src\components\shadcn-ui-old
Copy-Item lib\platform-bible-react\src\com

Maintain Upgrade Shadcn?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Upgrade Shadcn on getagentictools](https://getagentictools.com/loops/paranext-upgrade-shadcn?ref=badge)