@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,158 @@
1
+ # Scaffold Foundation
2
+
3
+ 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.
4
+
5
+ ## Step 1: Read the Blueprint
6
+
7
+ Read the full foundation blueprint and all template files:
8
+
9
+ ```
10
+ ~/Documents/WithMata/my-blueprints/blueprints/foundation/monorepo-turbo/BLUEPRINT.md
11
+ ~/Documents/WithMata/my-blueprints/blueprints/foundation/monorepo-turbo/files/**/*
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 architecture documentation, naming conventions, folder conventions, and file manifest. Follow it precisely.
17
+
18
+ ## Step 2: Read Project Context
19
+
20
+ Check if `.project-context.md` exists in the target project root:
21
+
22
+ - **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.
23
+
24
+ - **If it has a Foundation section already**: warn the user. Ask: "Foundation was already set up. Do you want to re-scaffold (destructive — replaces existing structure) or skip?"
25
+
26
+ - **If no context file exists**: that is fine. Ask the user directly for the product name and npm scope.
27
+
28
+ ## Step 3: Understand Current State
29
+
30
+ Explore the target project directory:
31
+
32
+ - Is it empty? Fresh start — scaffold everything.
33
+ - Does it already have files? Ask before overwriting anything.
34
+ - Is there an existing `package.json`? Read it for context.
35
+
36
+ ## Step 4: Ask Configuration Questions
37
+
38
+ Only three questions — skip any already answered by project context:
39
+
40
+ 1. **npm scope** — "What npm scope should internal packages use? (e.g., @acme)" Default: derive from product name.
41
+ 2. **Project name** — "What is the human-readable project name?" (for metadata, page titles). Default: from discovery context.
42
+ 3. **Node.js version** — "Target Node.js version?" Default: `>=22`.
43
+
44
+ ## Step 5: Scaffold
45
+
46
+ Create the monorepo skeleton by adapting all files from the blueprint. Replace placeholders:
47
+
48
+ - `{{SCOPE}}` -> the npm scope (e.g., `@acme`)
49
+ - `{{APP_NAME}}` -> the human-readable name (e.g., `Acme Dashboard`)
50
+
51
+ ### 5a. Root Configuration
52
+
53
+ From `files/root/`, create at project root:
54
+ - `package.json` — root monorepo config
55
+ - `turbo.json` — task orchestration
56
+ - `pnpm-workspace.yaml` — workspace patterns
57
+ - `biome.json` — linting + formatting
58
+ - `.gitignore` — from `files/root/gitignore`
59
+
60
+ ### 5b. Config Packages
61
+
62
+ From `files/config/`, create:
63
+ - `config/typescript-config/` — base.json, nextjs.json, react-library.json, package.json
64
+ - `config/tailwind-config/` — shared-styles.css, postcss.config.js, package.json
65
+
66
+ ### 5c. Next.js App Shell
67
+
68
+ From `files/apps/web/`, create:
69
+ - `apps/web/package.json`
70
+ - `apps/web/tsconfig.json`
71
+ - `apps/web/next.config.ts`
72
+ - `apps/web/env.ts`
73
+ - `apps/web/postcss.config.mjs`
74
+ - `apps/web/app/layout.tsx`
75
+ - `apps/web/app/page.tsx`
76
+ - `apps/web/app/globals.css`
77
+
78
+ ### 5d. Empty Workspace Directories
79
+
80
+ Create empty directories for feature blueprints:
81
+ - `apis/` — backend feature blueprint will add servers here
82
+ - `packages/` — feature blueprints will add shared packages here
83
+
84
+ ### 5e. Initialize
85
+
86
+ After creating all files:
87
+ 1. Initialize git if not already a repo: `git init`
88
+ 2. Run `pnpm install` to verify the workspace configuration is valid
89
+ 3. Verify the dev server starts: `pnpm dev` (briefly — just check it boots)
90
+
91
+ ## Step 6: Update Project Context
92
+
93
+ Append the `## Foundation` section to `.project-context.md`:
94
+
95
+ ```yaml
96
+ ## Foundation
97
+ monorepo_tool: turborepo
98
+ package_manager: pnpm
99
+ npm_scope: "<scope>"
100
+ node_version: ">=22"
101
+ workspaces:
102
+ apps: ["web"]
103
+ apis: []
104
+ packages: []
105
+ config: ["typescript-config", "tailwind-config"]
106
+ framework: next.js (app router)
107
+ typescript: strict
108
+ linter: biome
109
+ styling: tailwind-v4
110
+ env_validation: t3-env + zod
111
+ module_resolution: node subpath imports (#prefix)
112
+ foundation_completed: <date>
113
+ ```
114
+
115
+ If `.project-context.md` does not exist, create it with the standard header and the Foundation section.
116
+
117
+ ### Inject Maintenance Rules
118
+
119
+ Append the condensed maintenance rules to the target project's rules file(s):
120
+
121
+ 1. If `CLAUDE.md` exists in the target project → append rules there
122
+ 2. If `AGENTS.md` exists in the target project → append rules there
123
+ 3. If both exist → append to both (keep them in sync)
124
+ 4. If neither exists → ask the user which AI coding tool(s) they use:
125
+ - Claude Code → create CLAUDE.md with a `## Maintenance Rules` section
126
+ - OpenCode or Cursor → create AGENTS.md with a `## Maintenance Rules` section (both tools read AGENTS.md)
127
+ - Multiple tools → create all applicable files
128
+
129
+ The maintenance rules content is identical regardless of which file it goes into:
130
+
131
+ ```markdown
132
+ ## Maintenance Rules
133
+
134
+ ### Monorepo maintenance
135
+ - After every code change: format with Biome (`pnpm biome check --write .`) before considering work complete
136
+ - After adding new workspace packages: verify `pnpm-workspace.yaml` patterns match, run `pnpm install`
137
+ - After modifying shared configs (`config/typescript-config/`, `config/tailwind-config/`): verify all consumers still build
138
+ - After changing `turbo.json`: verify task ordering with `pnpm turbo run <task> --dry`
139
+ - After adding workspace dependencies: run `pnpm install` to create workspace links
140
+ - Keep `turbo.json` tasks with `cache: false` for any task with side effects (migrations, code generation)
141
+ ```
142
+
143
+ ## Step 7: Summarize
144
+
145
+ Tell the user:
146
+
147
+ - Project structure overview (directory tree)
148
+ - What was configured (scope, Node version, tooling)
149
+ - How to start development: `pnpm dev`
150
+ - Available feature blueprints to install next
151
+ - Suggest: "Run `/scaffold-auth` to add authentication. Other feature blueprints: ui-shared-components, tailwind-v4, db-drizzle-postgres."
152
+
153
+ ## Important Notes
154
+
155
+ - Never overwrite existing files without asking.
156
+ - Preserve all `// CONFIGURE:` comments in generated files so the user can find customization points.
157
+ - The Tailwind config is intentionally minimal — the UI feature blueprint extends it with shadcn, animations, and component-specific styles.
158
+ - Feature blueprints will add scripts to root `package.json` and tasks to `turbo.json` — the foundation provides the base that they extend.
@@ -0,0 +1,183 @@
1
+ ---
2
+ description: Run a project health check against available blueprints
3
+ ---
4
+
5
+ # Project Audit
6
+
7
+ Run a health check against available blueprints. Analyze this project's current state and recommend improvements, missing best practices, or blueprints that could replace hand-rolled infrastructure. This command is read-only — it does not modify any files.
8
+
9
+ ## Step 1: Read Available Blueprints
10
+
11
+ Load all available blueprint specs to understand what is possible:
12
+
13
+ ```
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
17
+ ```
18
+
19
+ Also scan for any additional feature blueprints:
20
+
21
+ ```
22
+ ~/Documents/WithMata/my-blueprints/blueprints/features/*/BLUEPRINT.md
23
+ ```
24
+
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.
26
+
27
+ ## Step 2: Read Project Context
28
+
29
+ Check if `.project-context.md` exists in this project root.
30
+
31
+ - **If it exists**: read it fully. Note which stages are complete (Discovery, Foundation, Installed Blueprints) and what choices were made.
32
+ - **If it does not exist**: note this — it means either no blueprints have been used, or the project predates the blueprint system.
33
+
34
+ ## Step 3: Explore the Project
35
+
36
+ Regardless of whether project context exists, explore the actual project to understand its true state. If `.project-context.md` contradicts what you find in the actual files, trust the files and note the discrepancy.
37
+
38
+ ### 3a. Product & Planning
39
+
40
+ - Does `docs/product/` exist? Are there product briefs, user stories, or discovery artifacts?
41
+ - Is there any structured product documentation, or just a README?
42
+
43
+ ### 3b. Project Structure & Type
44
+
45
+ - **Detect project type:**
46
+ - **Monorepo indicators**: `pnpm-workspace.yaml`, `turbo.json`, `nx.json`, `lerna.json`, or `"workspaces"` in root `package.json`
47
+ - **Single-repo indicators**: Single `package.json` at root, `src/` directory, no workspace config
48
+ - Record as `monorepo` or `single-repo` in the report
49
+ - What package manager? Check for `pnpm-lock.yaml`, `yarn.lock`, `package-lock.json`, `bun.lock`
50
+ - If monorepo: What workspaces exist? List `apps/`, `packages/`, `apis/`, `config/` or equivalent
51
+ - Is there a `biome.json`? ESLint config? Prettier config?
52
+ - Is TypeScript strict? Check `tsconfig.json` for `strict: true` and `noUncheckedIndexedAccess`
53
+ - Are there shared config packages? Or is config duplicated?
54
+
55
+ ### 3c. Authentication
56
+
57
+ - Is there an auth system? Search for:
58
+ - Better Auth config files (`better-auth`, `createAuthClient`)
59
+ - NextAuth/Auth.js files (`auth.ts`, `[...nextauth]`, `authOptions`)
60
+ - Hand-rolled auth (JWT imports, `bcrypt`, `jsonwebtoken`, session handling in middleware)
61
+ - Third-party services (Clerk, Auth0, Supabase auth, Firebase auth)
62
+ - Are there login/signup pages? Route protection middleware?
63
+ - Are there organization/team/workspace features?
64
+
65
+ ### 3d. Database
66
+
67
+ - Is Drizzle set up? Check for `drizzle.config.ts`, `drizzle-kit`
68
+ - Other ORMs? Check for Prisma (`schema.prisma`), TypeORM, Knex
69
+ - Is there a shared DB package, or is database access scattered?
70
+
71
+ ### 3e. Styling & UI
72
+
73
+ - Tailwind version? Check `tailwindcss` version in package.json — v3 (JS config) vs v4 (CSS config)
74
+ - Is there a shared UI package, or are components duplicated?
75
+ - Component library? shadcn/ui, Radix, MUI, Chakra?
76
+
77
+ ### 3f. Environment & Validation
78
+
79
+ - How are env vars handled? t3-env, raw `process.env`, dotenv only?
80
+ - Is there input validation? Zod, Valibot, Yup, Joi?
81
+
82
+ ### 3g. Code Quality
83
+
84
+ - Are there patterns that diverge from best practices?
85
+ - Default exports where named exports are preferred
86
+ - Missing barrel exports (`index.ts`) in packages
87
+ - File-type organization instead of feature-based
88
+ - Missing or inconsistent error handling
89
+
90
+ ### 3h. Blueprint Dependency Check
91
+
92
+ For each blueprint listed under `## Installed Blueprints` in `.project-context.md`:
93
+ - Read its `## Blueprint Dependencies` section from the BLUEPRINT.md
94
+ - Check if each `required` dependency is also listed in Installed Blueprints
95
+ - If a required dependency is missing, include it in the report as a recommendation
96
+
97
+ Example finding: "auth-better-auth is installed but its required dependency db-drizzle-postgres is not. Auth created a minimal db structure that lacks the full schema-group patterns. Run `/scaffold-db` to add the complete db patterns — it will merge without overwriting auth files."
98
+
99
+ ## Step 4: Generate the Audit Report
100
+
101
+ Present findings as a structured report. Be concrete and specific — reference actual files and patterns found.
102
+
103
+ ### Report Format
104
+
105
+ ---
106
+
107
+ **Project Audit: [project name or directory name]**
108
+
109
+ ### Current State
110
+
111
+ | Area | Status | Details |
112
+ |------|--------|---------|
113
+ | Product Discovery | [done / not found / partial] | [Brief note] |
114
+ | Foundation / Structure | [done / partial / needs work] | [Brief note] |
115
+ | Authentication | [blueprint / hand-rolled / third-party / none] | [Brief note] |
116
+ | Database | [Drizzle / Prisma / other / none] | [Brief note] |
117
+ | Styling | [Tailwind v4 / v3 / other] | [Brief note] |
118
+ | Code Quality | [good / needs attention] | [Brief note] |
119
+
120
+ ### Recommendations
121
+
122
+ For each recommendation:
123
+
124
+ 1. **[Priority: High/Medium/Low] [Category] — [One-line summary]**
125
+ - **What we found:** [Specific observation referencing actual files]
126
+ - **Why it matters:** [Impact on the project — explain for non-technical users too]
127
+ - **Action:** [Exact command or step to fix it]
128
+
129
+ ---
130
+
131
+ ### Recommendation Priority Guidelines
132
+
133
+ **High priority** — things that block progress or create real risk:
134
+ - No auth system and the product needs user accounts
135
+ - No monorepo structure in a multi-workspace project
136
+ - Hand-rolled auth with security gaps (plain text passwords, no CSRF, no rate limiting)
137
+ - Missing environment variable validation
138
+
139
+ **Medium priority** — things that improve quality and maintainability:
140
+ - A blueprint could replace hand-rolled infrastructure
141
+ - Missing product documentation for a project still figuring out its direction
142
+ - Inconsistent patterns across workspaces
143
+ - Tailwind v3 when v4 is available
144
+ - ESLint + Prettier when Biome could replace both
145
+
146
+ **Low priority** — nice-to-haves:
147
+ - Blueprints in development that are not yet available (mention them as "coming soon")
148
+ - Style preferences that do not affect functionality
149
+ - Optimizations for mature projects
150
+
151
+ ## Step 5: Provide Actionable Next Steps
152
+
153
+ End the report with a clear list of what to do, in recommended order:
154
+
155
+ ### Next Steps
156
+
157
+ ```
158
+ # Run these in order — each one is independent, stop whenever you want
159
+
160
+ 1. [command] # [what it does and why]
161
+ 2. [command] # [what it does and why]
162
+ ...
163
+ ```
164
+
165
+ For blueprint commands, use the slash command format: `/discover`, `/scaffold-foundation`, `/scaffold-auth`
166
+
167
+ For non-blueprint improvements, include the actual shell commands or instructions.
168
+
169
+ ## Tone Guidelines
170
+
171
+ - **Be honest.** If the project is in great shape, say so. Do not manufacture recommendations.
172
+ - **Be warm and accessible.** The user may be non-technical. Explain WHY something matters, not just what to do.
173
+ - **Be specific.** "Your auth looks hand-rolled" is not helpful. "I found JWT signing in `lib/auth.ts` without CSRF protection — the auth blueprint handles this with Better Auth's built-in security" is helpful.
174
+ - **Separate facts from opinions.** "You are using ESLint + Prettier" is a fact. "Biome could replace both with simpler config" is a recommendation — label it as such.
175
+ - **Do not overwhelm.** Lead with the 3-5 most impactful recommendations. If there are many findings, prioritize.
176
+ - **Celebrate what is done well.** If something follows best practices, acknowledge it briefly.
177
+
178
+ ## Important Notes
179
+
180
+ - This command is **read-only**. It does not modify any files — it only reads and reports.
181
+ - Only recommend blueprints with `Status: Complete`. Mention planned blueprints (tailwind-v4, ui-shared-components) as "coming soon" if relevant, but do not suggest running commands for them.
182
+ - If the project is empty or brand new, keep the report short: "This is a fresh project. Here is where to start." and suggest `/discover` or `/scaffold-foundation`.
183
+ - If everything looks good, say so: "This project is in great shape. No immediate recommendations."
@@ -0,0 +1,96 @@
1
+ ---
2
+ description: Run a structured product discovery session — outputs docs, no code
3
+ ---
4
+
5
+ # Run Product Discovery
6
+
7
+ 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.
8
+
9
+ ## Step 1: Read the Blueprint
10
+
11
+ Read the full discovery blueprint and all templates:
12
+
13
+ ```
14
+ ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/BLUEPRINT.md
15
+ ~/Documents/WithMata/my-blueprints/blueprints/discovery/product-discovery/templates/*
16
+ ```
17
+
18
+ If not found at that path, ask the user for the path to their blueprints repo.
19
+
20
+ The BLUEPRINT.md contains the full methodology: phased session structure, frameworks, operating principles, research strategy, challenge patterns, and quality checkpoints. Follow it precisely.
21
+
22
+ ## Step 2: Check for Existing Discovery
23
+
24
+ Check if `.project-context.md` exists and already contains a `## Product Discovery` section. If it does:
25
+
26
+ - Show the user what was previously discovered
27
+ - Ask: "Product discovery was already completed. Would you like to redo it (replaces existing), refine it (update specific sections), or skip?"
28
+
29
+ ## Step 3: Run the Discovery Session
30
+
31
+ 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.
32
+
33
+ This is conversational — you are guiding the user through structured discovery, not filling in a form.
34
+
35
+ Quick reference for the phases:
36
+ 1. **Phase 1: Initial Framing** — what and who
37
+ 2. **Phase 2: Problem Deep Dive** — root cause via 5 Whys
38
+ 3. **Phase 3: User Definition** — archetypes and persona variations
39
+ 4. **Phase 4: Solution Positioning** — competitive landscape and differentiation
40
+ 5. **Phase 5: Synthesis** — distill findings for documentation
41
+
42
+ ## Step 4: Verify Quality Checkpoints
43
+
44
+ Before generating documentation, verify ALL quality checkpoints listed in BLUEPRINT.md pass. If any fail, continue probing — do not rush to documentation.
45
+
46
+ ## Step 5: Generate Documentation
47
+
48
+ 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.
49
+
50
+ ```
51
+ docs/
52
+ └── product/
53
+ ├── product-thesis.md
54
+ ├── product-brief.md
55
+ └── users/
56
+ ├── archetype-[name].md # One per archetype identified
57
+ └── research-summary.md
58
+ ```
59
+
60
+ 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.
61
+
62
+ ## Step 6: Update Project Context
63
+
64
+ Create or update `.project-context.md` in the target project root:
65
+
66
+ - If the file does not exist, create it with a header and the `## Product Discovery` section
67
+ - If the file exists but has no discovery section, add the discovery section after the header
68
+ - If the file exists with a discovery section (user chose to redo), replace that section only
69
+
70
+ Append this structured YAML block:
71
+
72
+ ```yaml
73
+ ## Product Discovery
74
+ product_name: "<name>"
75
+ problem_statement: "<one sentence>"
76
+ core_pillars:
77
+ - "<pillar 1>"
78
+ - "<pillar 2>"
79
+ - "<pillar 3>"
80
+ primary_archetype: "<archetype name>"
81
+ discovery_completed: <date>
82
+ artifacts:
83
+ - docs/product/product-thesis.md
84
+ - docs/product/product-brief.md
85
+ - docs/product/users/archetype-<name>.md
86
+ - docs/product/users/research-summary.md
87
+ ```
88
+
89
+ ## Step 7: Summary
90
+
91
+ Tell the user:
92
+
93
+ - What documents were generated (list each with a one-line description)
94
+ - Key findings: core pillars, primary archetype, main competitive gap
95
+ - Critical assumptions that need validation
96
+ - Suggest next step: "Run `/scaffold-foundation` to set up the project skeleton, or `/new-project` to continue the full workflow."