@withmata/blueprints 0.3.1 → 0.3.2

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 (24) hide show
  1. package/.claude/skills/blueprint-catalog/SKILL.md +13 -2
  2. package/.claude/skills/scaffold-env/SKILL.md +222 -0
  3. package/.claude/skills/scaffold-tailwind/SKILL.md +177 -0
  4. package/.claude/skills/scaffold-ui/SKILL.md +206 -0
  5. package/blueprints/features/env-t3/BLUEPRINT.md +332 -0
  6. package/blueprints/features/env-t3/files/nextjs/.env.example +17 -0
  7. package/blueprints/features/env-t3/files/nextjs/.env.local +0 -0
  8. package/blueprints/features/env-t3/files/nextjs/env/client.ts +13 -0
  9. package/blueprints/features/env-t3/files/nextjs/env/server.ts +12 -0
  10. package/blueprints/features/env-t3/files/server/.env.example +14 -0
  11. package/blueprints/features/env-t3/files/server/.env.local +0 -0
  12. package/blueprints/features/env-t3/files/server/env.ts +17 -0
  13. package/blueprints/features/tailwind-v4/BLUEPRINT.md +262 -12
  14. package/blueprints/features/tailwind-v4/files/tailwind-config/package.json +20 -0
  15. package/blueprints/features/tailwind-v4/files/tailwind-config/shared-styles.css +131 -0
  16. package/blueprints/features/ui-shared-components/BLUEPRINT.md +350 -13
  17. package/blueprints/features/ui-shared-components/files/ui/components.json +21 -0
  18. package/blueprints/features/ui-shared-components/files/ui/package.json +42 -0
  19. package/blueprints/features/ui-shared-components/files/ui/styles/globals.css +2 -0
  20. package/blueprints/features/ui-shared-components/files/ui/tsconfig.json +9 -0
  21. package/blueprints/features/ui-shared-components/files/ui/utils/cn.ts +6 -0
  22. package/blueprints/features/ui-shared-components/files/ui/utils/cva.ts +4 -0
  23. package/dist/index.js +1 -1
  24. package/package.json +1 -1
@@ -3,7 +3,8 @@ name: blueprint-catalog
3
3
  description: >
4
4
  Background knowledge about available project blueprints for scaffolding.
5
5
  Invoke when user discusses: databases, authentication, project setup,
6
- monorepo, product ideas, scaffolding, or asks "what should I do next?"
6
+ monorepo, product ideas, scaffolding, environment variables, UI components,
7
+ design systems, Tailwind, or asks "what should I do next?"
7
8
  user-invocable: false
8
9
  ---
9
10
 
@@ -15,6 +16,9 @@ user-invocable: false
15
16
  | Monorepo Foundation | Foundation | Turborepo + pnpm monorepo with Next.js, Biome, TypeScript strict, Tailwind v4. | None | `/scaffold-foundation` |
16
17
  | Database | Feature | Drizzle ORM + PostgreSQL: schema groups, per-group migrations, seed scripts. | None | `/scaffold-db` |
17
18
  | Authentication | Feature | Better Auth + Drizzle + PostgreSQL: social login, email/password, organizations, role-based permissions. | Database | `/scaffold-auth` |
19
+ | Environment Variables | Feature | T3 Env + Zod: validated, type-safe env vars for Next.js (client/server split) and backend apps. | None | `/scaffold-env` |
20
+ | Tailwind v4 Design System | Feature | Full design system: shadcn tokens, animations, typography, sidebar/chart tokens, dark mode. | Foundation (recommended) | `/scaffold-tailwind` |
21
+ | UI Shared Components | Feature | Shared UI package: shadcn/ui, path-based exports, cn utility, component generation. | Tailwind v4 | `/scaffold-ui` |
18
22
 
19
23
  ## Project Context
20
24
 
@@ -32,6 +36,12 @@ Suggest a blueprint when you observe these signals. Be helpful, not pushy — me
32
36
 
33
37
  **`/scaffold-auth`** — User mentions login, signup, users, accounts, teams, organizations, permissions, or authentication. Or is implementing auth from scratch. Recommend `/scaffold-db` first if not already installed.
34
38
 
39
+ **`/scaffold-env`** — User mentions environment variables, `.env` files, env validation, type-safe config, T3 Env, or is accessing `process.env` directly. Or a Next.js app has no env validation. Standalone — works with any project.
40
+
41
+ **`/scaffold-tailwind`** — User mentions design system, shadcn setup, animations, typography plugin, dark mode theming, or the Tailwind config is missing shadcn integration. Best after foundation.
42
+
43
+ **`/scaffold-ui`** — User mentions shared components, UI package, component library, shadcn in monorepo, or needs to share components across apps. Recommend `/scaffold-tailwind` first if not installed.
44
+
35
45
  **`/audit`** — User asks "what should I do next?", wants to understand their project's state, or has hand-rolled infrastructure that a blueprint could improve.
36
46
 
37
47
  ## Lifecycle & Dependencies
@@ -42,7 +52,8 @@ Discovery → Foundation → Features is the recommended flow, but blueprints ca
42
52
  - **Single-repo project:** Skip foundation — go directly to feature blueprints (`/scaffold-db`, `/scaffold-auth`)
43
53
  - **Has monorepo, missing features:** Suggest specific feature blueprints
44
54
  - **Existing project:** Feature blueprints adapt to existing structures — no foundation required
45
- - **Dependencies:** `/scaffold-auth` works best after `/scaffold-db` (auth builds on db patterns). Install dependencies first.
55
+ - **Dependencies:** `/scaffold-auth` works best after `/scaffold-db` (auth builds on db patterns). `/scaffold-ui` requires `/scaffold-tailwind`. Install dependencies first.
56
+ - **Environment setup:** `/scaffold-env` is recommended for all projects — it's standalone and works with any combination of other blueprints
46
57
 
47
58
  ## Important
48
59
 
@@ -0,0 +1,222 @@
1
+ ---
2
+ name: scaffold-env
3
+ description: Scaffold T3 Env validated environment variables into the current project
4
+ ---
5
+
6
+ # Scaffold Env Blueprint
7
+
8
+ Scaffold the `env-t3` blueprint into the current project. Read the full blueprint first, then adapt it to this project's stack.
9
+
10
+ ## Step 1: Read the Blueprint
11
+
12
+ Read the full BLUEPRINT.md and all template files from the env blueprint:
13
+
14
+ ```
15
+ ~/.withmata/blueprints/blueprints/features/env-t3/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/features/env-t3/files/**/*
17
+ ```
18
+
19
+ If not found at these paths, run `npx @withmata/blueprints` to install.
20
+
21
+ ## Step 1.5: Read Project Context
22
+
23
+ Check if `.project-context.md` exists in the target project root:
24
+
25
+ - **If it exists**: read it to understand:
26
+ - Product name and scope (from Discovery)
27
+ - npm scope, workspace layout (from Foundation)
28
+ - What other blueprints are already installed (from Installed Blueprints)
29
+ - Use this information to pre-fill env variables and adapt file paths
30
+
31
+ - **If it does not exist**: proceed normally — explore the project manually (Step 2) and ask all configuration questions (Step 3)
32
+
33
+ When project context provides clear answers, skip the corresponding questions in Step 3. For example:
34
+ - Context has `auth-better-auth` installed -> pre-populate auth env vars
35
+ - Context has `env-t3` in Installed Blueprints -> warn about existing install
36
+
37
+ ## Step 2: Understand the Target Project
38
+
39
+ Before making any changes, explore the target project to understand:
40
+
41
+ ### 2a. Detect Project Type
42
+
43
+ Check `.project-context.md` for `project_type`. If not present, detect:
44
+
45
+ - **Monorepo indicators**: `pnpm-workspace.yaml`, `turbo.json`, `nx.json`, `lerna.json`, or `"workspaces"` in root `package.json`
46
+ - **Single-repo indicators**: Single `package.json` at root, `src/` directory, no workspace config
47
+
48
+ Confirm with user: "This looks like a [monorepo|single-repo] project. Is that right?"
49
+
50
+ ### 2b. Discover Apps
51
+
52
+ Find all applications that need env setup:
53
+
54
+ **Next.js apps** — look for:
55
+ - `next.config.ts` or `next.config.js` or `next.config.mjs`
56
+ - Typically in `apps/web/`, `apps/*/`, or project root (single-repo)
57
+
58
+ **Backend apps** — look for:
59
+ - `hono` or `express` or `@hono/node-server` in `package.json` dependencies
60
+ - Typically in `apis/*/`, `apps/server/`, or project root (single-repo)
61
+
62
+ ### 2c. Check Existing Env Setup
63
+
64
+ For each app found:
65
+ - Does `env.ts` already exist? (Foundation blueprint creates a basic one)
66
+ - Does `src/env/` directory exist? (Already has the split pattern)
67
+ - Does `.env.example` exist?
68
+ - Does `next.config.ts` already import env files?
69
+ - Are `@t3-oss/env-nextjs` or `@t3-oss/env-core` already installed?
70
+
71
+ ### 2d. Check Installed Blueprints
72
+
73
+ If other blueprints are installed, note their env vars so we can pre-populate:
74
+ - **auth-better-auth**: `BETTER_AUTH_URL`, `BETTER_AUTH_SECRET`, `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, `AUTH_DATABASE_URL`
75
+ - **db-drizzle-postgres**: `{{GROUP_UPPER}}_DATABASE_URL` (in db package, not app)
76
+
77
+ ## Step 3: Ask Clarifying Questions
78
+
79
+ Before scaffolding, ask the user:
80
+
81
+ 1. **Which apps to configure** — "I found these apps: [list]. Set up env validation for all of them?" (Default: yes, all)
82
+
83
+ 2. **Existing env.ts** — If an `env.ts` already exists: "I found an existing `env.ts`. I'll migrate it to the client/server split pattern and merge existing variables. Sound good?"
84
+
85
+ 3. **Pre-populate from installed blueprints** — If other blueprints are installed: "I see auth-better-auth is installed. Should I add its env vars to the server env schema?"
86
+
87
+ Skip questions where the answer is obvious from the project structure.
88
+
89
+ ## Step 4: Adapt and Scaffold
90
+
91
+ ### 4a. Next.js Apps
92
+
93
+ For each Next.js app:
94
+
95
+ **If `env.ts` exists (e.g., from foundation blueprint):**
96
+ 1. Read the existing `env.ts` to extract current variables
97
+ 2. Split variables: `NEXT_PUBLIC_*` -> `client.ts`, everything else -> `server.ts`
98
+ 3. Create `src/env/client.ts` with the client variables
99
+ 4. Create `src/env/server.ts` with the server variables
100
+ 5. Update `next.config.ts`:
101
+ - Replace `import "./env"` with `import "./src/env/server"` and `import "./src/env/client"`
102
+ - If no existing env import, add both imports at the top (before any other code)
103
+ 6. Delete the old `env.ts`
104
+
105
+ **If no existing env setup:**
106
+ 1. Create `src/env/client.ts` from template — replace `{{APP_NAME}}`
107
+ 2. Create `src/env/server.ts` from template — replace `{{APP_NAME}}`
108
+ 3. Update `next.config.ts` — add imports at the top
109
+
110
+ **For all Next.js apps:**
111
+ 4. Create `.env.example` from template — replace `{{APP_NAME}}`
112
+ 5. Create `.env.local` (empty file)
113
+ 6. If other blueprints are installed, merge their env vars into the appropriate schema
114
+
115
+ ### 4b. Backend Apps
116
+
117
+ For each backend app:
118
+
119
+ 1. Create `src/env.ts` from template — replace `{{APP_NAME}}`
120
+ 2. Update the app's entry point to import env:
121
+ ```typescript
122
+ import { env } from "./env.js";
123
+ ```
124
+ 3. Create `.env.example` from template — replace `{{APP_NAME}}`
125
+ 4. Create `.env.local` (empty file)
126
+ 5. If the app has hardcoded `process.env.PORT` or similar, refactor to use `env.PORT`
127
+
128
+ ### 4c. Dependency Installation
129
+
130
+ For each Next.js app:
131
+ - Ensure `@t3-oss/env-nextjs` and `zod` are in `dependencies`
132
+
133
+ For each backend app:
134
+ - Ensure `@t3-oss/env-core`, `zod`, and `dotenv` are in `dependencies`
135
+
136
+ ## Step 5: Update Project Context
137
+
138
+ Append an entry to `.project-context.md` under `## Installed Blueprints`:
139
+
140
+ ```yaml
141
+ ### env-t3
142
+ blueprint: env-t3
143
+ choices:
144
+ nextjs_env_location: src/env/
145
+ backend_env_location: src/env.ts
146
+ apps_configured:
147
+ - name: <app name>
148
+ type: <nextjs|backend>
149
+ files:
150
+ - <list of files created>
151
+ packages_added:
152
+ - <list of packages added>
153
+ ```
154
+
155
+ If `.project-context.md` does not exist, create it with the standard header and the Installed Blueprints section.
156
+
157
+ ### Create Maintenance Skill
158
+
159
+ Create a project-level maintenance skill for the env blueprint:
160
+
161
+ **File:** `<project>/.claude/skills/env-maintenance/SKILL.md`
162
+
163
+ ```yaml
164
+ ---
165
+ name: env-maintenance
166
+ description: Maintenance rules for T3 Env validated environment variables. Invoke when adding, removing, or modifying environment variables.
167
+ user-invocable: false
168
+ ---
169
+
170
+ ### env-t3 maintenance
171
+ - After adding a new env var: add it to the env schema file (client.ts or server.ts), `.env.example`, and `.env.local`
172
+ - NEXT_PUBLIC_* vars go in env/client.ts with explicit runtimeEnv mapping; server vars go in env/server.ts
173
+ - After removing an env var: remove from schema, .env.example, and .env.local
174
+ - Never access process.env directly — always use the typed env objects (clientEnv, serverEnv, or env)
175
+ - Keep .env.example documented with section headers and local/production hints
176
+ ```
177
+
178
+ ## Step 6: Output Summary
179
+
180
+ After scaffolding, provide the user with a clear summary:
181
+
182
+ ### Packages to Install
183
+
184
+ **Next.js apps:**
185
+ ```bash
186
+ pnpm add @t3-oss/env-nextjs zod
187
+ ```
188
+
189
+ **Backend apps:**
190
+ ```bash
191
+ pnpm add @t3-oss/env-core zod dotenv
192
+ ```
193
+
194
+ ### Files Created
195
+
196
+ List every file that was created or modified, with a one-line description.
197
+
198
+ ### How to Use
199
+
200
+ ```typescript
201
+ // In server components, API routes, server actions:
202
+ import { serverEnv } from "~/env/server";
203
+
204
+ // In client components:
205
+ import { clientEnv } from "~/env/client";
206
+
207
+ // In backend apps:
208
+ import { env } from "./env.js";
209
+ ```
210
+
211
+ ### Next Steps
212
+
213
+ - Fill in `.env.local` with your actual values (use `.env.example` as reference)
214
+ - As you add features, add their env vars to the schema files and `.env.example`
215
+ - Run `pnpm dev` to verify env validation passes
216
+
217
+ ## Important Notes
218
+
219
+ - When adapting code, preserve the `// CONFIGURE:` comments so the user can find customization points later.
220
+ - Never overwrite existing files without asking. If env files exist, merge new variables into them.
221
+ - If `next.config.ts` already imports env files, don't add duplicate imports.
222
+ - The env schema files are the source of truth for what variables an app needs — keep them accurate.
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: scaffold-tailwind
3
+ description: Scaffold Tailwind v4 full design system into the current project
4
+ ---
5
+
6
+ # Scaffold Tailwind v4 Blueprint
7
+
8
+ Scaffold the `tailwind-v4` blueprint into the current project. This upgrades the foundation's minimal tailwind-config into a production-ready design system with animations, typography, sidebar tokens, and full shadcn/ui integration.
9
+
10
+ ## Step 1: Read the Blueprint
11
+
12
+ Read the full BLUEPRINT.md and all template files from the tailwind blueprint:
13
+
14
+ ```
15
+ ~/.withmata/blueprints/blueprints/features/tailwind-v4/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/features/tailwind-v4/files/**/*
17
+ ```
18
+
19
+ If not found at these paths, run `npx @withmata/blueprints` to install.
20
+
21
+ ## Step 1.5: Read Project Context
22
+
23
+ Check if `.project-context.md` exists in the target project root:
24
+
25
+ - **If it exists**: read it to understand:
26
+ - npm scope (from Foundation)
27
+ - Whether `monorepo-turbo` foundation is installed
28
+ - What other blueprints are already installed
29
+ - Use this to determine if `config/tailwind-config/` exists
30
+
31
+ - **If it does not exist**: proceed normally — explore the project manually
32
+
33
+ ## Step 2: Understand the Target Project
34
+
35
+ ### 2a. Detect Project Type
36
+
37
+ Check `.project-context.md` for `project_type`. If not present, detect:
38
+
39
+ - **Monorepo indicators**: `pnpm-workspace.yaml`, `turbo.json`, or `"workspaces"` in root `package.json`
40
+ - **Single-repo indicators**: Single `package.json` at root, `src/` directory
41
+
42
+ ### 2b. Check Existing Tailwind Setup
43
+
44
+ - Does `config/tailwind-config/` exist? (Foundation blueprint creates this)
45
+ - Read existing `shared-styles.css` — is it the minimal version or already upgraded?
46
+ - Read existing `package.json` — what deps are already present?
47
+ - Check `tailwind-v4` in `.project-context.md` Installed Blueprints — already installed?
48
+
49
+ ## Step 3: Ask Clarifying Questions
50
+
51
+ 1. **Sidebar tokens** — "Include sidebar-specific color tokens for dashboard layouts? (Default: yes)"
52
+ 2. **Chart tokens** — "Include chart color tokens for data visualization? (Default: yes)"
53
+
54
+ Skip questions if the user has indicated preferences or if the project type makes the answer obvious.
55
+
56
+ ## Step 4: Adapt and Scaffold
57
+
58
+ ### 4a. Monorepo — Upgrade Existing Config
59
+
60
+ **If `config/tailwind-config/` exists (foundation was run):**
61
+
62
+ 1. **Replace `shared-styles.css`** — Copy the full version from this blueprint, replacing the foundation's minimal version entirely. The full version includes everything the minimal version had, plus:
63
+ - `@import "tw-animate-css"`
64
+ - `@import "shadcn/tailwind.css"`
65
+ - `@import "tailwind-scrollbar-hide/v4"`
66
+ - Sidebar tokens (`--color-sidebar-*`)
67
+ - Chart tokens (`--color-chart-*`)
68
+ - Extended radius tokens (`--radius-3xl`, `--radius-4xl`)
69
+ - Font mono token (`--font-mono`)
70
+
71
+ 2. **Merge `package.json` dependencies** — Add these to the existing `dependencies`:
72
+ - `@tailwindcss/typography`
73
+ - `shadcn`
74
+ - `tailwind-scrollbar-hide`
75
+ - `tw-animate-css`
76
+ Keep existing `devDependencies` unchanged.
77
+
78
+ 3. **Leave `postcss.config.mjs` unchanged** — it's already correct from foundation.
79
+
80
+ **If `config/tailwind-config/` does NOT exist:**
81
+
82
+ 1. Create the `config/tailwind-config/` directory
83
+ 2. Copy `shared-styles.css` from template
84
+ 3. Copy `package.json` from template — replace `{{SCOPE}}`
85
+ 4. Create `postcss.config.mjs`:
86
+ ```javascript
87
+ export const postcssConfig = {
88
+ plugins: {
89
+ "@tailwindcss/postcss": {},
90
+ },
91
+ };
92
+ ```
93
+
94
+ ### 4b. Single-Repo
95
+
96
+ 1. Create `src/styles/shared-styles.css` from template
97
+ 2. Add all design system deps to root `package.json`
98
+ 3. Update `globals.css` or equivalent to import the shared styles:
99
+ ```css
100
+ @import "./src/styles/shared-styles.css";
101
+ ```
102
+
103
+ ### 4c. Install Dependencies
104
+
105
+ Run `pnpm install` (or the project's package manager) to fetch new dependencies.
106
+
107
+ ## Step 5: Update Project Context
108
+
109
+ Append an entry to `.project-context.md` under `## Installed Blueprints`:
110
+
111
+ ```yaml
112
+ ### tailwind-v4
113
+ blueprint: tailwind-v4
114
+ choices:
115
+ include_sidebar_tokens: <true|false>
116
+ include_chart_tokens: <true|false>
117
+ include_scrollbar_hide: <true|false>
118
+ files_modified:
119
+ - config/tailwind-config/shared-styles.css
120
+ - config/tailwind-config/package.json
121
+ packages_added:
122
+ - "@tailwindcss/typography"
123
+ - shadcn
124
+ - tailwind-scrollbar-hide
125
+ - tw-animate-css
126
+ ```
127
+
128
+ ### Create Maintenance Skill
129
+
130
+ Create a project-level maintenance skill:
131
+
132
+ **File:** `<project>/.claude/skills/tailwind-maintenance/SKILL.md`
133
+
134
+ ```yaml
135
+ ---
136
+ name: tailwind-maintenance
137
+ description: Maintenance rules for Tailwind v4 design system. Invoke when modifying theme tokens, colors, or adding new apps.
138
+ user-invocable: false
139
+ ---
140
+
141
+ ### tailwind-v4 maintenance
142
+ - After adding a new color: add CSS variable to both :root and .dark selectors in shared-styles.css, then map in @theme inline
143
+ - After adding a new app: import the tailwind-config package in the app's globals.css
144
+ - After upgrading Tailwind: check for @import, @theme, or @custom-variant breaking changes
145
+ - Never use tailwind.config.js — all configuration is CSS-based in shared-styles.css
146
+ - Colors use OKLCH color space — do not use hex or RGB
147
+ ```
148
+
149
+ ## Step 6: Output Summary
150
+
151
+ ### Packages Added
152
+
153
+ ```
154
+ @tailwindcss/typography, shadcn, tailwind-scrollbar-hide, tw-animate-css
155
+ ```
156
+
157
+ ### Files Modified
158
+
159
+ List every file created or modified with a one-line description.
160
+
161
+ ### What Changed from Foundation
162
+
163
+ - `shared-styles.css` upgraded with animation imports, sidebar tokens, chart tokens, scrollbar utility
164
+ - `package.json` now includes design system dependencies
165
+ - Typography plugin available (add `@plugin "@tailwindcss/typography"` in app globals.css)
166
+
167
+ ### Next Steps
168
+
169
+ - Add `@plugin "@tailwindcss/typography"` to your app's `globals.css` if you need prose styling
170
+ - Customize the primary color hue in `:root` and `.dark` (currently indigo at hue 264)
171
+ - Run `/scaffold-ui` to set up a shared component library that uses this design system
172
+
173
+ ## Important Notes
174
+
175
+ - The full `shared-styles.css` is a complete replacement — it includes everything the foundation's minimal version had plus the new additions.
176
+ - Never overwrite `postcss.config.mjs` — it's already correct from the foundation.
177
+ - If the user has customized colors in the existing `shared-styles.css`, ask before replacing. Offer to merge their custom values into the new file.
@@ -0,0 +1,206 @@
1
+ ---
2
+ name: scaffold-ui
3
+ description: Scaffold shared UI component library with shadcn/ui into the current project
4
+ ---
5
+
6
+ # Scaffold UI Blueprint
7
+
8
+ Scaffold the `ui-shared-components` blueprint into the current project. Read the full blueprint first, then adapt it to this project's stack.
9
+
10
+ ## Step 1: Read the Blueprint
11
+
12
+ Read the full BLUEPRINT.md and all template files from the UI blueprint:
13
+
14
+ ```
15
+ ~/.withmata/blueprints/blueprints/features/ui-shared-components/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/features/ui-shared-components/files/**/*
17
+ ```
18
+
19
+ If not found at these paths, run `npx @withmata/blueprints` to install.
20
+
21
+ ## Step 1.5: Read Project Context
22
+
23
+ Check if `.project-context.md` exists in the target project root:
24
+
25
+ - **If it exists**: read it to understand:
26
+ - npm scope (from Foundation)
27
+ - Whether `tailwind-v4` is installed (required dependency)
28
+ - What other blueprints are installed
29
+ - Use this to pre-fill scope and adapt paths
30
+
31
+ - **If it does not exist**: proceed normally — explore the project manually
32
+
33
+ When project context provides clear answers, skip the corresponding questions in Step 3.
34
+
35
+ ## Step 2: Understand the Target Project
36
+
37
+ ### 2a. Detect Project Type
38
+
39
+ Check `.project-context.md` for `project_type`. If not present, detect:
40
+
41
+ - **Monorepo indicators**: `pnpm-workspace.yaml`, `turbo.json`, or `"workspaces"` in root `package.json`
42
+ - **Single-repo indicators**: Single `package.json` at root, `src/` directory
43
+
44
+ ### 2b. Check Blueprint Dependencies
45
+
46
+ **Required: `tailwind-v4`**
47
+
48
+ Check if `tailwind-v4` is in `.project-context.md` Installed Blueprints, OR check if `config/tailwind-config/shared-styles.css` contains `@import "tw-animate-css"` (indicator of the full tailwind-v4 blueprint).
49
+
50
+ If NOT installed: ask "UI components need the Tailwind design system. Run `/scaffold-tailwind` first? (Y/n)"
51
+ - If yes: tell the user to run `/scaffold-tailwind` first, then come back
52
+ - If no: proceed with basic Tailwind defaults and warn about missing design tokens
53
+
54
+ ### 2c. Explore Structure
55
+
56
+ **If monorepo:**
57
+ 1. Does `packages/ui/` already exist? If so, what's in it?
58
+ 2. What npm scope is used?
59
+ 3. What is the shared TypeScript config package name?
60
+ 4. Where are the consuming apps? (`apps/web/`, `apps/*/`, etc.)
61
+ 5. What's in the consuming app's `globals.css`?
62
+
63
+ **If single-repo:**
64
+ 1. Does `src/ui/` or `src/components/` exist?
65
+ 2. What framework is this? (Next.js?)
66
+ 3. What import convention is used? (`@/`, `#`, relative?)
67
+
68
+ ## Step 3: Ask Clarifying Questions
69
+
70
+ 1. **shadcn style** — "Which shadcn style do you prefer? (Default: new-york)" Only ask if the user hasn't specified.
71
+
72
+ 2. **Icon library** — "Which icon library? Lucide (default, shadcn default), Phosphor (richer set), or custom?"
73
+
74
+ 3. **Existing `packages/ui/`** — If it exists: "I found an existing `packages/ui/`. I'll merge the new files without overwriting existing ones."
75
+
76
+ Skip questions where the answer is obvious.
77
+
78
+ ## Step 4: Adapt and Scaffold
79
+
80
+ ### 4a. Monorepo — Create UI Package
81
+
82
+ 1. Create `packages/ui/` directory (if it doesn't exist)
83
+ 2. Copy `package.json` — replace `{{SCOPE}}` with the project's npm scope
84
+ 3. Copy `tsconfig.json` — replace `{{SCOPE}}`
85
+ 4. Copy `components.json` — update style if user chose something other than `new-york`, update iconLibrary if user chose something other than `lucide`
86
+ 5. Create `styles/` directory and copy `globals.css` — replace `{{SCOPE}}`
87
+ 6. Create `utils/` directory, copy `cn.ts` and `cva.ts`
88
+ 7. Create empty directories: `components/ui/`, `icons/`, `icons/logos/`
89
+
90
+ ### 4b. Single-Repo — Create UI Directory
91
+
92
+ 1. Create `src/ui/` directory structure
93
+ 2. Copy utility files (`cn.ts`, `cva.ts`) to `src/ui/utils/`
94
+ 3. Copy `styles/globals.css` to `src/ui/styles/` — adjust import to direct path
95
+ 4. Copy `components.json` to project root — update aliases for single-repo paths
96
+ 5. Create empty directories: `src/ui/components/ui/`, `src/ui/icons/`
97
+ 6. Add UI deps to root `package.json`
98
+
99
+ ### 4c. Update Consuming App
100
+
101
+ **For each Next.js app (monorepo):**
102
+
103
+ Update `app/globals.css`. The final file should look like:
104
+
105
+ ```css
106
+ @import "tailwindcss";
107
+ @import "{{SCOPE}}/tailwind-config";
108
+ @import "{{SCOPE}}/ui/styles";
109
+ @plugin "@tailwindcss/typography";
110
+
111
+ @source "../../../packages/ui";
112
+ ```
113
+
114
+ Compute the `@source` relative path based on the consuming app's location relative to `packages/ui/`. For example:
115
+ - `apps/web/` → `@source "../../../packages/ui"` (if workspace root is 3 levels up... actually the typical path is `../../packages/ui` since apps/web/ is 2 levels)
116
+ - Verify the path resolves correctly
117
+
118
+ **Important:** Don't overwrite the entire `globals.css` — merge the new imports. If the file already has `@import "tailwindcss"` and `@import "{{SCOPE}}/tailwind-config"`, add the new lines after them.
119
+
120
+ ### 4d. Dependency Installation
121
+
122
+ Run `pnpm install` to wire workspace dependencies.
123
+
124
+ ## Step 5: Update Project Context
125
+
126
+ Append an entry to `.project-context.md` under `## Installed Blueprints`:
127
+
128
+ ```yaml
129
+ ### ui-shared-components
130
+ blueprint: ui-shared-components
131
+ choices:
132
+ shadcn_style: <style>
133
+ icon_library: <library>
134
+ include_cva: true
135
+ files_created:
136
+ - <list of all files created>
137
+ globals_css_updated:
138
+ - <list of globals.css files modified>
139
+ packages_added:
140
+ - <list of packages>
141
+ ```
142
+
143
+ ### Create Maintenance Skill
144
+
145
+ Create a project-level maintenance skill:
146
+
147
+ **File:** `<project>/.claude/skills/ui-maintenance/SKILL.md`
148
+
149
+ ```yaml
150
+ ---
151
+ name: ui-maintenance
152
+ description: Maintenance rules for shared UI component library. Invoke when adding components, icons, or modifying the UI package.
153
+ user-invocable: false
154
+ ---
155
+
156
+ ### ui-shared-components maintenance
157
+ - Add shadcn components via `pnpm dlx shadcn@latest add <name>` from packages/ui/
158
+ - Use cn() for all className composition — never concatenate class strings manually
159
+ - Internal imports use #prefix (#components/ui/button); cross-package imports use @scope/ui/components/ui/button
160
+ - After adding a new export directory: add to both exports and imports in packages/ui/package.json
161
+ - After adding a new consuming app: add @import and @source directive to the app's globals.css
162
+ ```
163
+
164
+ ## Step 6: Output Summary
165
+
166
+ ### Packages to Install
167
+
168
+ ```bash
169
+ # Should be handled by pnpm install, but verify these are in packages/ui/package.json:
170
+ # Dependencies: @radix-ui/react-slot, class-variance-authority, clsx, tailwind-merge, tw-animate-css, shadcn
171
+ # DevDeps: @tailwindcss/postcss, tailwindcss, typescript, @types/react, @types/react-dom
172
+ ```
173
+
174
+ ### Files Created
175
+
176
+ List every file created or modified with a one-line description.
177
+
178
+ ### How to Add Components
179
+
180
+ ```bash
181
+ # From packages/ui/
182
+ cd packages/ui
183
+ pnpm dlx shadcn@latest add button
184
+ pnpm dlx shadcn@latest add card
185
+ pnpm dlx shadcn@latest add input
186
+ ```
187
+
188
+ ### How to Use in Apps
189
+
190
+ ```typescript
191
+ import { Button } from "@scope/ui/components/ui/button";
192
+ import { cn } from "@scope/ui/utils/cn";
193
+ ```
194
+
195
+ ### Next Steps
196
+
197
+ - Add your first shadcn components with the commands above
198
+ - Create brand icons in `packages/ui/icons/logos/`
199
+ - Build custom components in `packages/ui/components/`
200
+
201
+ ## Important Notes
202
+
203
+ - When adapting code, preserve the `// CONFIGURE:` comments so the user can find customization points later.
204
+ - Never overwrite existing files without asking. If `packages/ui/` exists, merge new files.
205
+ - The `@source` directive path must be correct relative to the consuming app — verify it resolves.
206
+ - If `tailwind-v4` is not installed and the user proceeds anyway, the UI package will work but may have missing design tokens (no animations, no sidebar colors, etc.).