@withmata/blueprints 0.2.0 → 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 (46) hide show
  1. package/{.opencode/commands/audit.md → .claude/skills/audit/SKILL.md} +8 -6
  2. package/.claude/skills/blueprint-catalog/SKILL.md +63 -0
  3. package/.claude/{commands/discover.md → skills/discover/SKILL.md} +8 -3
  4. package/{.cursor/commands/new-blueprint.md → .claude/skills/new-blueprint/SKILL.md} +13 -8
  5. package/{.cursor/commands/new-project.md → .claude/skills/new-project/SKILL.md} +11 -6
  6. package/.claude/{commands/scaffold-auth.md → skills/scaffold-auth/SKILL.md} +24 -23
  7. package/{.cursor/commands/scaffold-db.md → .claude/skills/scaffold-db/SKILL.md} +17 -16
  8. package/.claude/skills/scaffold-env/SKILL.md +222 -0
  9. package/.claude/{commands/scaffold-foundation.md → skills/scaffold-foundation/SKILL.md} +17 -16
  10. package/.claude/skills/scaffold-tailwind/SKILL.md +177 -0
  11. package/.claude/skills/scaffold-ui/SKILL.md +206 -0
  12. package/ENGINEERING.md +2 -2
  13. package/blueprints/features/env-t3/BLUEPRINT.md +332 -0
  14. package/blueprints/features/env-t3/files/nextjs/.env.example +17 -0
  15. package/blueprints/features/env-t3/files/nextjs/.env.local +0 -0
  16. package/blueprints/features/env-t3/files/nextjs/env/client.ts +13 -0
  17. package/blueprints/features/env-t3/files/nextjs/env/server.ts +12 -0
  18. package/blueprints/features/env-t3/files/server/.env.example +14 -0
  19. package/blueprints/features/env-t3/files/server/.env.local +0 -0
  20. package/blueprints/features/env-t3/files/server/env.ts +17 -0
  21. package/blueprints/features/tailwind-v4/BLUEPRINT.md +262 -12
  22. package/blueprints/features/tailwind-v4/files/tailwind-config/package.json +20 -0
  23. package/blueprints/features/tailwind-v4/files/tailwind-config/shared-styles.css +131 -0
  24. package/blueprints/features/ui-shared-components/BLUEPRINT.md +350 -13
  25. package/blueprints/features/ui-shared-components/files/ui/components.json +21 -0
  26. package/blueprints/features/ui-shared-components/files/ui/package.json +42 -0
  27. package/blueprints/features/ui-shared-components/files/ui/styles/globals.css +2 -0
  28. package/blueprints/features/ui-shared-components/files/ui/tsconfig.json +9 -0
  29. package/blueprints/features/ui-shared-components/files/ui/utils/cn.ts +6 -0
  30. package/blueprints/features/ui-shared-components/files/ui/utils/cva.ts +4 -0
  31. package/dist/index.js +210 -166
  32. package/package.json +6 -7
  33. package/.claude/commands/audit.md +0 -179
  34. package/.claude/commands/new-blueprint.md +0 -265
  35. package/.claude/commands/new-project.md +0 -230
  36. package/.claude/commands/scaffold-db.md +0 -270
  37. package/.cursor/commands/audit.md +0 -179
  38. package/.cursor/commands/discover.md +0 -92
  39. package/.cursor/commands/scaffold-auth.md +0 -310
  40. package/.cursor/commands/scaffold-foundation.md +0 -158
  41. package/.opencode/commands/discover.md +0 -96
  42. package/.opencode/commands/new-blueprint.md +0 -269
  43. package/.opencode/commands/new-project.md +0 -234
  44. package/.opencode/commands/scaffold-auth.md +0 -314
  45. package/.opencode/commands/scaffold-db.md +0 -274
  46. package/.opencode/commands/scaffold-foundation.md +0 -162
@@ -1,5 +1,7 @@
1
1
  ---
2
- description: Run a project health check against available blueprints
2
+ name: audit
3
+ description: Run a project health check against available blueprints (read-only analysis)
4
+ allowed-tools: Read, Glob, Grep, Bash(git *), Bash(ls *)
3
5
  ---
4
6
 
5
7
  # Project Audit
@@ -11,18 +13,18 @@ Run a health check against available blueprints. Analyze this project's current
11
13
  Load all available blueprint specs to understand what is possible:
12
14
 
13
15
  ```
14
- ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
15
- ~/Documents/WithMata/my-blueprints/blueprints/foundation/monorepo-turbo/BLUEPRINT.md
16
- ~/Documents/WithMata/my-blueprints/blueprints/features/auth-better-auth/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
17
+ ~/.withmata/blueprints/blueprints/foundation/monorepo-turbo/BLUEPRINT.md
18
+ ~/.withmata/blueprints/blueprints/features/auth-better-auth/BLUEPRINT.md
17
19
  ```
18
20
 
19
21
  Also scan for any additional feature blueprints:
20
22
 
21
23
  ```
22
- ~/Documents/WithMata/my-blueprints/blueprints/features/*/BLUEPRINT.md
24
+ ~/.withmata/blueprints/blueprints/features/*/BLUEPRINT.md
23
25
  ```
24
26
 
25
- Only consider a blueprint "available" if its BLUEPRINT.md has `Status: Complete`. If not found at these paths, ask the user for the path to their blueprints repo.
27
+ Only consider a blueprint "available" if its BLUEPRINT.md has `Status: Complete`. If not found, run `npx @withmata/blueprints` to install.
26
28
 
27
29
  ## Step 2: Read Project Context
28
30
 
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: blueprint-catalog
3
+ description: >
4
+ Background knowledge about available project blueprints for scaffolding.
5
+ Invoke when user discusses: databases, authentication, project setup,
6
+ monorepo, product ideas, scaffolding, environment variables, UI components,
7
+ design systems, Tailwind, or asks "what should I do next?"
8
+ user-invocable: false
9
+ ---
10
+
11
+ ## Available Blueprints
12
+
13
+ | Blueprint | Tier | What it does | Dependencies | Skill |
14
+ |-----------|------|-------------|--------------|-------|
15
+ | Product Discovery | Discovery | Structured session producing product thesis, user archetypes, and competitive analysis. No code. | None | `/discover` |
16
+ | Monorepo Foundation | Foundation | Turborepo + pnpm monorepo with Next.js, Biome, TypeScript strict, Tailwind v4. | None | `/scaffold-foundation` |
17
+ | Database | Feature | Drizzle ORM + PostgreSQL: schema groups, per-group migrations, seed scripts. | None | `/scaffold-db` |
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` |
22
+
23
+ ## Project Context
24
+
25
+ !`cat .project-context.md 2>/dev/null || echo "No .project-context.md found — no blueprints have been installed in this project yet."`
26
+
27
+ ## When to Recommend
28
+
29
+ Suggest a blueprint when you observe these signals. Be helpful, not pushy — mention it once, then follow the user's lead.
30
+
31
+ **`/discover`** — User describes a new product idea, asks "what should I build", is unsure about scope or target users, is non-technical or building their first product, or project has no product documentation.
32
+
33
+ **`/scaffold-foundation`** — User wants to set up a monorepo, mentions Turborepo or project structure, or project has no `turbo.json` / `pnpm-workspace.yaml`. Best after discovery. Skip for single-repo apps.
34
+
35
+ **`/scaffold-db`** — User mentions database, Drizzle, PostgreSQL, schemas, migrations, or needs a structured db layer. Or is writing raw SQL or using an ORM without organized schemas.
36
+
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.
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
+
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.
46
+
47
+ ## Lifecycle & Dependencies
48
+
49
+ Discovery → Foundation → Features is the recommended flow, but blueprints can be applied at any stage.
50
+
51
+ - **New project, no code:** Start with `/discover` (especially for non-technical users) or `/scaffold-foundation` (for monorepos)
52
+ - **Single-repo project:** Skip foundation — go directly to feature blueprints (`/scaffold-db`, `/scaffold-auth`)
53
+ - **Has monorepo, missing features:** Suggest specific feature blueprints
54
+ - **Existing project:** Feature blueprints adapt to existing structures — no foundation required
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
57
+
58
+ ## Important
59
+
60
+ - Check `.project-context.md` first — do not recommend blueprints already recorded there.
61
+ - Read the full BLUEPRINT.md before scaffolding. Follow ENGINEERING.md for coding conventions.
62
+ - Only recommend blueprints listed above. Other blueprints are in development and not yet available.
63
+ - Blueprints location: `~/.withmata/blueprints/`
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: discover
3
+ description: Run a structured product discovery session producing product documentation (no code)
4
+ ---
5
+
1
6
  # Run Product Discovery
2
7
 
3
8
  Run a rigorous product discovery session. This produces product documentation — no code is generated. The session is a structured 60-minute deep dive that transforms a raw idea into a defensible product strategy.
@@ -7,11 +12,11 @@ Run a rigorous product discovery session. This produces product documentation
7
12
  Read the full discovery blueprint and all templates:
8
13
 
9
14
  ```
10
- ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
11
- ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/templates/*
15
+ ~/.withmata/blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/discovery/product-discovery/templates/*
12
17
  ```
13
18
 
14
- If not found at that path, ask the user for the path to their blueprints repo.
19
+ If not found, run `npx @withmata/blueprints` to install.
15
20
 
16
21
  The BLUEPRINT.md contains the full methodology: phased session structure, frameworks, operating principles, research strategy, challenge patterns, and quality checkpoints. Follow it precisely.
17
22
 
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: new-blueprint
3
+ description: Add a new blueprint to the withmata blueprints repository
4
+ ---
5
+
1
6
  # Add a New Blueprint
2
7
 
3
8
  Guide the user through adding a new blueprint to this repo. This command ensures every blueprint follows the established conventions and is fully wired up.
@@ -214,11 +219,11 @@ Before considering the BLUEPRINT.md done, verify:
214
219
  - [ ] Code files use `{{SCOPE}}`, `{{APP_NAME}}`, and `// CONFIGURE:` markers
215
220
  - [ ] References link to official docs
216
221
 
217
- ## Step 5: Create the Scaffold Command
222
+ ## Step 5: Create the Scaffold Skill
218
223
 
219
- Create the command in all three tool directories: `.claude/commands/scaffold-{name}.md`, `.opencode/commands/scaffold-{name}.md`, and `.cursor/commands/scaffold-{name}.md`. The OpenCode version should include YAML frontmatter with a `description` field. The Claude Code and Cursor versions use plain markdown (no frontmatter). The command body is the same across all three.
224
+ Create the skill as `.claude/skills/scaffold-{name}/SKILL.md`. Follow the pattern from existing skills (read `.claude/skills/scaffold-auth/SKILL.md` as the model). Add YAML frontmatter with `name` and `description` fields.
220
225
 
221
- Follow the pattern from existing commands (read `.claude/commands/scaffold-auth.md` as the model). Every scaffold command must:
226
+ Every scaffold skill must:
222
227
 
223
228
  1. **Read the blueprint** — BLUEPRINT.md and all files
224
229
  2. **Read project context** — `.project-context.md` for existing state
@@ -226,14 +231,14 @@ Follow the pattern from existing commands (read `.claude/commands/scaffold-auth.
226
231
  4. **Ask clarifying questions** — based on the blueprint's configurable options
227
232
  5. **Adapt and scaffold** — replace placeholders, adapt to project structure
228
233
  6. **Update project context** — append to `.project-context.md`
229
- 7. **Inject maintenance rules** — detect and append to the target project's rules file(s): CLAUDE.md, AGENTS.md, or both (see the multi-tool injection pattern in existing scaffold commands)
234
+ 7. **Create maintenance skill** — as the final step, create a project-level maintenance skill at `<project>/.claude/skills/{name}-maintenance/SKILL.md` with `user-invocable: false` containing the blueprint's maintenance hooks
230
235
  8. **Summarize** — packages to install, env vars to set, manual steps remaining
231
236
 
232
- The command should reference the BLUEPRINT.md as the source of truth for methodology and not duplicate its content.
237
+ The skill should reference the BLUEPRINT.md as the source of truth for methodology and not duplicate its content.
233
238
 
234
239
  ## Step 6: Update the Repo
235
240
 
236
- After the blueprint and command are created:
241
+ After the blueprint and skill are created:
237
242
 
238
243
  1. **Update README.md** — Add the new blueprint to the appropriate table (Complete or Planned) in the "Available blueprints" section. Add a scaffold command entry to the "Available commands" table.
239
244
 
@@ -243,14 +248,14 @@ After the blueprint and command are created:
243
248
 
244
249
  4. **Check for a planned blueprint placeholder** — If `blueprints/features/{name}/BLUEPRINT.md` already existed as a planned placeholder, replace it entirely with the full BLUEPRINT.md. Don't try to preserve the placeholder content.
245
250
 
246
- 5. **Ensure all three directories have the new scaffold command:** `.claude/commands/`, `.opencode/commands/`, and `.cursor/commands/`.
251
+ 5. **Ensure the new scaffold skill exists at `.claude/skills/scaffold-{name}/SKILL.md`.**
247
252
 
248
253
  ## Step 7: Verify
249
254
 
250
255
  Before considering the blueprint done:
251
256
 
252
257
  1. Read back the BLUEPRINT.md and verify it meets the quality checklist from Step 4
253
- 2. Read the scaffold command and verify it follows the pattern from Step 5
258
+ 2. Read the scaffold skill and verify it follows the pattern from Step 5
254
259
  3. Verify all files in files/ use proper placeholders (no hardcoded scopes or app names)
255
260
  4. Verify README.md and CHANGELOG.md are updated
256
261
  5. Show the user a summary of everything that was created
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: new-project
3
+ description: Take a product from idea to running code using the full blueprint lifecycle
4
+ ---
5
+
1
6
  # New Project
2
7
 
3
8
  Take a product from idea to running code. This command walks through the full lifecycle — defining the product, setting up the codebase to support it, and wiring in the capabilities it needs. You're a product partner with deep engineering expertise: the product strategy drives every technical decision.
@@ -7,19 +12,19 @@ Take a product from idea to running code. This command walks through the full li
7
12
  Load all available blueprints so you understand what's possible:
8
13
 
9
14
  ```
10
- ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
11
- ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/templates/*
12
- ~/Documents/WithMata/my-blueprints/blueprints/foundation/monorepo-turbo/BLUEPRINT.md
13
- ~/Documents/WithMata/my-blueprints/blueprints/foundation/monorepo-turbo/files/**/*
15
+ ~/.withmata/blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/discovery/product-discovery/templates/*
17
+ ~/.withmata/blueprints/blueprints/foundation/monorepo-turbo/BLUEPRINT.md
18
+ ~/.withmata/blueprints/blueprints/foundation/monorepo-turbo/files/**/*
14
19
  ```
15
20
 
16
21
  Also scan for available feature blueprints:
17
22
 
18
23
  ```
19
- ~/Documents/WithMata/my-blueprints/blueprints/features/*/BLUEPRINT.md
24
+ ~/.withmata/blueprints/blueprints/features/*/BLUEPRINT.md
20
25
  ```
21
26
 
22
- Only consider a feature blueprint "available" if its BLUEPRINT.md has `Status: Complete` (not a placeholder). If not found at the paths above, ask the user for the path to their blueprints repo.
27
+ Only consider a feature blueprint "available" if its BLUEPRINT.md has `Status: Complete` (not a placeholder). If not found, run `npx @withmata/blueprints` to install.
23
28
 
24
29
  ## Step 2: Assess Current State
25
30
 
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: scaffold-auth
3
+ description: Scaffold Better Auth + Drizzle authentication into the current project
4
+ ---
5
+
1
6
  # Scaffold Auth Blueprint
2
7
 
3
8
  Scaffold the `auth-better-auth` blueprint into the current project. Read the full blueprint first, then adapt it to this project's stack.
@@ -7,11 +12,11 @@ Scaffold the `auth-better-auth` blueprint into the current project. Read the ful
7
12
  Read the full BLUEPRINT.md and all code files from the auth blueprint:
8
13
 
9
14
  ```
10
- blueprints/features/auth-better-auth/BLUEPRINT.md
11
- blueprints/features/auth-better-auth/files/**/*
15
+ ~/.withmata/blueprints/blueprints/features/auth-better-auth/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/features/auth-better-auth/files/**/*
12
17
  ```
13
18
 
14
- If these files are not in the current project, look for them at `~/Documents/WithMata/my-blueprints/blueprints/features/auth-better-auth/`. If still not found, ask the user for the path to their blueprints repo.
19
+ If not found at these paths, run `npx @withmata/blueprints` to install.
15
20
 
16
21
  ## Step 1.5: Read Project Context
17
22
 
@@ -115,13 +120,13 @@ Based on the project structure, project context, and user answers, adapt the blu
115
120
  ### 4a. Database Layer
116
121
 
117
122
  **If monorepo:**
118
- - Copy/adapt `files/db/drizzle.config.ts` `packages/db/drizzle/auth/drizzle.config.ts`
123
+ - Copy/adapt `files/db/drizzle.config.ts` -> `packages/db/drizzle/auth/drizzle.config.ts`
119
124
  - Copy `files/db/auth-schema.ts` as a reference (the actual schema will be auto-generated)
120
125
  - Add the `"./auth"` export to `packages/db/package.json`
121
126
  - Add `auth:generate` and `auth:migrate` scripts to `packages/db/package.json`
122
127
 
123
128
  **If single-repo:**
124
- - Copy/adapt `files/db/drizzle.config.ts` `drizzle/auth/drizzle.config.ts` (at project root)
129
+ - Copy/adapt `files/db/drizzle.config.ts` -> `drizzle/auth/drizzle.config.ts` (at project root)
125
130
  - Adjust schema paths to `"./src/db/auth/schema.ts"` (relative to root)
126
131
  - Create `src/db/auth/` directory for auth schema
127
132
  - No separate package.json export needed — use direct imports
@@ -129,17 +134,17 @@ Based on the project structure, project context, and user answers, adapt the blu
129
134
  ### 4b. Server Layer
130
135
 
131
136
  **If monorepo:**
132
- - Copy/adapt `files/server/auth.ts` `apis/server/src/auth/index.ts`
137
+ - Copy/adapt `files/server/auth.ts` -> `apis/server/src/auth/index.ts`
133
138
  - Replace `{{APP_NAME}}`, `{{EMAIL_FROM}}`, `{{SCOPE}}`
134
- - Copy/adapt `files/server/auth-db.ts` `apis/server/src/db/auth.ts`
135
- - Copy/adapt `files/server/middleware.ts` `apis/server/src/middleware/auth.ts`
139
+ - Copy/adapt `files/server/auth-db.ts` -> `apis/server/src/db/auth.ts`
140
+ - Copy/adapt `files/server/middleware.ts` -> `apis/server/src/middleware/auth.ts`
136
141
  - Merge auth env vars into `apis/server/src/env.ts`
137
142
 
138
143
  **If single-repo:**
139
- - Copy/adapt `files/server/auth.ts` `src/lib/auth/index.ts`
144
+ - Copy/adapt `files/server/auth.ts` -> `src/lib/auth/index.ts`
140
145
  - Replace `{{APP_NAME}}`, `{{EMAIL_FROM}}`
141
146
  - Adjust DB import to use direct path: `import { db } from "@/db/auth/client"` or `#db/auth/client`
142
- - Copy/adapt `files/server/auth-db.ts` `src/lib/db/auth.ts`
147
+ - Copy/adapt `files/server/auth-db.ts` -> `src/lib/db/auth.ts`
143
148
  - Default to Next.js API routes (no separate Hono server)
144
149
  - Merge auth env vars into existing `env.ts` (or create one)
145
150
 
@@ -221,21 +226,19 @@ If `.project-context.md` does not exist, create it with the standard header and
221
226
 
222
227
  Also append any significant architectural decisions to the `## Architecture Decisions` section.
223
228
 
224
- ### Inject Maintenance Rules
229
+ ### Create Maintenance Skill
225
230
 
226
- Append the condensed maintenance rules to the target project's rules file(s):
231
+ Create a project-level maintenance skill for the auth blueprint:
227
232
 
228
- 1. If `CLAUDE.md` exists in the target project → append rules there
229
- 2. If `AGENTS.md` exists in the target project → append rules there
230
- 3. If both exist → append to both (keep them in sync)
231
- 4. If neither exists → ask the user which AI coding tool(s) they use:
232
- - Claude Code → create CLAUDE.md with a `## Maintenance Rules` section
233
- - OpenCode or Cursor → create AGENTS.md with a `## Maintenance Rules` section (both tools read AGENTS.md)
234
- - Multiple tools → create all applicable files
233
+ **File:** `<project>/.claude/skills/auth-maintenance/SKILL.md`
235
234
 
236
- The maintenance rules content is identical regardless of which file it goes into:
235
+ ```yaml
236
+ ---
237
+ name: auth-maintenance
238
+ description: Maintenance rules for Better Auth. Invoke when modifying auth config, providers, session settings, or auth schema.
239
+ user-invocable: false
240
+ ---
237
241
 
238
- ```markdown
239
242
  ### auth-better-auth maintenance
240
243
  - After modifying Better Auth server config, plugins, or providers: run `pnpm auth:generate && pnpm auth:migrate`
241
244
  - After updating `better-auth` package: run `pnpm auth:generate`, check for schema changes, migrate if needed
@@ -245,8 +248,6 @@ The maintenance rules content is identical regardless of which file it goes into
245
248
  - Never edit the auto-generated auth schema directly — modify the Better Auth config and regenerate
246
249
  ```
247
250
 
248
- If the `## Maintenance Rules` heading already exists (from another blueprint), only add the `### auth-better-auth maintenance` subsection — do not duplicate the heading.
249
-
250
251
  ## Step 6: Output Summary
251
252
 
252
253
  After scaffolding, provide the user with a clear summary:
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: scaffold-db
3
+ description: Scaffold Drizzle ORM + PostgreSQL database package into the current project
4
+ ---
5
+
1
6
  # Scaffold DB Blueprint
2
7
 
3
8
  Scaffold the `db-drizzle-postgres` blueprint into the current project. Read the full blueprint first, then adapt it to this project's stack.
@@ -7,11 +12,11 @@ Scaffold the `db-drizzle-postgres` blueprint into the current project. Read the
7
12
  Read the full BLUEPRINT.md and all template files from the db blueprint:
8
13
 
9
14
  ```
10
- blueprints/features/db-drizzle-postgres/BLUEPRINT.md
11
- blueprints/features/db-drizzle-postgres/files/**/*
15
+ ~/.withmata/blueprints/blueprints/features/db-drizzle-postgres/BLUEPRINT.md
16
+ ~/.withmata/blueprints/blueprints/features/db-drizzle-postgres/files/**/*
12
17
  ```
13
18
 
14
- If these files are not in the current project, look for them at `~/Documents/WithMata/my-blueprints/blueprints/features/db-drizzle-postgres/`. If still not found, ask the user for the path to their blueprints repo.
19
+ If not found at these paths, run `npx @withmata/blueprints` to install.
15
20
 
16
21
  ## Step 1.5: Read Project Context
17
22
 
@@ -188,21 +193,19 @@ scripts_added:
188
193
 
189
194
  If `.project-context.md` does not exist, create it with the standard header and the Installed Blueprints section. Log a note: "No discovery or foundation context found. Consider running `/discover` and `/scaffold-foundation` for a complete project context."
190
195
 
191
- ### Inject Maintenance Rules
196
+ ### Create Maintenance Skill
192
197
 
193
- Append the condensed maintenance rules to the target project's rules file(s):
198
+ Create a project-level maintenance skill for the database blueprint:
194
199
 
195
- 1. If `CLAUDE.md` exists in the target project -> append rules there
196
- 2. If `AGENTS.md` exists in the target project -> append rules there
197
- 3. If both exist -> append to both (keep them in sync)
198
- 4. If neither exists -> ask the user which AI coding tool(s) they use:
199
- - Claude Code -> create CLAUDE.md with a `## Maintenance Rules` section
200
- - OpenCode or Cursor -> create AGENTS.md with a `## Maintenance Rules` section (both tools read AGENTS.md)
201
- - Multiple tools -> create all applicable files
200
+ **File:** `<project>/.claude/skills/db-maintenance/SKILL.md`
202
201
 
203
- The maintenance rules content is identical regardless of which file it goes into:
202
+ ```yaml
203
+ ---
204
+ name: db-maintenance
205
+ description: Maintenance rules for Drizzle + PostgreSQL database. Invoke when modifying schemas, adding entities, or running migrations.
206
+ user-invocable: false
207
+ ---
204
208
 
205
- ```markdown
206
209
  ### db-drizzle-postgres maintenance
207
210
  - After creating a new schema file: add it to `drizzle/<group>/drizzle.config.ts` schema array AND the group's `index.ts` barrel export
208
211
  - After any schema change: run `pnpm <group>:generate && pnpm <group>:migrate`
@@ -211,8 +214,6 @@ The maintenance rules content is identical regardless of which file it goes into
211
214
  - Never use glob patterns in drizzle.config.ts schema — always list files explicitly, excluding index.ts
212
215
  ```
213
216
 
214
- If the `## Maintenance Rules` heading already exists (from another blueprint), only add the `### db-drizzle-postgres maintenance` subsection — do not duplicate the heading.
215
-
216
217
  ## Step 6: Output Summary
217
218
 
218
219
  After scaffolding, provide the user with a clear summary:
@@ -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.