@withmata/blueprints 0.3.1 → 0.3.3
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.
- package/.claude/skills/blueprint-catalog/SKILL.md +13 -2
- package/.claude/skills/scaffold-auth/SKILL.md +2 -2
- package/.claude/skills/scaffold-env/SKILL.md +222 -0
- package/.claude/skills/scaffold-foundation/SKILL.md +166 -16
- package/.claude/skills/scaffold-tailwind/SKILL.md +177 -0
- package/.claude/skills/scaffold-ui/SKILL.md +206 -0
- package/blueprints/features/env-t3/BLUEPRINT.md +332 -0
- package/blueprints/features/env-t3/files/nextjs/.env.example +17 -0
- package/blueprints/features/env-t3/files/nextjs/.env.local +0 -0
- package/blueprints/features/env-t3/files/nextjs/env/client.ts +13 -0
- package/blueprints/features/env-t3/files/nextjs/env/server.ts +12 -0
- package/blueprints/features/env-t3/files/server/.env.example +14 -0
- package/blueprints/features/env-t3/files/server/.env.local +0 -0
- package/blueprints/features/env-t3/files/server/env.ts +17 -0
- package/blueprints/features/tailwind-v4/BLUEPRINT.md +262 -12
- package/blueprints/features/tailwind-v4/files/tailwind-config/package.json +20 -0
- package/blueprints/features/tailwind-v4/files/tailwind-config/shared-styles.css +131 -0
- package/blueprints/features/ui-shared-components/BLUEPRINT.md +350 -13
- package/blueprints/features/ui-shared-components/files/ui/components.json +21 -0
- package/blueprints/features/ui-shared-components/files/ui/package.json +42 -0
- package/blueprints/features/ui-shared-components/files/ui/styles/globals.css +2 -0
- package/blueprints/features/ui-shared-components/files/ui/tsconfig.json +9 -0
- package/blueprints/features/ui-shared-components/files/ui/utils/cn.ts +6 -0
- package/blueprints/features/ui-shared-components/files/ui/utils/cva.ts +4 -0
- package/dist/index.js +1 -1
- 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,
|
|
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
|
|
|
@@ -138,7 +138,7 @@ Based on the project structure, project context, and user answers, adapt the blu
|
|
|
138
138
|
- Replace `{{APP_NAME}}`, `{{EMAIL_FROM}}`, `{{SCOPE}}`
|
|
139
139
|
- Copy/adapt `files/server/auth-db.ts` -> `apis/server/src/db/auth.ts`
|
|
140
140
|
- Copy/adapt `files/server/middleware.ts` -> `apis/server/src/middleware/auth.ts`
|
|
141
|
-
- Merge auth env vars into `apis/server/src/env.ts`
|
|
141
|
+
- Merge auth env vars into `apis/server/src/env.ts` (if env-t3 is installed, this uses `@t3-oss/env-core` with Zod schemas — add vars to the `server` schema object)
|
|
142
142
|
|
|
143
143
|
**If single-repo:**
|
|
144
144
|
- Copy/adapt `files/server/auth.ts` -> `src/lib/auth/index.ts`
|
|
@@ -146,7 +146,7 @@ Based on the project structure, project context, and user answers, adapt the blu
|
|
|
146
146
|
- Adjust DB import to use direct path: `import { db } from "@/db/auth/client"` or `#db/auth/client`
|
|
147
147
|
- Copy/adapt `files/server/auth-db.ts` -> `src/lib/db/auth.ts`
|
|
148
148
|
- Default to Next.js API routes (no separate Hono server)
|
|
149
|
-
- Merge auth env vars into existing `env.ts` (or create one)
|
|
149
|
+
- Merge auth env vars into existing env files. If env-t3 is installed (check for `src/env/server.ts`), add server vars to `src/env/server.ts` and client vars to `src/env/client.ts`. Otherwise merge into `env.ts` (or create one).
|
|
150
150
|
|
|
151
151
|
**Both:**
|
|
152
152
|
- If the project uses a different server framework than Hono, adapt the middleware while keeping the core `auth.api.getSession({ headers })` pattern
|
|
@@ -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.
|
|
@@ -7,18 +7,34 @@ description: Set up a Turborepo + pnpm monorepo skeleton (skip for single-repo a
|
|
|
7
7
|
|
|
8
8
|
Set up the monorepo project skeleton using the foundation blueprint. **For single-repo applications** (standalone Next.js, Node, or Bun apps), skip this command and go directly to feature blueprints (`/scaffold-db`, `/scaffold-auth`) — they detect single-repo projects and adapt automatically.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This skill operates in two modes:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- **Install mode** (default) — fresh scaffold of the full monorepo skeleton
|
|
13
|
+
- **Upgrade mode** — detects an existing foundation install and offers to apply updates (new features added to blueprints since the original install)
|
|
14
|
+
|
|
15
|
+
## Step 1: Read the Blueprints
|
|
16
|
+
|
|
17
|
+
Read the foundation blueprint and all template files:
|
|
13
18
|
|
|
14
19
|
```
|
|
15
20
|
~/.withmata/blueprints/blueprints/foundation/monorepo-turbo/BLUEPRINT.md
|
|
16
21
|
~/.withmata/blueprints/blueprints/foundation/monorepo-turbo/files/**/*
|
|
17
22
|
```
|
|
18
23
|
|
|
24
|
+
Also read the feature blueprints that foundation can optionally include:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
~/.withmata/blueprints/blueprints/features/env-t3/BLUEPRINT.md
|
|
28
|
+
~/.withmata/blueprints/blueprints/features/env-t3/files/**/*
|
|
29
|
+
~/.withmata/blueprints/blueprints/features/tailwind-v4/BLUEPRINT.md
|
|
30
|
+
~/.withmata/blueprints/blueprints/features/tailwind-v4/files/**/*
|
|
31
|
+
~/.withmata/blueprints/blueprints/features/ui-shared-components/BLUEPRINT.md
|
|
32
|
+
~/.withmata/blueprints/blueprints/features/ui-shared-components/files/**/*
|
|
33
|
+
```
|
|
34
|
+
|
|
19
35
|
If not found, run `npx @withmata/blueprints` to install.
|
|
20
36
|
|
|
21
|
-
The BLUEPRINT.md
|
|
37
|
+
The BLUEPRINT.md files contain the full architecture documentation, naming conventions, folder conventions, and file manifests. Follow them precisely.
|
|
22
38
|
|
|
23
39
|
## Step 2: Read Project Context
|
|
24
40
|
|
|
@@ -26,12 +42,48 @@ Check if `.project-context.md` exists in the target project root:
|
|
|
26
42
|
|
|
27
43
|
- **If it has a Discovery section**: use the product name to derive the npm scope (e.g., "Acme Dashboard" -> `@acme`). Use technical constraints to inform any decisions.
|
|
28
44
|
|
|
29
|
-
- **If it has a Foundation section already**:
|
|
45
|
+
- **If it has a Foundation section already**: **switch to upgrade mode** (see Step 2b below).
|
|
46
|
+
|
|
47
|
+
- **If no context file exists**: that is fine. Ask the user directly for the product name and npm scope. Proceed with install mode.
|
|
48
|
+
|
|
49
|
+
### Step 2b: Upgrade Mode Detection
|
|
50
|
+
|
|
51
|
+
When foundation is already installed, compare what's currently in the project against what the blueprints now offer. Check for:
|
|
52
|
+
|
|
53
|
+
1. **Foundation file updates** — Compare each foundation template file against the installed version. Flag files where the blueprint template has changed (e.g., updated `turbo.json` task structure, new fields in `package.json`).
|
|
54
|
+
|
|
55
|
+
2. **Missing features** — Check `.project-context.md` Installed Blueprints for:
|
|
56
|
+
- `env-t3` — Is it installed? If not, apply it automatically (env validation is not optional).
|
|
57
|
+
- `tailwind-v4` + `ui-shared-components` — Are they installed? If not, flag as available (frontend UI is optional).
|
|
58
|
+
|
|
59
|
+
3. **Present findings to the user:**
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Foundation was installed on <date>. Here's what's available:
|
|
30
63
|
|
|
31
|
-
|
|
64
|
+
Updates to existing files:
|
|
65
|
+
☐ turbo.json — new task caching strategy
|
|
66
|
+
☐ apps/web/next.config.ts — updated config pattern
|
|
67
|
+
|
|
68
|
+
Auto-applying:
|
|
69
|
+
✓ Validated environment variables (env-t3) — type-safe env with client/server split
|
|
70
|
+
|
|
71
|
+
New features (not yet installed):
|
|
72
|
+
☐ Frontend UI setup (tailwind-v4 + ui-shared-components) — full design system and shared component library
|
|
73
|
+
|
|
74
|
+
Which would you like to apply?
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
4. Apply only what the user selects. For each selected feature, follow its blueprint's integration steps (adapted to the existing project). Skip configuration questions where the answer is already in `.project-context.md`.
|
|
78
|
+
|
|
79
|
+
5. Update `.project-context.md` with the newly installed features and update `foundation_completed` date.
|
|
80
|
+
|
|
81
|
+
After upgrade mode completes, skip to Step 7 (Summarize).
|
|
32
82
|
|
|
33
83
|
## Step 3: Understand Current State
|
|
34
84
|
|
|
85
|
+
*(Install mode only — skipped in upgrade mode)*
|
|
86
|
+
|
|
35
87
|
Explore the target project directory:
|
|
36
88
|
|
|
37
89
|
- Is it empty? Fresh start — scaffold everything.
|
|
@@ -40,12 +92,20 @@ Explore the target project directory:
|
|
|
40
92
|
|
|
41
93
|
## Step 4: Ask Configuration Questions
|
|
42
94
|
|
|
43
|
-
|
|
95
|
+
*(Install mode only — skipped in upgrade mode)*
|
|
96
|
+
|
|
97
|
+
Core questions — skip any already answered by project context:
|
|
44
98
|
|
|
45
99
|
1. **npm scope** — "What npm scope should internal packages use? (e.g., @acme)" Default: derive from product name.
|
|
46
100
|
2. **Project name** — "What is the human-readable project name?" (for metadata, page titles). Default: from discovery context.
|
|
47
101
|
3. **Node.js version** — "Target Node.js version?" Default: `>=22`.
|
|
48
102
|
|
|
103
|
+
Optional feature question — ask after the core questions:
|
|
104
|
+
|
|
105
|
+
4. **Frontend UI** — "Will this project have frontend work? If yes, I'll set up the full Tailwind design system and a shared UI component library (`packages/ui/`) with shadcn/ui. (Y/n)" Default: yes. If yes, applies both tailwind-v4 and ui-shared-components together.
|
|
106
|
+
|
|
107
|
+
**Note:** Validated environment variables (env-t3) are always set up — not optional. Every app gets type-safe env validation.
|
|
108
|
+
|
|
49
109
|
## Step 5: Scaffold
|
|
50
110
|
|
|
51
111
|
Create the monorepo skeleton by adapting all files from the blueprint. Replace placeholders:
|
|
@@ -66,7 +126,7 @@ From `files/root/`, create at project root:
|
|
|
66
126
|
|
|
67
127
|
From `files/config/`, create:
|
|
68
128
|
- `config/typescript-config/` — base.json, nextjs.json, react-library.json, package.json
|
|
69
|
-
- `config/tailwind-config/` — shared-styles.css, postcss.config.
|
|
129
|
+
- `config/tailwind-config/` — shared-styles.css, postcss.config.mjs, package.json
|
|
70
130
|
|
|
71
131
|
### 5c. Next.js App Shell
|
|
72
132
|
|
|
@@ -93,9 +153,73 @@ After creating all files:
|
|
|
93
153
|
2. Run `pnpm install` to verify the workspace configuration is valid
|
|
94
154
|
3. Verify the dev server starts: `pnpm dev` (briefly — just check it boots)
|
|
95
155
|
|
|
156
|
+
## Step 5.5: Optional Features
|
|
157
|
+
|
|
158
|
+
Apply the optional features the user said yes to in Step 4. Each feature follows its own blueprint's integration steps but within the same session — no need to run separate scaffold commands.
|
|
159
|
+
|
|
160
|
+
### 5.5a. Environment Variables (always applied)
|
|
161
|
+
|
|
162
|
+
Follow the `env-t3` blueprint's integration steps:
|
|
163
|
+
|
|
164
|
+
1. Create `apps/web/src/env/client.ts` and `apps/web/src/env/server.ts` from env-t3 templates
|
|
165
|
+
2. Replace the foundation's `apps/web/env.ts` with the split pattern
|
|
166
|
+
3. Update `apps/web/next.config.ts` — replace `import "./env"` with:
|
|
167
|
+
```typescript
|
|
168
|
+
import "./src/env/server";
|
|
169
|
+
import "./src/env/client";
|
|
170
|
+
```
|
|
171
|
+
4. Create `apps/web/.env.example` from env-t3 template — replace `{{APP_NAME}}`
|
|
172
|
+
5. Create `apps/web/.env.local` (empty)
|
|
173
|
+
6. Ensure `@t3-oss/env-nextjs` and `zod` are in `apps/web/package.json` dependencies
|
|
174
|
+
|
|
175
|
+
### 5.5b. Frontend UI Setup (if opted in)
|
|
176
|
+
|
|
177
|
+
When the user opts in to frontend work, apply both tailwind-v4 and ui-shared-components together as a single step.
|
|
178
|
+
|
|
179
|
+
**Tailwind design system** — follow the `tailwind-v4` blueprint's integration steps:
|
|
180
|
+
|
|
181
|
+
1. Replace `config/tailwind-config/shared-styles.css` with the full version from the tailwind-v4 blueprint (includes `tw-animate-css`, `shadcn/tailwind.css`, `tailwind-scrollbar-hide`, sidebar tokens, chart tokens)
|
|
182
|
+
2. Merge tailwind-v4 dependencies into `config/tailwind-config/package.json`:
|
|
183
|
+
- Add `@tailwindcss/typography`, `shadcn`, `tailwind-scrollbar-hide`, `tw-animate-css` to `dependencies`
|
|
184
|
+
|
|
185
|
+
**Shared UI package** — follow the `ui-shared-components` blueprint's integration steps:
|
|
186
|
+
|
|
187
|
+
1. Create `packages/ui/` with all files from the ui blueprint:
|
|
188
|
+
- `package.json` — replace `{{SCOPE}}`
|
|
189
|
+
- `tsconfig.json` — replace `{{SCOPE}}`
|
|
190
|
+
- `components.json`
|
|
191
|
+
- `styles/globals.css` — replace `{{SCOPE}}`
|
|
192
|
+
- `utils/cn.ts`
|
|
193
|
+
- `utils/cva.ts`
|
|
194
|
+
2. Create empty directories: `packages/ui/components/ui/`, `packages/ui/icons/`, `packages/ui/icons/logos/`
|
|
195
|
+
3. Update `apps/web/app/globals.css` to import UI styles:
|
|
196
|
+
```css
|
|
197
|
+
@import "tailwindcss";
|
|
198
|
+
@import "{{SCOPE}}/tailwind-config";
|
|
199
|
+
@import "{{SCOPE}}/ui/styles";
|
|
200
|
+
@plugin "@tailwindcss/typography";
|
|
201
|
+
|
|
202
|
+
@source "../../packages/ui";
|
|
203
|
+
```
|
|
204
|
+
Compute the `@source` relative path based on the actual directory structure.
|
|
205
|
+
|
|
206
|
+
### 5.5d. Re-install
|
|
207
|
+
|
|
208
|
+
If any optional features were applied:
|
|
209
|
+
1. Run `pnpm install` again to wire new workspace dependencies
|
|
210
|
+
2. Verify `pnpm dev` still boots cleanly
|
|
211
|
+
|
|
96
212
|
## Step 6: Update Project Context
|
|
97
213
|
|
|
98
|
-
|
|
214
|
+
**This step is mandatory.** The `.project-context.md` file is how other blueprints and future runs of `/scaffold-foundation` (upgrade mode) know what's been set up. Without it, every subsequent blueprint runs blind.
|
|
215
|
+
|
|
216
|
+
If `.project-context.md` does not exist, create it now:
|
|
217
|
+
|
|
218
|
+
```markdown
|
|
219
|
+
# Project Context
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Then append the `## Foundation` section:
|
|
99
223
|
|
|
100
224
|
```yaml
|
|
101
225
|
## Foundation
|
|
@@ -103,10 +227,11 @@ monorepo_tool: turborepo
|
|
|
103
227
|
package_manager: pnpm
|
|
104
228
|
npm_scope: "<scope>"
|
|
105
229
|
node_version: ">=22"
|
|
230
|
+
project_type: monorepo
|
|
106
231
|
workspaces:
|
|
107
232
|
apps: ["web"]
|
|
108
233
|
apis: []
|
|
109
|
-
packages: []
|
|
234
|
+
packages: ["ui"] # if frontend UI was applied, otherwise []
|
|
110
235
|
config: ["typescript-config", "tailwind-config"]
|
|
111
236
|
framework: next.js (app router)
|
|
112
237
|
typescript: strict
|
|
@@ -117,11 +242,20 @@ module_resolution: node subpath imports (#prefix)
|
|
|
117
242
|
foundation_completed: <date>
|
|
118
243
|
```
|
|
119
244
|
|
|
120
|
-
|
|
245
|
+
Then append `## Installed Blueprints` with entries for every feature that was applied:
|
|
246
|
+
|
|
247
|
+
```markdown
|
|
248
|
+
## Installed Blueprints
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
- Always add the `env-t3` project context block (see env-t3 BLUEPRINT.md)
|
|
252
|
+
- If frontend UI was applied: add both the `tailwind-v4` and `ui-shared-components` project context blocks (see their BLUEPRINT.md files)
|
|
253
|
+
|
|
254
|
+
**Verify the file exists and is well-formed before proceeding to Step 7.** If it's missing or empty, that is a bug — fix it before summarizing.
|
|
121
255
|
|
|
122
|
-
### Create Maintenance
|
|
256
|
+
### Create Maintenance Skills
|
|
123
257
|
|
|
124
|
-
Create
|
|
258
|
+
Create the foundation maintenance skill:
|
|
125
259
|
|
|
126
260
|
**File:** `<project>/.claude/skills/monorepo-maintenance/SKILL.md`
|
|
127
261
|
|
|
@@ -141,19 +275,35 @@ user-invocable: false
|
|
|
141
275
|
- Keep `turbo.json` tasks with `cache: false` for any task with side effects (migrations, code generation)
|
|
142
276
|
```
|
|
143
277
|
|
|
278
|
+
Also create maintenance skills:
|
|
279
|
+
- Always create `env-maintenance/SKILL.md` (see scaffold-env skill for template)
|
|
280
|
+
- If frontend UI: create both `tailwind-maintenance/SKILL.md` and `ui-maintenance/SKILL.md` (see scaffold-tailwind and scaffold-ui skills for templates)
|
|
281
|
+
|
|
144
282
|
## Step 7: Summarize
|
|
145
283
|
|
|
146
284
|
Tell the user:
|
|
147
285
|
|
|
148
|
-
|
|
286
|
+
### Install Mode Summary
|
|
287
|
+
|
|
288
|
+
- Project structure overview (directory tree — include optional features that were applied)
|
|
149
289
|
- What was configured (scope, Node version, tooling)
|
|
290
|
+
- Which optional features were included
|
|
150
291
|
- How to start development: `pnpm dev`
|
|
151
|
-
-
|
|
152
|
-
-
|
|
292
|
+
- If frontend UI was set up: how to add shadcn components (`cd packages/ui && pnpm dlx shadcn@latest add button`)
|
|
293
|
+
- Available feature blueprints to install next: `/scaffold-db`, `/scaffold-auth`
|
|
294
|
+
|
|
295
|
+
### Upgrade Mode Summary
|
|
296
|
+
|
|
297
|
+
- What was updated (list files that changed)
|
|
298
|
+
- What new features were added (env, tailwind, UI)
|
|
299
|
+
- Any manual steps remaining
|
|
300
|
+
- Suggest next steps based on what's still not installed
|
|
153
301
|
|
|
154
302
|
## Important Notes
|
|
155
303
|
|
|
156
304
|
- Never overwrite existing files without asking.
|
|
157
305
|
- Preserve all `// CONFIGURE:` comments in generated files so the user can find customization points.
|
|
158
|
-
-
|
|
306
|
+
- In upgrade mode, be conservative — only modify files that the blueprints own. Don't touch user-customized files (check for differences from the template before replacing).
|
|
307
|
+
- If the user has customized colors in `shared-styles.css` or added variables to `env.ts`, ask before replacing. Offer to merge their customizations into the new version.
|
|
159
308
|
- Feature blueprints will add scripts to root `package.json` and tasks to `turbo.json` — the foundation provides the base that they extend.
|
|
309
|
+
- The individual `/scaffold-env`, `/scaffold-tailwind`, and `/scaffold-ui` skills still exist for projects that didn't use foundation or want to add features later. The foundation's optional feature steps follow the same blueprints — no duplication.
|