@withmata/blueprints 0.2.0

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 (77) hide show
  1. package/.claude/commands/audit.md +179 -0
  2. package/.claude/commands/discover.md +92 -0
  3. package/.claude/commands/new-blueprint.md +265 -0
  4. package/.claude/commands/new-project.md +230 -0
  5. package/.claude/commands/scaffold-auth.md +310 -0
  6. package/.claude/commands/scaffold-db.md +270 -0
  7. package/.claude/commands/scaffold-foundation.md +158 -0
  8. package/.cursor/commands/audit.md +179 -0
  9. package/.cursor/commands/discover.md +92 -0
  10. package/.cursor/commands/new-blueprint.md +265 -0
  11. package/.cursor/commands/new-project.md +230 -0
  12. package/.cursor/commands/scaffold-auth.md +310 -0
  13. package/.cursor/commands/scaffold-db.md +270 -0
  14. package/.cursor/commands/scaffold-foundation.md +158 -0
  15. package/.opencode/commands/audit.md +183 -0
  16. package/.opencode/commands/discover.md +96 -0
  17. package/.opencode/commands/new-blueprint.md +269 -0
  18. package/.opencode/commands/new-project.md +234 -0
  19. package/.opencode/commands/scaffold-auth.md +314 -0
  20. package/.opencode/commands/scaffold-db.md +274 -0
  21. package/.opencode/commands/scaffold-foundation.md +162 -0
  22. package/ENGINEERING.md +47 -0
  23. package/blueprints/discovery/product-discovery/BLUEPRINT.md +361 -0
  24. package/blueprints/discovery/product-discovery/templates/archetype-template.md +143 -0
  25. package/blueprints/discovery/product-discovery/templates/product-brief.md +65 -0
  26. package/blueprints/discovery/product-discovery/templates/product-thesis.md +64 -0
  27. package/blueprints/discovery/product-discovery/templates/research-summary.md +43 -0
  28. package/blueprints/features/auth-better-auth/BLUEPRINT.md +794 -0
  29. package/blueprints/features/auth-better-auth/files/client/auth-client.ts +31 -0
  30. package/blueprints/features/auth-better-auth/files/client/context/organization.ts +236 -0
  31. package/blueprints/features/auth-better-auth/files/client/hooks/use-create-organization.ts +45 -0
  32. package/blueprints/features/auth-better-auth/files/client/hooks/use-has-permission.ts +26 -0
  33. package/blueprints/features/auth-better-auth/files/client/hooks/use-organization.ts +64 -0
  34. package/blueprints/features/auth-better-auth/files/client/schema/auth.ts +21 -0
  35. package/blueprints/features/auth-better-auth/files/client/schema/organization.ts +51 -0
  36. package/blueprints/features/auth-better-auth/files/client/types/organization.ts +20 -0
  37. package/blueprints/features/auth-better-auth/files/db/auth-schema.ts +184 -0
  38. package/blueprints/features/auth-better-auth/files/db/drizzle.config.ts +21 -0
  39. package/blueprints/features/auth-better-auth/files/middleware/route-protection.ts +84 -0
  40. package/blueprints/features/auth-better-auth/files/server/auth-db.ts +18 -0
  41. package/blueprints/features/auth-better-auth/files/server/auth.ts +159 -0
  42. package/blueprints/features/auth-better-auth/files/server/env.ts +44 -0
  43. package/blueprints/features/auth-better-auth/files/server/middleware.ts +144 -0
  44. package/blueprints/features/db-drizzle-postgres/BLUEPRINT.md +596 -0
  45. package/blueprints/features/db-drizzle-postgres/files/db/drizzle.config.ts +18 -0
  46. package/blueprints/features/db-drizzle-postgres/files/db/env.example +3 -0
  47. package/blueprints/features/db-drizzle-postgres/files/db/package.json +33 -0
  48. package/blueprints/features/db-drizzle-postgres/files/db/src/client.ts +34 -0
  49. package/blueprints/features/db-drizzle-postgres/files/db/src/example-entity.ts +73 -0
  50. package/blueprints/features/db-drizzle-postgres/files/db/src/index.ts +8 -0
  51. package/blueprints/features/db-drizzle-postgres/files/db/src/scripts/seed.ts +50 -0
  52. package/blueprints/features/db-drizzle-postgres/files/db/tsconfig.json +13 -0
  53. package/blueprints/features/tailwind-v4/BLUEPRINT.md +29 -0
  54. package/blueprints/features/ui-shared-components/BLUEPRINT.md +35 -0
  55. package/blueprints/foundation/monorepo-turbo/BLUEPRINT.md +378 -0
  56. package/blueprints/foundation/monorepo-turbo/files/apps/web/app/globals.css +2 -0
  57. package/blueprints/foundation/monorepo-turbo/files/apps/web/app/layout.tsx +23 -0
  58. package/blueprints/foundation/monorepo-turbo/files/apps/web/app/page.tsx +7 -0
  59. package/blueprints/foundation/monorepo-turbo/files/apps/web/env.ts +13 -0
  60. package/blueprints/foundation/monorepo-turbo/files/apps/web/next.config.ts +12 -0
  61. package/blueprints/foundation/monorepo-turbo/files/apps/web/package.json +28 -0
  62. package/blueprints/foundation/monorepo-turbo/files/apps/web/postcss.config.mjs +5 -0
  63. package/blueprints/foundation/monorepo-turbo/files/apps/web/tsconfig.json +18 -0
  64. package/blueprints/foundation/monorepo-turbo/files/config/tailwind-config/package.json +14 -0
  65. package/blueprints/foundation/monorepo-turbo/files/config/tailwind-config/postcss.config.mjs +5 -0
  66. package/blueprints/foundation/monorepo-turbo/files/config/tailwind-config/shared-styles.css +88 -0
  67. package/blueprints/foundation/monorepo-turbo/files/config/typescript-config/base.json +19 -0
  68. package/blueprints/foundation/monorepo-turbo/files/config/typescript-config/nextjs.json +12 -0
  69. package/blueprints/foundation/monorepo-turbo/files/config/typescript-config/package.json +5 -0
  70. package/blueprints/foundation/monorepo-turbo/files/config/typescript-config/react-library.json +7 -0
  71. package/blueprints/foundation/monorepo-turbo/files/root/biome.json +46 -0
  72. package/blueprints/foundation/monorepo-turbo/files/root/gitignore +35 -0
  73. package/blueprints/foundation/monorepo-turbo/files/root/package.json +25 -0
  74. package/blueprints/foundation/monorepo-turbo/files/root/pnpm-workspace.yaml +5 -0
  75. package/blueprints/foundation/monorepo-turbo/files/root/turbo.json +30 -0
  76. package/dist/index.js +453 -0
  77. package/package.json +53 -0
@@ -0,0 +1,92 @@
1
+ # Run Product Discovery
2
+
3
+ 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.
4
+
5
+ ## Step 1: Read the Blueprint
6
+
7
+ Read the full discovery blueprint and all templates:
8
+
9
+ ```
10
+ ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
11
+ ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/templates/*
12
+ ```
13
+
14
+ If not found at that path, ask the user for the path to their blueprints repo.
15
+
16
+ The BLUEPRINT.md contains the full methodology: phased session structure, frameworks, operating principles, research strategy, challenge patterns, and quality checkpoints. Follow it precisely.
17
+
18
+ ## Step 2: Check for Existing Discovery
19
+
20
+ Check if `.project-context.md` exists and already contains a `## Product Discovery` section. If it does:
21
+
22
+ - Show the user what was previously discovered
23
+ - Ask: "Product discovery was already completed. Would you like to redo it (replaces existing), refine it (update specific sections), or skip?"
24
+
25
+ ## Step 3: Run the Discovery Session
26
+
27
+ Follow the full 5-phase discovery process documented in BLUEPRINT.md. The blueprint contains the complete methodology: phase structure, frameworks, operating principles, research strategy, challenge patterns, and quality gates. Follow it precisely. Do not abbreviate or skip phases.
28
+
29
+ This is conversational — you are guiding the user through structured discovery, not filling in a form.
30
+
31
+ Quick reference for the phases:
32
+ 1. **Phase 1: Initial Framing** — what and who
33
+ 2. **Phase 2: Problem Deep Dive** — root cause via 5 Whys
34
+ 3. **Phase 3: User Definition** — archetypes and persona variations
35
+ 4. **Phase 4: Solution Positioning** — competitive landscape and differentiation
36
+ 5. **Phase 5: Synthesis** — distill findings for documentation
37
+
38
+ ## Step 4: Verify Quality Checkpoints
39
+
40
+ Before generating documentation, verify ALL quality checkpoints listed in BLUEPRINT.md pass. If any fail, continue probing — do not rush to documentation.
41
+
42
+ ## Step 5: Generate Documentation
43
+
44
+ Create the `docs/product/` directory structure in the target project. Use the templates from the blueprint as the structural guide — fill them with the session's findings.
45
+
46
+ ```
47
+ docs/
48
+ └── product/
49
+ ├── product-thesis.md
50
+ ├── product-brief.md
51
+ └── users/
52
+ ├── archetype-[name].md # One per archetype identified
53
+ └── research-summary.md
54
+ ```
55
+
56
+ See BLUEPRINT.md for document quality standards and writing guidelines for each document type. Do not create files beyond what's specified. Do not rename the structure.
57
+
58
+ ## Step 6: Update Project Context
59
+
60
+ Create or update `.project-context.md` in the target project root:
61
+
62
+ - If the file does not exist, create it with a header and the `## Product Discovery` section
63
+ - If the file exists but has no discovery section, add the discovery section after the header
64
+ - If the file exists with a discovery section (user chose to redo), replace that section only
65
+
66
+ Append this structured YAML block:
67
+
68
+ ```yaml
69
+ ## Product Discovery
70
+ product_name: "<name>"
71
+ problem_statement: "<one sentence>"
72
+ core_pillars:
73
+ - "<pillar 1>"
74
+ - "<pillar 2>"
75
+ - "<pillar 3>"
76
+ primary_archetype: "<archetype name>"
77
+ discovery_completed: <date>
78
+ artifacts:
79
+ - docs/product/product-thesis.md
80
+ - docs/product/product-brief.md
81
+ - docs/product/users/archetype-<name>.md
82
+ - docs/product/users/research-summary.md
83
+ ```
84
+
85
+ ## Step 7: Summary
86
+
87
+ Tell the user:
88
+
89
+ - What documents were generated (list each with a one-line description)
90
+ - Key findings: core pillars, primary archetype, main competitive gap
91
+ - Critical assumptions that need validation
92
+ - Suggest next step: "Run `/scaffold-foundation` to set up the project skeleton, or `/new-project` to continue the full workflow."
@@ -0,0 +1,265 @@
1
+ # Add a New Blueprint
2
+
3
+ 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.
4
+
5
+ ## Step 1: Understand the Conventions
6
+
7
+ Read these files to understand the system you're adding to:
8
+
9
+ ```
10
+ ENGINEERING.md # Engineering preferences
11
+ README.md # System overview and blueprint anatomy
12
+ CHANGELOG.md # To update when done
13
+ ```
14
+
15
+ Also scan existing complete blueprints to understand the quality bar:
16
+
17
+ ```
18
+ blueprints/features/auth-better-auth/BLUEPRINT.md # Best example of a feature blueprint
19
+ blueprints/foundation/monorepo-turbo/BLUEPRINT.md # Best example of a foundation blueprint
20
+ blueprints/discovery/product-discovery/BLUEPRINT.md # Best example of a discovery blueprint
21
+ ```
22
+
23
+ ## Step 2: Gather Information
24
+
25
+ Ask the user:
26
+
27
+ 1. **"What pattern are you extracting?"** — What does it do? (e.g., "shared database layer with Drizzle", "Stripe billing integration", "email service with Resend")
28
+
29
+ 2. **"Which tier?"** — Discovery (produces docs), Foundation (project skeleton), or Feature (plugs into existing project)? Most new blueprints are Features.
30
+
31
+ 3. **"Is there an existing project to extract from?"** — If yes, get the path. If no, we're building from scratch — which is fine but harder.
32
+
33
+ 4. **"What should it be called?"** — Suggest a name following the convention: `{domain}-{tool}` for features (e.g., `auth-better-auth`, `db-drizzle-postgres`, `billing-stripe`, `email-resend`). Foundation and discovery blueprints use `{purpose}-{tool}` (e.g., `monorepo-turbo`, `product-discovery`).
34
+
35
+ ## Step 3: Extract or Build
36
+
37
+ ### If extracting from an existing project:
38
+
39
+ Read the relevant code in the source project. Understand:
40
+ - What files are involved
41
+ - How they connect to each other
42
+ - What's project-specific vs what's the reusable pattern
43
+ - What dependencies are needed
44
+ - What environment variables are required
45
+ - How it integrates with the monorepo (workspace deps, turbo tasks, root scripts)
46
+
47
+ Then create the blueprint:
48
+
49
+ 1. Create the directory: `blueprints/{tier}/{name}/`
50
+ 2. Create `files/` with the extracted code — generalize project-specific values:
51
+ - Replace npm scopes with `{{SCOPE}}`
52
+ - Replace app names with `{{APP_NAME}}`
53
+ - Replace project-specific emails, URLs, etc. with `{{PLACEHOLDER}}` and `// CONFIGURE:` comments
54
+ - Remove any business logic that's not part of the pattern
55
+ 3. Create `BLUEPRINT.md` following the structure below
56
+
57
+ ### If building from scratch:
58
+
59
+ 1. Create the directory: `blueprints/{tier}/{name}/`
60
+ 2. Build the code files in `files/`, following the conventions in ENGINEERING.md
61
+ 3. Create `BLUEPRINT.md` following the structure below
62
+
63
+ ## Step 4: Write the BLUEPRINT.md
64
+
65
+ This is the most important file. It's what makes AI-assisted scaffolding intelligent rather than mechanical. Follow this structure:
66
+
67
+ ### Required sections (all tiers):
68
+
69
+ ```markdown
70
+ # [Name] Blueprint — [Short Description]
71
+
72
+ ## Tier
73
+ [Discovery | Foundation | Feature]
74
+
75
+ ## Status
76
+ [Complete | In Progress | Planned]
77
+
78
+ ## Problem
79
+ [What problem does this blueprint solve? Be specific about the pain point.]
80
+ ```
81
+
82
+ ### Additional sections for Feature blueprints:
83
+
84
+ ```markdown
85
+ ## Blueprint Dependencies
86
+
87
+ [Does this blueprint require or recommend other blueprints be installed first?
88
+ List them in a table with columns: Blueprint, Type (required/recommended), Why.
89
+ If required, include a subsection explaining fallback behavior if the dependency is absent.
90
+ If no dependencies, write "None."]
91
+
92
+ ## Single-Repo Adaptation
93
+
94
+ [How does file placement, imports, and scripts differ for standalone (non-monorepo) apps?
95
+ Include a path mapping table (monorepo vs single-repo) and a single-repo scripts example.
96
+ Document what core patterns stay the same regardless of project type.]
97
+
98
+ ## Architecture
99
+
100
+ ### Core Pattern
101
+ [How does this work at a high level?]
102
+
103
+ ### Key Decisions
104
+ [For each major decision, document WHAT you chose and WHY. This is what lets the AI coding tool adapt intelligently.]
105
+
106
+ - **[Decision 1]** (recommended/required) — [Explanation of what and why. Include alternatives if relevant.]
107
+ - **[Decision 2]** (optional) — [Explanation]
108
+
109
+ ## Hard Requirements vs Recommended Defaults
110
+
111
+ **Hard requirements:**
112
+ - [Things that can't change]
113
+
114
+ **Recommended defaults — ask during scaffolding:**
115
+
116
+ | Choice | Recommended | Alternatives |
117
+ |---|---|---|
118
+ | [Choice 1] | [Default] | [Options] |
119
+
120
+ ## Dependencies
121
+
122
+ ### npm packages
123
+
124
+ **Server:**
125
+ | Package | Version | Purpose |
126
+ |---|---|---|
127
+ | [pkg] | [version] | [why] |
128
+
129
+ **Client:**
130
+ | Package | Version | Purpose |
131
+ |---|---|---|
132
+
133
+ ### Environment Variables
134
+
135
+ | Variable | Where | Description |
136
+ |---|---|---|
137
+ | [VAR] | [Server/Client] | [What it's for] |
138
+
139
+ ## Monorepo Wiring
140
+
141
+ [How does this integrate across workspaces? Package exports, workspace deps, turbo tasks, root scripts. This section is critical — it's the hardest part to figure out from scratch.]
142
+
143
+ ## File Manifest
144
+
145
+ | File | Purpose | Target Location |
146
+ |---|---|---|
147
+ | [file path in files/] | [what it does] | [where it goes in target project] |
148
+
149
+ ## Integration Steps
150
+
151
+ [Ordered phases for scaffolding. Group related steps.]
152
+
153
+ ### Phase 1: [Name]
154
+ 1. [Step]
155
+ 2. [Step]
156
+
157
+ ### Phase 2: [Name]
158
+ ...
159
+
160
+ ## Maintenance Hooks
161
+
162
+ [What needs to happen after changes to keep this working?]
163
+
164
+ ### Condensed Rules for project rules file
165
+
166
+ ```markdown
167
+ ### [name] maintenance
168
+ - [rule 1]
169
+ - [rule 2]
170
+ ```
171
+
172
+ ## References
173
+
174
+ - [Links to docs, repos, etc.]
175
+ ```
176
+
177
+ ### Additional sections for Discovery blueprints:
178
+
179
+ ```markdown
180
+ ## Output
181
+ [What documents are generated and where]
182
+
183
+ ## Process
184
+ [The conversational flow — phases, frameworks, quality gates]
185
+ ```
186
+
187
+ ### Additional sections for Foundation blueprints:
188
+
189
+ ```markdown
190
+ ## Output
191
+ [What project structure is generated — show the directory tree]
192
+
193
+ ## Architecture
194
+ [Key structural decisions: why this tool, why this config, why this convention]
195
+
196
+ ## Expects from Discovery
197
+ [What info it reads from the discovery context, if anything]
198
+ ```
199
+
200
+ ### Quality checklist for BLUEPRINT.md:
201
+
202
+ Before considering the BLUEPRINT.md done, verify:
203
+
204
+ - [ ] Every architectural decision explains WHY, not just WHAT
205
+ - [ ] Configurable vs opinionated choices are clearly separated
206
+ - [ ] Blueprint Dependencies section is present (even if "None")
207
+ - [ ] Single-Repo Adaptation section documents path mapping and script differences
208
+ - [ ] File manifest covers every file in files/ with both monorepo and single-repo target locations
209
+ - [ ] Integration steps are ordered and phased, with conditional monorepo/single-repo phases
210
+ - [ ] Dependencies list specific versions
211
+ - [ ] Environment variables are documented with descriptions
212
+ - [ ] Monorepo wiring is documented (this is always the hardest part)
213
+ - [ ] Maintenance hooks define trigger-action pairs
214
+ - [ ] Code files use `{{SCOPE}}`, `{{APP_NAME}}`, and `// CONFIGURE:` markers
215
+ - [ ] References link to official docs
216
+
217
+ ## Step 5: Create the Scaffold Command
218
+
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.
220
+
221
+ Follow the pattern from existing commands (read `.claude/commands/scaffold-auth.md` as the model). Every scaffold command must:
222
+
223
+ 1. **Read the blueprint** — BLUEPRINT.md and all files
224
+ 2. **Read project context** — `.project-context.md` for existing state
225
+ 3. **Explore the target project** — understand current structure
226
+ 4. **Ask clarifying questions** — based on the blueprint's configurable options
227
+ 5. **Adapt and scaffold** — replace placeholders, adapt to project structure
228
+ 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)
230
+ 8. **Summarize** — packages to install, env vars to set, manual steps remaining
231
+
232
+ The command should reference the BLUEPRINT.md as the source of truth for methodology and not duplicate its content.
233
+
234
+ ## Step 6: Update the Repo
235
+
236
+ After the blueprint and command are created:
237
+
238
+ 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
+
240
+ 2. **Update CHANGELOG.md** — Add an entry under [Unreleased] → Added describing the new blueprint.
241
+
242
+ 3. **Update the directory structure** in README.md if it's shown there.
243
+
244
+ 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
+
246
+ 5. **Ensure all three directories have the new scaffold command:** `.claude/commands/`, `.opencode/commands/`, and `.cursor/commands/`.
247
+
248
+ ## Step 7: Verify
249
+
250
+ Before considering the blueprint done:
251
+
252
+ 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
254
+ 3. Verify all files in files/ use proper placeholders (no hardcoded scopes or app names)
255
+ 4. Verify README.md and CHANGELOG.md are updated
256
+ 5. Show the user a summary of everything that was created
257
+
258
+ ## Tips for Good Blueprints
259
+
260
+ - **Extract from real projects** — Blueprints that come from battle-tested code are always better than theoretical ones.
261
+ - **Document the WHY** — The code is the easy part. The decisions and reasoning are what make AI-assisted scaffolding intelligent.
262
+ - **Keep it focused** — One blueprint, one problem. If you're tempted to add "and also X", that's probably a separate blueprint.
263
+ - **Include the monorepo wiring** — Package exports, workspace dependencies, turbo tasks, root scripts. This is always the part people get wrong, and it's where the blueprint adds the most value.
264
+ - **Think about maintenance** — What breaks silently if you forget to run something? Those are your maintenance hooks.
265
+ - **Use existing blueprints as your quality bar** — Read auth-better-auth before writing yours. Match that level of detail.
@@ -0,0 +1,230 @@
1
+ # New Project
2
+
3
+ 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.
4
+
5
+ ## Step 1: Read the Blueprints
6
+
7
+ Load all available blueprints so you understand what's possible:
8
+
9
+ ```
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/**/*
14
+ ```
15
+
16
+ Also scan for available feature blueprints:
17
+
18
+ ```
19
+ ~/Documents/WithMata/my-blueprints/blueprints/features/*/BLUEPRINT.md
20
+ ```
21
+
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.
23
+
24
+ ## Step 2: Assess Current State
25
+
26
+ Before doing anything, understand where this project stands.
27
+
28
+ **Check `.project-context.md`** in the target project root. This file tracks what has already been done:
29
+
30
+ - **Has a `## Product Discovery` section?** Discovery is complete.
31
+ - **Has a `## Foundation` section?** Foundation is scaffolded.
32
+ - **Has entries under `## Installed Blueprints`?** Some features are already installed.
33
+
34
+ **Explore the target directory:**
35
+
36
+ - Empty directory? Fresh start — begin from Stage 1.
37
+ - Has `docs/product/`? Discovery was done (even without a context file).
38
+ - Has `package.json`, `turbo.json`, workspace dirs? Foundation was done.
39
+ - Has auth files, DB packages, etc.? Features were installed.
40
+
41
+ ## Step 3: Determine Starting Point
42
+
43
+ Based on what you found, tell the user where things stand. Lead with the product, not the tech:
44
+
45
+ - **Nothing exists**: "This is a blank slate. Let's start by figuring out what you're building and who it's for — then we'll set up the codebase to support it."
46
+
47
+ - **Discovery done, nothing else**: "You've already defined [product name] — [problem statement in one line]. We've got a clear picture of the product. Let's turn that into something you can ship."
48
+
49
+ - **Discovery + Foundation done**: "The product is defined and the codebase is ready. Based on what [primary archetype] needs, let's wire in the right capabilities."
50
+
51
+ - **Everything done**: "This project looks fully set up. Want to add more capabilities, or revisit any of the product decisions?"
52
+
53
+ If the user wants to start at a specific stage, let them. If they want to redo a completed stage, confirm before proceeding (it may be destructive).
54
+
55
+ ---
56
+
57
+ ## Stage 1: Discovery
58
+
59
+ > "Before we write any code, let's get clear on what we're building and why it matters."
60
+
61
+ This is the most important stage. Everything downstream — the architecture, the features, the trade-offs — flows from what we define here. Don't rush it.
62
+
63
+ Follow the full discovery process from the product-discovery blueprint. This is a rigorous product conversation — challenge assumptions, research the market, and push until the product thesis is sharp. You'll work through:
64
+
65
+ 1. **Initial Framing** — What are you building? Who is it for? Why does it need to exist?
66
+ 2. **Problem Deep Dive** — 5 Whys to get past symptoms to root cause
67
+ 3. **User Definition** — Vivid archetypes and personas via scenario mapping + JTBD
68
+ 4. **Solution Positioning** — Competitive landscape, differentiation, "why now?"
69
+ 5. **Synthesis** — Distill everything into a defensible product thesis
70
+
71
+ Use the templates from the blueprint to generate:
72
+
73
+ ```
74
+ docs/product/
75
+ ├── product-thesis.md # The 2-minute read — pillars, metrics, positioning
76
+ ├── product-brief.md # Supporting research and detail
77
+ └── users/
78
+ ├── archetype-[name].md # Vivid portraits of who you're building for
79
+ └── research-summary.md # Evidence and sources
80
+ ```
81
+
82
+ Create or update `.project-context.md` with the `## Product Discovery` section.
83
+
84
+ ### Pause Point
85
+
86
+ After discovery is complete, connect what was defined to what comes next:
87
+
88
+ "We've defined [product name] around [N] core pillars: [list them]. The primary user is [archetype] — [one-line description of their world]. This gives us a clear foundation to build on. Want to set up the codebase now, or let this sit and come back to it?"
89
+
90
+ If stopping: "Whenever you're ready, run `/scaffold-foundation` to set up the project, or `/new-project` again to pick up where we left off."
91
+
92
+ ---
93
+
94
+ ## Stage 1.5: Project Type
95
+
96
+ After discovery is complete, determine the project type:
97
+
98
+ "Now let's set up the codebase. Are you building a:
99
+ 1. **Monorepo** — multiple packages, shared config, Turborepo (recommended for larger products with separate frontend/backend/packages)
100
+ 2. **Single-repo** — one application, everything in one package.json (simpler for smaller products or standalone apps)"
101
+
102
+ Record the choice in `.project-context.md` under `## Foundation`:
103
+ ```yaml
104
+ project_type: monorepo # or single-repo
105
+ ```
106
+
107
+ - If **monorepo**: proceed to Stage 2 (Foundation)
108
+ - If **single-repo**: skip Stage 2 entirely, proceed to Stage 3 (Features). Note in context: "Foundation skipped — single-repo project."
109
+
110
+ ---
111
+
112
+ ## Stage 2: Foundation
113
+
114
+ > "The product is defined. Let's build the structure to support it."
115
+
116
+ > **Note:** Skip this stage for single-repo projects — proceed directly to Stage 3.
117
+
118
+ Read the discovery context from `.project-context.md` to inform technical decisions:
119
+
120
+ - Derive the npm scope from the product name (e.g., "Acme Dashboard" -> `@acme`)
121
+ - Use the product pillars and archetype needs to inform any trade-offs
122
+ - Apply technical constraints from discovery if any were noted
123
+
124
+ Follow the foundation blueprint process. Only three questions — skip any already answered by project context:
125
+
126
+ 1. **npm scope** — defaults from product name
127
+ 2. **Project name** — human-readable, for metadata and page titles
128
+ 3. **Node.js version** — defaults to `>=22`
129
+
130
+ Scaffold the monorepo skeleton: root configs, TypeScript config package, Tailwind config package, Next.js app shell, and empty workspace directories for future blueprints.
131
+
132
+ After scaffolding:
133
+
134
+ 1. Run `pnpm install` to verify the workspace is valid
135
+ 2. Briefly verify the dev server boots: `pnpm dev`
136
+ 3. Append the `## Foundation` section to `.project-context.md`
137
+
138
+ ### Pause Point
139
+
140
+ After foundation is complete, bridge to features by referencing the product:
141
+
142
+ "The codebase is ready — [scope] monorepo with Turborepo, Biome, and a Next.js app shell. Now let's think about what [product name] needs to actually work. Want to look at what's available, or stop here for now?"
143
+
144
+ If stopping: "You can add capabilities anytime. Run `/scaffold-auth` for authentication, or `/new-project` to see all available blueprints."
145
+
146
+ ---
147
+
148
+ ## Stage 3: Features
149
+
150
+ > "Let's wire in what [product name] needs to deliver on its core pillars."
151
+
152
+ If discovery was completed, reference the product pillars and archetype needs when presenting features. Connect each blueprint back to the product — don't just list technical capabilities.
153
+
154
+ List the available feature blueprints. Read each `BLUEPRINT.md` under `blueprints/features/*/` and show only those with `Status: Complete`.
155
+
156
+ **Present features in dependency order** — blueprints that others depend on should be listed first. Check each blueprint's `## Blueprint Dependencies` section. For example, db should be listed before auth (since auth requires db).
157
+
158
+ For each available blueprint, show:
159
+ - **Name** — human-readable
160
+ - **What it enables for the product** — tie it to a pillar or user need when possible
161
+ - **Dependencies** — note if it requires another blueprint (e.g., "requires Database")
162
+ - **Command** — the slash command to run it individually
163
+
164
+ Example:
165
+
166
+ ```
167
+ Based on what [product name] needs:
168
+
169
+ 1. Authentication (Better Auth + Drizzle) — /scaffold-auth
170
+ User accounts, login flows, route protection. Required for [relevant pillar].
171
+ If org plugin: team/workspace management for [archetype need].
172
+ ```
173
+
174
+ Ask: "Which of these does [product name] need? We'll set them up one at a time."
175
+
176
+ If no discovery context exists, fall back to a straightforward capability list without the product framing.
177
+
178
+ ### For Each Selected Feature
179
+
180
+ 1. Read the feature's BLUEPRINT.md and all its files
181
+ 2. Read `.project-context.md` to understand current state
182
+ 3. Follow the blueprint's scaffolding process (ask its configuration questions, adapt files, etc.)
183
+ 4. Append the feature's entry to `## Installed Blueprints` in .project-context.md
184
+
185
+ After each feature is installed, ask: "[Feature] is wired in. Want to add another, or is [product name] ready to start building on?"
186
+
187
+ ---
188
+
189
+ ## Step 7: Final Summary
190
+
191
+ Once the user is done (whether after one stage or all three), provide a summary that connects the product to the technical foundation:
192
+
193
+ ### What We Built
194
+
195
+ - **The product** (if discovery ran) — what it is, who it's for, the core pillars it delivers on
196
+ - **The codebase** (if foundation ran) — how the project structure supports the product
197
+ - **The capabilities** (if features ran) — what's wired in and how it maps to product needs
198
+
199
+ ### Getting Started
200
+
201
+ ```
202
+ pnpm dev # Start the development server
203
+ ```
204
+
205
+ ### Environment Variables to Set
206
+
207
+ List any env vars that need values (aggregated from all stages).
208
+
209
+ ### Manual Steps Remaining
210
+
211
+ List anything that can't be automated (aggregated from all stages).
212
+
213
+ ### What's Next
214
+
215
+ Suggest next steps in terms of product progress, not just technical tasks. Reference specific commands:
216
+
217
+ - "The product thesis identified [pillar] as a core pillar — `/scaffold-auth` wires in the user accounts and access control to support that."
218
+ - "Other feature blueprints coming soon: UI components, database, Tailwind theming."
219
+ - "Start building the core product experience — the [archetype]'s primary workflow."
220
+
221
+ ---
222
+
223
+ ## Important Notes
224
+
225
+ - **Resumable** — this command always checks `.project-context.md` before starting. Run it again anytime to pick up where you left off, or use the individual stage commands (`/discover`, `/scaffold-foundation`, `/scaffold-auth`).
226
+ - **Non-destructive** — never overwrite existing files without asking. If a stage was already completed, confirm before redoing it.
227
+ - **Product-first** — every technical decision should trace back to the product definition. When in doubt, reference the pillars, the archetype, and the problem statement.
228
+ - **Conversational** — this is a guided conversation, not a script. Adapt to the user's pace. If they want to skip ahead, let them. If they want to dig deeper into a stage, follow their lead.
229
+ - **Project context is the source of truth** — every stage reads it, every stage appends to it. This is how stages communicate with each other across sessions.
230
+ - **Maintenance rules accumulate** — each stage injects its maintenance rules into the project's rules file(s). These rules tell the AI coding tool what actions to take after certain types of changes. They accumulate as more blueprints are installed — the monorepo rules from foundation, plus auth rules, plus database rules, etc. The tool reads these at the start of every session.