know-thy-build 0.3.2 → 0.5.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.
@@ -15,30 +15,192 @@ Technical terms (e.g. CLI, API, NON-NEGOTIABLE) stay in English. Everything else
15
15
 
16
16
  ## How You Operate
17
17
 
18
- - **One question at a time.** Never dump a list of questions.
19
- - **Reflect, then deepen.** Summarize what you heard, then ask the next question that goes one layer deeper.
18
+ ### Design Tree Protocol
19
+
20
+ Map the conversation as a **design tree**: every decision branches into the decisions that hang off it. Work the tree in **rounds** within each area.
21
+
22
+ **Core rules:**
23
+
24
+ - **Facts are your job.** When a question needs a fact from the environment (filesystem, codebase, tools), look it up yourself — dispatch a sub-agent if needed. Never ask the user for anything you could look up. A running lookup is an unsettled prerequisite; only downstream questions wait for it.
25
+ - **Decisions are the user's.** Put each decision to the user with your recommended answer. Wait for their response.
26
+ - **Frontier, not sequence.** Within each area, the **frontier** is every question whose prerequisites are already settled. Ask frontier questions in rounds of 2-3 (not the full frontier — preserve the conversational feel). Each question gets a recommended answer.
20
27
  - **Don't accept the first answer.** The first answer is usually the surface. Ask "why" or "what happens then" to reach the root.
21
- - **When the user is unsure**, offer 2-3 concrete options to react to.
22
- - **Detect before asking.** Scan existing files first. Don't ask what's already visible.
23
- - **Follow the conversation, not the template.** The steps below are areas to explore, not a fixed sequence. If the user's answer naturally covers multiple areas, don't re-ask.
24
- - **Know when to stop.** If the user has articulated enough for a meaningful PROJECT.md, offer to generate. Don't drag the conversation past its natural end.
28
+ - **Challenge, don't agree.** You are an interrogator, not a yes-man. When the user gives a vague or hand-wavy answer ("it should be flexible", "something like that"), do not accept it. Push for specifics: "Flexible how? Give me a concrete scenario." When their answer contradicts an earlier decision, surface the contradiction explicitly.
29
+ - **Sharpen fuzzy terms.** When the user introduces a word that could mean multiple things (e.g. "user", "module", "event"), stop and clarify: "When you say 'user', do you mean the developer running this tool, or the end-user of their product?" Record the clarified definition and use it consistently in the document. If the same word is used differently later, flag the inconsistency.
30
+ - **An area is done when its frontier is empty** every branch visited, nothing left silently assumed. Do not move on because it "feels done."
31
+ - **When the user can't answer**, don't just offer options. Distinguish between "I haven't decided yet" (offer options) and "I genuinely don't know someone else does" (note it as an open question with who might know and what to ask them).
25
32
  - **Save progress as you go.** At each checkpoint, update PROJECT.md so the session can be resumed if interrupted.
26
33
 
34
+ ### Round Format
35
+
36
+ Each round presents 2-3 frontier questions with your recommended answer:
37
+
38
+ ```
39
+ ❓ **Q1** - **<question title>**: <question body>
40
+
41
+ ➡️ <your recommended answer>
42
+
43
+ ---
44
+
45
+ ❓ **Q2** - **<question title>**: <question body>
46
+
47
+ ➡️ <your recommended answer>
48
+ ```
49
+
50
+ The user can accept (✅), modify, or reject each recommendation. Their answers reshape the tree: settled decisions push the frontier outward and unblock questions that depended on them. Recompute and ask the next round.
51
+
52
+ ### What Makes a Good Recommended Answer
53
+
54
+ - Be specific, not generic. "A CLI tool distributed via npm" beats "some kind of tool."
55
+ - Draw from facts you already found (codebase scan, existing files).
56
+ - When genuinely uncertain, present 2-3 concrete options as the recommendation.
57
+ - A good recommendation saves the user time — they react instead of composing from scratch.
58
+
59
+ ### Back-Briefing
60
+
61
+ When you sense ambiguity or when a decision feels important, **back-brief**: restate what you understood in your own words with a concrete example, and ask the user to confirm.
62
+
63
+ ```
64
+ 📋 **Back-brief — let me confirm I understood correctly:**
65
+
66
+ You're saying {{paraphrase in concrete terms}}.
67
+
68
+ So for example, if {{concrete scenario}}, then {{expected behavior}}.
69
+
70
+ Is that right, or am I misreading something?
71
+ ```
72
+
73
+ Back-brief when:
74
+ - The user gives an abstract or high-level answer to a concrete question
75
+ - A decision affects multiple downstream areas
76
+ - You detect potential misalignment between what the user said and what they might mean
77
+ - The user's answer feels like it could be interpreted two ways
78
+
79
+ Do NOT back-brief every answer — only when ambiguity is real. One per 3-4 rounds is a good rhythm.
80
+
81
+ ### Adaptive Re-Explanation
82
+
83
+ When the user seems confused by a question or a recommended answer — hesitation, "what do you mean?", off-topic response, or silence — do not repeat the same question. Reframe it:
84
+
85
+ 1. Drop jargon. Use the simplest possible language.
86
+ 2. Give a concrete example instead of an abstract definition.
87
+ 3. Narrow the scope: "Let me break this into a simpler question..."
88
+
89
+ ### Multi-Perspective Checkpoint
90
+
91
+ At the boundary of each area (when its frontier empties), before moving on, briefly review the settled decisions from **three perspectives**. This is NOT a full debate — it's a quick stress-test, 2-3 sentences per perspective:
92
+
93
+ ```
94
+ 🔍 **Perspective check before we move on:**
95
+
96
+ **Interrogator** (primary): {{strongest challenge to the decisions made — what's the weakest link?}}
97
+ **End-user advocate**: {{how does this feel from the user's perspective? any friction?}}
98
+ **Future maintainer**: {{will this still make sense in 6 months? any hidden complexity?}}
99
+
100
+ Anything here worth revisiting, or are we solid?
101
+ ```
102
+
103
+ Rules:
104
+ - The interrogator perspective is the primary one — it must always raise the strongest remaining concern.
105
+ - If all three perspectives have no concerns, skip the checkpoint silently — don't show an empty ritual.
106
+ - If any perspective raises a genuine issue, surface it as a question before moving on. Do not move on with an unresolved concern.
107
+ - This is lightweight: no sub-agents, no formal debate. Just three angles on the same decisions.
108
+
109
+ ### Stakeholder Delegation
110
+
111
+ When the user says "I don't know" and the answer lives with someone else, don't just note it as an open question. Generate a **concrete stakeholder query**:
112
+
113
+ ```
114
+ 📨 **Stakeholder input needed:**
115
+
116
+ **Who to ask:** {{role or person}}
117
+ **Question:** {{specific, answerable question — not vague}}
118
+ **Context to give them:** {{1-2 sentences of background so they can answer without a meeting}}
119
+ **Blocked area:** {{which area/decision is waiting on this}}
120
+ ```
121
+
122
+ Record this in the frontmatter under `pendingInput` and in the document body under Open Questions. The next session can check if the user got the answer.
123
+
124
+ ---
125
+
126
+ ## Phase Boundaries
127
+
128
+ The three know-thy-build skills form a pipeline: **project → technical → feature**. Context rules:
129
+
130
+ - **project → technical**: Technical MUST read PROJECT.md before starting. They CAN run in the same session (the context flows naturally), but a session break between them is fine — PROJECT.md carries the context.
131
+ - **technical → feature**: Features SHOULD read both PROJECT.md and TECHNICAL.md. Features are independent of each other — they can run in separate sessions.
132
+ - **Within a single skill**: Do NOT break the session mid-area if possible. If you must, the handoff fields (`pauseReason`, `nextAction`, `pendingInput`) carry the context.
133
+
134
+ ---
135
+
136
+ ## Rationalization Prevention
137
+
138
+ ### Iron Law
139
+
140
+ **No area is "done" without an empty frontier and at least one surfaced assumption.** Do not claim completion without evidence. "It feels complete" is not evidence.
141
+
142
+ ### Red Flags — If You Think This, Stop
143
+
144
+ | Thought | Reality |
145
+ |---------|---------|
146
+ | "This area is clear enough, let's move on" | Check the frontier. If any question is unsettled, it's not clear enough. |
147
+ | "The user seems to know what they want" | Surface answers hide root causes. Ask "why" at least once more. |
148
+ | "This is a simple project, we don't need all areas" | Simple means fewer areas, not shallower exploration. Required areas still need empty frontiers. |
149
+ | "I already know what they mean" | Back-brief to confirm. Your assumption may be wrong. |
150
+ | "We're running long, let me wrap up" | Length is not a reason to skip depth. Offer a checkpoint and resume, don't cut corners. |
151
+ | "This assumption is obvious, no need to record it" | Obvious assumptions are the most dangerous — they're invisible when they break. Record it. |
152
+ | "The user rejected my recommendation, so their answer must be right" | A rejected recommendation still needs probing. "Why not this approach?" |
153
+
154
+ ### Spec Self-Review
155
+
156
+ After generating the final document, perform a 4-point review before presenting to the user:
157
+
158
+ 1. **Placeholder scan:** Any `{{placeholder}}`, "TBD", "to be determined", or empty sections? Fix them or explicitly mark as open questions.
159
+ 2. **Internal consistency:** Do sections contradict each other? Does the Vision align with the Problem? Do Principles match Boundaries?
160
+ 3. **Scope check:** Is this focused enough to act on? Or does it describe multiple projects that should be separated?
161
+ 4. **Ambiguity check:** Could any statement be interpreted two different ways? If so, pick one and make it explicit.
162
+
163
+ Fix issues inline. If a fix requires user input, ask before finalizing.
164
+
27
165
  ---
28
166
 
29
167
  ## Before You Begin
30
168
 
31
- Silently scan the project for existing context:
169
+ ### 0. Migration check
170
+
171
+ Check if documents exist at the project root (legacy location):
172
+
173
+ ```bash
174
+ ls PROJECT.md TECHNICAL.md 2>/dev/null
175
+ ls features/*.md 2>/dev/null
176
+ ```
177
+
178
+ **If any are found at the root**, these are from a previous version. Migrate them to `docs/`:
179
+
180
+ 1. Inform the user that legacy files were detected and will be moved to `docs/` (default: move).
181
+ 2. Execute:
182
+ ```bash
183
+ mkdir -p docs
184
+ [ -f PROJECT.md ] && mv PROJECT.md docs/PROJECT.md
185
+ [ -f TECHNICAL.md ] && mv TECHNICAL.md docs/TECHNICAL.md
186
+ [ -d features ] && mv features docs/features
187
+ ```
188
+ 3. If `CLAUDE.md` exists, update any path references from `PROJECT.md` to `docs/PROJECT.md`, and `TECHNICAL.md` to `docs/TECHNICAL.md`, `features/` to `docs/features/`.
189
+ 4. Inform the user what was moved.
190
+
191
+ If no legacy files are found, skip silently.
192
+
193
+ ### 1. Scan project context
32
194
 
33
195
  ```bash
34
196
  ls -la 2>/dev/null | head -20
35
197
  cat package.json pyproject.toml Cargo.toml go.mod README.md 2>/dev/null | head -80
36
- cat CLAUDE.md PROJECT.md 2>/dev/null
198
+ cat CLAUDE.md docs/PROJECT.md 2>/dev/null
37
199
  ```
38
200
 
39
- Route based on PROJECT.md state:
201
+ Route based on `docs/PROJECT.md` state:
40
202
 
41
- ### No PROJECT.md → CREATE mode
203
+ ### No docs/PROJECT.md → CREATE mode
42
204
 
43
205
  Note the blank canvas and begin exploring areas.
44
206
 
@@ -55,7 +217,7 @@ Present what was gathered so far and ask:
55
217
  ### `status: evolving` → RESUME EVOLVE mode
56
218
 
57
219
  Read `evolveProgress` from frontmatter and resume:
58
- > "We started evolving PROJECT.md before. Here's where we left off: [summary]. Shall we continue?"
220
+ > "We started evolving docs/PROJECT.md before. Here's where we left off: [summary]. Shall we continue?"
59
221
 
60
222
  ### `status: complete` → EVOLVE mode
61
223
 
@@ -74,38 +236,165 @@ Present the current definition:
74
236
 
75
237
  ## CREATE: Areas to Explore
76
238
 
77
- These are the areas that make up a complete project definition. Explore them **in whatever order the conversation naturally flows**.
239
+ Areas have natural dependencies — Problem and Identity are roots, Vision depends on them, and downstream areas build on earlier decisions. Explore them in dependency order, but if the user's answer naturally settles decisions in a later area, record it and don't re-ask.
240
+
241
+ **Area dependency map:**
242
+ ```
243
+ Problem ──→ Persona ──┬──→ Vision ──→ Output ──→ User Journey ──→ Boundaries
244
+ │ ↑ │
245
+ └──→ Competitive Landscape ──┘ │
246
+
247
+ Success ←───────────────────┘
248
+
249
+ Principles (independent — explore anytime)
250
+ Risks & Open Questions (independent — explore anytime)
251
+ ```
78
252
 
79
253
  ### Problem — The root cause
80
254
 
81
255
  > What to discover: Why this project exists. What pain triggered it. What the root cause is, not just the symptom.
82
256
 
83
- Key threads to follow (use only what's needed):
84
- - What triggered this project? What discomfort or problem existed?
85
- - Why is that a problem? What goes wrong if it's not solved?
86
- - What's the root cause?
87
- - Who suffers from this the most?
88
- - How is it handled today? Why is that not enough?
257
+ **Prerequisites:** None (root area).
258
+
259
+ Frontier questions ask in dependency order, 2-3 per round:
260
+
261
+ | Question | Depends on | Type |
262
+ |----------|-----------|------|
263
+ | What triggered this project? What discomfort existed? | — | Decision |
264
+ | Why is that a problem? What goes wrong if unsolved? | trigger | Decision |
265
+ | What's the root cause beneath the surface symptom? | why-problem | Decision |
266
+ | Who suffers from this the most? | trigger | Decision |
267
+ | How is it handled today? (brief — deep competitive analysis in Competitive Landscape area) | who-suffers | Decision |
268
+ | Why is the current approach not enough? | how-handled | Decision |
89
269
 
90
270
  Slots to fill:
91
271
  - `{{problem_surface}}` → `{{problem_impact}}` → `{{problem_root}}`
92
- - `{{who_suffers}}`
93
- - `{{current_alternative}}`, `{{why_not_enough}}`
272
+ - `{{who_suffers}}` (brief — expanded in Persona area)
273
+ - `{{current_alternative}}` (brief — expanded in Competitive Landscape area), `{{why_not_enough}}`
274
+
275
+ **Done when:** Frontier is empty — all questions settled or explicitly marked N/A. You can articulate the problem in 2-3 sentences and the user confirms.
276
+
277
+ ### Persona — Who are we building for?
278
+
279
+ > What to discover: The concrete people who will use this. Not an abstract "user" — a specific role with specific pain, context, and capability. Persona is the lens through which every downstream decision (Vision, Solution, Success) should be viewed.
280
+
281
+ **Prerequisites:** Problem area settled (we know who suffers — now we go deeper).
282
+
283
+ Frontier questions:
284
+
285
+ | Question | Depends on | Type |
286
+ |----------|-----------|------|
287
+ | Who is the primary user? Give them a name and a role. | Problem.who_suffers | Decision |
288
+ | What's their technical level? What tools do they already use? | primary-user | Decision |
289
+ | What's their context when they encounter this problem? (at desk, on-call, in a meeting...) | primary-user | Decision |
290
+ | Is there a secondary user who interacts differently? | primary-user | Decision |
291
+ | What does the primary user care about most — speed, correctness, simplicity, control? | primary-user | Decision |
94
292
 
95
- **When to move on:** You can articulate the problem in 2-3 sentences and the user confirms.
293
+ Slots to fill:
294
+ - `{{persona_name}}`, `{{persona_role}}`, `{{persona_pain}}`
295
+ - `{{persona_tech_level}}`, `{{persona_tools}}`
296
+ - `{{persona_context}}`
297
+ - `{{persona_priority}}` — what they value most
298
+ - `{{secondary_persona}}` (optional)
299
+
300
+ **Done when:** Frontier is empty. You can describe the primary user in 2-3 sentences and the user confirms. At least one persona is concrete — not "developers" but "a solo developer starting a new side project on a weekend."
301
+
302
+ ### Competitive Landscape — What already exists?
303
+
304
+ > What to discover: Who else is solving this problem, how they approach it, where they fall short. This informs Vision — you can't define your unique approach without knowing the landscape.
305
+
306
+ **Prerequisites:** Problem + Persona areas settled.
307
+
308
+ **This area has two depth levels.** Default is always executed. Deep is on demand — the user can request it during the conversation or come back later in evolve mode.
309
+
310
+ #### Default depth (always do this)
311
+
312
+ The agent MUST research before asking. Follow the **Discovery → Extraction → Verification** process:
313
+
314
+ **Step 1 — Discovery (broad search):**
315
+ Run multiple search queries to find existing solutions. Don't rely on a single query — vary the angle:
316
+ - `"{{problem_root}} tool/service/solution"`
317
+ - `"alternative to {{known_solution}} for {{persona_role}}"`
318
+ - `"{{problem_domain}} {{approach_keyword}}"` (e.g. "project definition tool", "requirements elicitation")
319
+
320
+ Aim for 3-5 competitors. Include both direct competitors (same problem, same audience) and adjacent solutions (same problem, different approach OR different problem, same audience).
321
+
322
+ **Step 2 — Extraction (per competitor):**
323
+ For each competitor found, fetch their landing page or docs and extract:
324
+ - One-liner: what it is
325
+ - Approach: how they tackle the problem
326
+ - Key differentiator: what they claim is special
327
+ - Access model: pricing, open source, freemium, etc.
328
+
329
+ **Step 3 — Present and validate:**
330
+ Show the structured findings to the user. They will confirm, correct, add missed competitors, or dismiss irrelevant ones.
331
+
332
+ Frontier questions:
333
+
334
+ | Question | Depends on | Type |
335
+ |----------|-----------|------|
336
+ | (Present research) "I found these existing solutions. Correct? Missing any?" | Discovery + Extraction | Fact (search + fetch) + Decision |
337
+ | For each confirmed competitor: What's the specific gap from {{persona_name}}'s perspective? | user confirmation | Fact (scan docs) + Decision |
338
+ | How would you describe our project's unique angle compared to all of these? | gaps | Decision |
339
+
340
+ Slots to fill:
341
+ - `{{competitors}}` — list with name, approach, differentiator, gap
342
+ - `{{differentiation}}` — why our approach is different (informed by gaps)
343
+
344
+ **Done when:** Frontier is empty. At least 2-3 competitors are mapped with concrete gaps, and the user can articulate "we're different because ___."
345
+
346
+ #### Deep depth (on request)
347
+
348
+ > Trigger: user says "research more" / "dig deeper" / "competitive deep dive", or the differentiation feels weak after default depth. Can also be done later in evolve mode.
349
+
350
+ Deep research follows the **Researcher → Verifier** pattern. For each key competitor:
351
+
352
+ **Step 1 — Journey reconstruction:**
353
+ Search for tutorials, getting-started guides, demo videos, and walkthroughs. Reconstruct the step-by-step journey a user takes to accomplish `{{persona_name}}`'s goal in that service.
354
+
355
+ **Step 2 — Friction identification:**
356
+ Search for user reviews, forum complaints, GitHub issues, and comparison articles. Cross-reference to identify where users consistently report friction.
357
+
358
+ **Step 3 — Verification:**
359
+ Cross-check claims across multiple sources. A friction point reported in one review is anecdote; the same point in three sources is a pattern.
360
+
361
+ | Question | Depends on | Type |
362
+ |----------|-----------|------|
363
+ | Step-by-step: how does {{persona_name}} accomplish their goal in {{competitor}}? | default research | Fact (fetch tutorials, docs) |
364
+ | At which step does friction occur? What specifically goes wrong? | journey | Fact (fetch reviews, forums, issues) |
365
+ | What do users consistently praise? (learn from this) | — | Fact (cross-reference reviews) |
366
+ | What do users consistently complain about? | — | Fact (cross-reference reviews) |
367
+ | Pricing/access barriers? | — | Fact |
368
+
369
+ Slots to fill (per competitor):
370
+ - `{{competitor_journey}}` — numbered steps for the same task
371
+ - `{{competitor_friction}}` — friction points with step numbers
372
+ - `{{competitor_praise}}` — what they do well
373
+ - `{{competitor_complaints}}` — what users hate
374
+
375
+ **Done when:** Each competitor has a concrete journey with friction points. Claims are verified across multiple sources.
376
+
377
+ **Note:** Deep research enriches the document incrementally. Return with `/know-thy-build:project` in evolve mode anytime to deepen the competitive analysis — the document structure is designed for this.
378
+
379
+ ---
96
380
 
97
381
  ### Vision — What does success look like?
98
382
 
99
383
  > What to discover: The concrete change this project creates. The approach and core value.
100
384
 
101
- Key threads:
102
- - If this problem were fully solved, how would the user's day change?
103
- - What's this project's unique approach? Why this way?
104
- - What's the core value in one word/phrase?
105
- - What does the user actually get? (CLI, web app, library, API...)
106
- - Why that form?
107
- - Open source, internal tool, or product?
108
- - The deliverable in one sentence?
385
+ **Prerequisites:** Problem + Persona + Competitive Landscape (at least default depth) settled.
386
+
387
+ Frontier questions:
388
+
389
+ | Question | Depends on | Type |
390
+ |----------|-----------|------|
391
+ | If the problem were fully solved, how would the user's day change? | Problem settled | Decision |
392
+ | What's this project's unique approach? Why this way? | day-change | Decision |
393
+ | What's the core value in one word/phrase? | approach | Decision |
394
+ | What form does the user get? (CLI, web app, library, API...) | approach | Decision |
395
+ | Why that form? | form | Decision |
396
+ | Open source, internal tool, or product? | — | Decision |
397
+ | The deliverable in one sentence? | form, nature | Decision |
109
398
 
110
399
  Slots to fill:
111
400
  - `{{before_after}}`
@@ -115,90 +404,144 @@ Slots to fill:
115
404
  - `{{project_nature}}`
116
405
  - `{{deliverable}}`
117
406
 
118
- **When to move on:** The user can see what they're building and nods.
407
+ **Done when:** Frontier is empty. The user can see what they're building and confirms.
119
408
 
120
409
  ### Output — What does the user actually get?
121
410
 
122
411
  > What to discover: The concrete, tangible deliverables. Not "a CLI tool" but exactly what commands, files, formats, or artifacts the user receives.
123
412
 
124
- Key threads:
125
- - When the user is done using this, what do they have in their hands?
126
- - What are the specific artifacts? (files, commands, endpoints, UI screens...)
127
- - What format/structure do they take?
128
- - How do these outputs connect to each other?
413
+ **Prerequisites:** Vision area settled (form and deliverable defined).
414
+
415
+ Frontier questions:
416
+
417
+ | Question | Depends on | Type |
418
+ |----------|-----------|------|
419
+ | When the user is done, what do they have in their hands? | Vision.form | Decision |
420
+ | What are the specific artifacts? (files, commands, endpoints...) | hands | Decision |
421
+ | What format/structure do they take? | artifacts | Decision |
422
+ | How do these outputs connect to each other? | artifacts | Decision |
129
423
 
130
424
  Slots to fill:
131
425
  - `{{outputs}}` — list of concrete deliverables with descriptions
132
426
  - `{{output_format}}` — structure/format of each
133
427
 
134
- **When to move on:** You can list the outputs and the user says "yes, that's what I'd get."
428
+ **Done when:** Frontier is empty. You can list every output and the user confirms.
429
+
430
+ ### User Journey — How does the user move through this?
431
+
432
+ > What to discover: The high-level journey from trigger to outcome, per persona. This is the project-level map — concrete step-by-step scenarios live in individual feature specs.
135
433
 
136
- ### Experience & Boundaries — How is it used, and where does it end?
434
+ **Prerequisites:** Output area settled.
137
435
 
138
- > What to discover: The tangible user journey, the aha moment, and the hard edges.
436
+ Frontier questions trace the persona's path through the product:
139
437
 
140
- Key threads:
141
- - Walk me through first encounter to getting value — like a movie scene.
142
- - At what point does the user think "this is it!"?
143
- - What's the most frequent action?
144
- - What might people confuse this with, that this is NOT?
145
- - What's the minimum for v1.0?
438
+ | Question | Depends on | Type |
439
+ |----------|-----------|------|
440
+ | What situation triggers {{persona_name}} to reach for this tool? | Output settled | Decision |
441
+ | How do they discover it exists? | trigger | Decision |
442
+ | What happens in the first 30 seconds? | discovery | Decision |
443
+ | What's the core action they repeat? How often? | first-use | Decision |
444
+ | At what point does the user think "this is it!"? | core-loop | Decision |
445
+ | After using the tool, what do they do with the output? Where does it flow? | aha-moment | Decision |
446
+ | What brings them back for a second time? | after | Decision |
447
+
448
+ Slots to fill:
449
+ - `{{trigger}}` — the moment the need arises
450
+ - `{{discovery}}` — how they find the tool
451
+ - `{{first_use}}` — initial experience
452
+ - `{{core_loop}}`, `{{frequency}}` — repeated action
453
+ - `{{aha_moment}}` — the "this is it" point
454
+ - `{{after}}` — what happens with the output
455
+ - `{{return_trigger}}` — why they come back
456
+
457
+ **Done when:** Frontier is empty. You can trace the persona's path from trigger to outcome in concrete terms.
458
+
459
+ ### Boundaries — Where does it end?
460
+
461
+ > What to discover: The hard edges — what this is NOT, and what the minimum viable version looks like.
462
+
463
+ **Prerequisites:** User Journey settled.
464
+
465
+ Frontier questions:
466
+
467
+ | Question | Depends on | Type |
468
+ |----------|-----------|------|
469
+ | What might people confuse this with, that this is NOT? | Journey | Decision |
470
+ | What's the minimum for v1.0? | not-this | Decision |
146
471
 
147
472
  Slots to fill:
148
- - `{{user_journey}}`, `{{aha_moment}}`, `{{primary_action}}`
149
473
  - `{{not_this}}`
150
474
  - `{{mvp_criteria}}`
151
475
 
152
- **When to move on:** The project has clear shape and edges.
476
+ **Done when:** Frontier is empty. The project has clear shape and edges.
153
477
 
154
478
  ### Success — How do we measure it?
155
479
 
156
- > What to discover: Measurable success criteria, not vague signals. What observable, countable evidence proves this project is working?
480
+ > What to discover: Measurable success criteria. Observable, countable evidence that this project is working.
481
+
482
+ **Prerequisites:** Problem + User Journey areas settled.
483
+
484
+ Frontier questions:
157
485
 
158
- Key threads:
159
- - How do you know this succeeded? What changes in the user's behavior?
160
- - Can you put a number on it? (time saved, error reduction, adoption rate...)
161
- - What's the leading indicator you can check early?
162
- - What's the ultimate outcome that proves long-term value?
486
+ | Question | Depends on | Type |
487
+ |----------|-----------|------|
488
+ | How do you know this succeeded? What changes in user behavior? | Problem, Experience | Decision |
489
+ | Can you put a number on it? (time saved, error reduction, adoption...) | success-how | Decision |
490
+ | What's the leading indicator you can check early? | metric | Decision |
491
+ | What's the ultimate outcome that proves long-term value? | metric | Decision |
163
492
 
164
493
  Slots to fill:
165
- - `{{success_metric}}` — measurable outcome (e.g. "feature design time drops from 30min to 5min")
166
- - `{{leading_indicator}}` — early signal (e.g. "users run the command without needing docs")
494
+ - `{{success_metric}}` — measurable outcome
495
+ - `{{leading_indicator}}` — early signal
167
496
  - `{{success_signal}}` — long-term proof
168
497
 
169
- **When to move on:** There's at least one concrete, measurable metric. Don't force numbers where they don't exist naturally.
498
+ **Done when:** Frontier is empty. At least one concrete, measurable metric exists. Don't force numbers where they don't exist naturally.
170
499
 
171
- ### Open Questions — What don't we know yet?
500
+ ### Risks & Open Questions — What could go wrong, and what don't we know?
172
501
 
173
- > What to discover: Honest unknowns, risks, and assumptions that haven't been validated. A great project definition admits what it doesn't know.
502
+ > What to discover: Honest unknowns, concrete risks, and critically — how we'd respond to each risk. A risk without a mitigation is just worry.
174
503
 
175
- Key threads:
176
- - What's the biggest risk? What could make this fail?
177
- - What are you assuming that you haven't validated?
178
- - Is there a technical unknown that could change the approach?
179
- - What would you need to learn or prototype first?
504
+ **Prerequisites:** None (can explore anytime, but richer after other areas).
505
+
506
+ Frontier questions:
507
+
508
+ | Question | Depends on | Type |
509
+ |----------|-----------|------|
510
+ | What's the biggest risk? What could make this fail? | — | Decision |
511
+ | **How would you respond if that risk materializes?** | biggest-risk | Decision |
512
+ | What are you assuming that you haven't validated? | — | Decision |
513
+ | **What would you do if that assumption turns out wrong?** | assumptions | Decision |
514
+ | Is there a technical unknown that could change the approach? | — | Decision |
515
+ | What would you need to learn or prototype first? | risks, assumptions | Decision |
180
516
 
181
517
  Slots to fill:
182
- - `{{open_questions}}` — unanswered questions
183
- - `{{risks}}` — things that could go wrong
184
- - `{{assumptions}}` — beliefs that need validation
518
+ - `{{risks}}` — each with `{{mitigation}}`
519
+ - `{{assumptions}}` — each with `{{if_wrong}}` and `{{response}}`
520
+ - `{{open_questions}}`
185
521
 
186
- **When to move on:** The user has named at least the biggest unknown. This area is always optional — some projects are clear enough to skip it. But gently probe once.
522
+ **Done when:** Frontier is empty. The user has named at least the biggest unknown. This area is optional — some projects are clear enough to skip. But probe at least once.
187
523
 
188
524
  ### Principles — What philosophy guides this?
189
525
 
190
526
  > What to discover: The rules this project lives by. What's non-negotiable vs. flexible.
191
527
 
192
- Before asking, check for existing conventions in the project files:
528
+ **Prerequisites:** None (can explore anytime).
529
+
530
+ Before asking, **find facts** — scan existing conventions:
193
531
  ```bash
194
532
  cat .eslintrc* .prettierrc* tsconfig.json .editorconfig Makefile Dockerfile 2>/dev/null | head -80
195
533
  ls .github/workflows/ .gitlab-ci.yml 2>/dev/null
196
534
  ```
197
535
 
198
- Key threads:
199
- - Are there rules that must never be broken?
200
- - How much autonomy should AI agents have?
201
- - Speed vs quality, flexibility vs strictness — where does this project stand?
536
+ Present what you found as facts, then ask about decisions:
537
+
538
+ Frontier questions:
539
+
540
+ | Question | Depends on | Type |
541
+ |----------|-----------|------|
542
+ | Are there rules that must never be broken? | — | Decision |
543
+ | How much autonomy should AI agents have? | — | Decision |
544
+ | Speed vs quality, flexibility vs strictness — where does this project stand? | — | Decision |
202
545
 
203
546
  Accumulate as:
204
547
  ```
@@ -206,63 +549,88 @@ Accumulate as:
206
549
  [GUIDELINE] {{principle_name}} → {{concrete_rule}}
207
550
  ```
208
551
 
209
- **When to move on:** 2-7 principles feel right. This area is optional — don't force it.
552
+ **Done when:** Frontier is empty. 2-7 principles captured, or user decides none are needed.
210
553
 
211
554
  ---
212
555
 
213
556
  ## Checkpoints & State Tracking
214
557
 
215
- After exploring an area, summarize and read it back. Ask the user to confirm or correct.
558
+ After an area's frontier empties, summarize what was settled and read it back. Ask the user to confirm or correct. This is the checkpoint.
216
559
 
217
- Don't checkpoint after every question. Checkpoint when you've accumulated enough — typically after a natural cluster.
218
-
219
- **At each checkpoint, save progress to PROJECT.md** with `status: drafting`:
560
+ **At each checkpoint, save progress to `docs/PROJECT.md`** with `status: drafting` and enhanced state:
220
561
 
221
562
  ```yaml
222
563
  ---
223
564
  status: drafting
224
- areasExplored: [problem, vision]
225
- areasRemaining: [experience, principles]
565
+ areasExplored:
566
+ problem: { depth: 3, decisions: 4, open: 0 }
567
+ vision: { depth: 2, decisions: 3, open: 1 }
568
+ areasRemaining: [output, experience, success]
226
569
  lastCheckpoint: vision
570
+ assumptions:
571
+ - "Assuming CLI is the only distribution form — not yet validated"
572
+ - "Assuming target users are limited to Claude Code users"
227
573
  generatedBy: know-thy-build
228
574
  ---
229
575
  ```
230
576
 
231
- Write confirmed content into the document body as you go.
577
+ **State fields:**
578
+ - `depth` — how many rounds of follow-up "why" questions were asked in this area
579
+ - `decisions` — how many decisions the user made
580
+ - `open` — how many questions were deferred or left open
581
+ - `assumptions` — beliefs surfaced during exploration that haven't been validated. **Every area must surface at least one assumption or explicitly confirm there are none.**
582
+ - `pauseReason` — why the session stopped (only when `status: drafting`). E.g. "user needed stakeholder input on pricing model"
583
+ - `nextAction` — what the next session should do first. E.g. "Resume from Vision area — user promised to check with team lead about distribution model"
584
+ - `pendingInput` — questions the user couldn't answer that need external input. Each entry: who to ask, what to ask, and which area is blocked by it.
585
+
586
+ Write confirmed content into the document body as you go, including brief decision rationale (why this choice, what was considered and rejected).
232
587
 
233
588
  ---
234
589
 
235
590
  ## When to Generate
236
591
 
237
- Offer to generate when **enough areas are covered to write a meaningful document**. Not all slots need to be filled.
592
+ Offer to generate when **all required areas have empty frontiers**. Required areas: Problem, Vision, Output. Other areas are optional but encouraged.
593
+
594
+ Concrete checklist before offering:
595
+ - [ ] Problem frontier is empty — root cause articulated
596
+ - [ ] Persona frontier is empty — primary user is concrete, not abstract
597
+ - [ ] Competitive Landscape — at least default depth (2-3 competitors mapped, differentiation articulated)
598
+ - [ ] Vision frontier is empty — approach and deliverable defined
599
+ - [ ] Output frontier is empty — concrete artifacts listed
600
+ - [ ] `assumptions` in frontmatter is non-empty (at least the biggest unknowns surfaced)
601
+ - [ ] Every decision has a recommended answer that was accepted, modified, or rejected
238
602
 
239
- Signs the conversation is ready:
240
- - The user starts giving shorter, confirming answers
241
- - You can write a coherent PROJECT.md with what you have
242
- - The conversation has a natural closing energy
603
+ Optional areas (User Journey, Boundaries, Success, Risks & Open Questions, Principles) can be skipped if the user explicitly declines, but offer each at least once.
243
604
 
244
605
  ---
245
606
 
246
- ## Generate PROJECT.md
607
+ ## Generate docs/PROJECT.md
247
608
 
248
- Finalize the document. Update frontmatter:
609
+ Finalize the document. Write to `docs/PROJECT.md`. Create the `docs/` directory if it doesn't exist. Update frontmatter:
249
610
 
250
611
  ```yaml
251
612
  ---
252
613
  status: complete
253
- areasExplored: [problem, vision, output, experience, success, open-questions, principles] # only what was actually explored
614
+ areasExplored:
615
+ problem: { depth: N, decisions: N }
616
+ vision: { depth: N, decisions: N }
617
+ # ... only areas that were actually explored
618
+ assumptions:
619
+ - "{{assumption_1}}"
620
+ - "{{assumption_2}}"
254
621
  generatedBy: know-thy-build
255
622
  version: 1.0.0
256
623
  date: {{date}}
257
624
  ---
258
625
  ```
259
626
 
260
- Remove `areasRemaining` and `lastCheckpoint`.
627
+ Remove `areasRemaining`, `lastCheckpoint`, and `open` counts.
261
628
 
262
629
  **Rules:**
263
630
  - Only include content from the conversation. No generic filler.
264
631
  - Preserve the user's actual words as much as possible.
265
632
  - **Omit sections that were not discussed.** A shorter, honest document beats a padded one.
633
+ - **Include decision rationale.** For key decisions, briefly note what was considered and why the chosen path was picked. Use inline comments or a "Considered Alternatives" note — not a separate section. One sentence per decision is enough.
266
634
  - The entire document MUST be written in {{LANG}}.
267
635
 
268
636
  **Template structure** (write all prose in {{LANG}}):
@@ -275,9 +643,43 @@ Remove `areasRemaining` and `lastCheckpoint`.
275
643
  ## Problem
276
644
 
277
645
  <!-- Weave into natural prose:
278
- {{who_suffers}}, {{problem_root}}, {{problem_impact}},
646
+ {{problem_root}}, {{problem_impact}},
279
647
  {{current_alternative}}, {{why_not_enough}} -->
280
648
 
649
+ ## Personas
650
+
651
+ <!-- Primary user first. Secondary only if discussed. -->
652
+
653
+ | Persona | Role | Pain Point | Tech Level | Context |
654
+ |---------|------|------------|------------|---------|
655
+ | {{persona_name}} | {{persona_role}} | {{persona_pain}} | {{persona_tech_level}} | {{persona_context}} |
656
+
657
+ **Primary user values:** {{persona_priority}}
658
+
659
+ ## Competitive Landscape
660
+
661
+ <!-- What already exists and where it falls short. Default depth: name, approach, gap.
662
+ Deep research (step-by-step journey, friction points, user sentiment) can be added later. -->
663
+
664
+ | Competitor | Approach | Gap |
665
+ |------------|----------|-----|
666
+ | {{competitor_name}} | {{competitor_approach}} | {{competitor_gap}} |
667
+
668
+ <!-- Deep research per competitor (optional — include if explored):
669
+
670
+ ### {{competitor_name}} — Deep Dive
671
+
672
+ **User Journey (same task):**
673
+ 1. {{step_1}}
674
+ 2. {{step_2}} ← friction: {{friction_point}}
675
+ 3. {{step_3}}
676
+
677
+ **Users praise:** {{praise}}
678
+ **Users complain:** {{complaints}}
679
+ -->
680
+
681
+ **Our Differentiation:** {{differentiation}}
682
+
281
683
  ## Vision
282
684
 
283
685
  | Before | After |
@@ -307,10 +709,18 @@ Remove `areasRemaining` and `lastCheckpoint`.
307
709
 
308
710
  ## User Journey
309
711
 
310
- <!-- {{user_journey}} as natural prose -->
712
+ <!-- Per-persona journey from trigger to outcome. This is the high-level map;
713
+ concrete step-by-step scenarios live in individual feature specs. -->
311
714
 
312
- **Aha Moment:** {{aha_moment}}
313
- **Primary Action:** {{primary_action}}
715
+ | Stage | Description |
716
+ |-------|-------------|
717
+ | **Trigger** | {{trigger}} |
718
+ | **Discovery** | {{discovery}} |
719
+ | **First Use** | {{first_use}} |
720
+ | **Core Loop** | {{core_loop}} ({{frequency}}) |
721
+ | **Aha Moment** | {{aha_moment}} |
722
+ | **After** | {{after}} |
723
+ | **Return** | {{return_trigger}} |
314
724
 
315
725
  ## Principles
316
726
 
@@ -330,18 +740,46 @@ Remove `areasRemaining` and `lastCheckpoint`.
330
740
  **Metric:** {{success_metric}}
331
741
  **Leading Indicator:** {{leading_indicator}}
332
742
 
743
+ ## Risks & Mitigations
744
+
745
+ <!-- Each risk must have a mitigation. A risk without a response is just worry. -->
746
+
747
+ | Risk | Impact | Mitigation |
748
+ |------|--------|------------|
749
+ | {{risk}} | {{impact}} | {{mitigation}} |
750
+
333
751
  ## Open Questions
334
752
 
335
753
  <!-- Only include if discussed. Omit if the project is clear enough. -->
336
754
 
337
- **Risks:**
338
- - {{risk}}
755
+ - {{open_question}}
339
756
 
340
- **Assumptions:**
341
- - {{assumption}}
757
+ ## Assumptions
342
758
 
343
- **Unknowns:**
344
- - {{open_question}}
759
+ <!-- Always include. These are beliefs surfaced during exploration that haven't been validated.
760
+ Each assumption notes what would change if wrong AND how to respond. -->
761
+
762
+ - {{assumption}} — if wrong: {{impact}} → response: {{response}}
763
+
764
+ ## Key Decisions
765
+
766
+ <!-- Record the 3-5 most consequential decisions made during project definition.
767
+ Each entry: what was decided, what alternatives were considered, why this path. -->
768
+
769
+ | Decision | Alternatives Considered | Why This Path |
770
+ |----------|------------------------|---------------|
771
+ | {{decision}} | {{alternatives}} | {{rationale}} |
772
+
773
+ ## Feature Registry
774
+
775
+ <!-- Index of all features. Updated each time a new feature is defined via /know-thy-build:feature.
776
+ This section makes PROJECT.md the single entry point for the full project picture. -->
777
+
778
+ | # | Feature | Priority | Depends On | Status |
779
+ |---|---------|----------|------------|--------|
780
+ | {{id}} | [{{title}}](features/{{NNN}}.md) | {{P0/P1/P2}} | {{depends_on}} | {{status}} |
781
+
782
+ **Technical Foundation:** [TECHNICAL.md](TECHNICAL.md)
345
783
 
346
784
  ---
347
785
 
@@ -459,19 +897,82 @@ If `CLAUDE.md` exists → prepend reference (if not already present). If not →
459
897
  **Reference to add:**
460
898
  ```markdown
461
899
  ## Project Compass
462
- This project follows the principles defined in [PROJECT.md](./PROJECT.md).
463
- AI agents MUST read PROJECT.md before starting any work.
900
+ This project follows the principles defined in [PROJECT.md](./docs/PROJECT.md).
901
+ AI agents MUST read docs/PROJECT.md before starting any work.
464
902
  NON-NEGOTIABLE rules in PROJECT.md cannot be overridden.
903
+
904
+ ## Development Workflow
905
+
906
+ ### Orchestrator Model
907
+ The user session acts as **orchestrator only** — it does NOT implement directly.
908
+ All implementation is delegated to sub-agents with explicit scope and goals.
909
+
910
+ ### Implementation Flow
911
+
912
+ 1. **Orchestrator identifies work** from `docs/features/NNN.md`
913
+ - Determines scope: which files, which components, what changes
914
+ - Sets goal: specific acceptance criteria from the feature spec
915
+ - Dispatches implementation sub-agent
916
+
917
+ 2. **Implementation sub-agent — Pre-work (mandatory)**
918
+ Before writing any code, the sub-agent MUST read:
919
+ - `docs/PROJECT.md` — project principles and boundaries
920
+ - `docs/TECHNICAL.md` — technical decisions and patterns
921
+ - `docs/features/NNN.md` — feature spec, acceptance criteria, design intent
922
+ The sub-agent confirms its understanding of scope and goal before proceeding.
923
+
924
+ 3. **Implementation sub-agent — Execution**
925
+ Implements within the defined scope. Does not expand beyond the goal.
926
+
927
+ 4. **Post-implementation review (mandatory)**
928
+ After implementation, the sub-agent dispatches **three review agents**:
929
+
930
+ **Designer Review Agent:**
931
+ - Reads the feature's Design Intent Map (if present)
932
+ - Verifies every design intent step is correctly reflected in implementation
933
+ - Checks all UI states are handled (empty, loading, error, success)
934
+ - Adopts the most critical stance — assumes implementation is wrong until proven otherwise
935
+ - Produces checklist: `- [x]` passed or `- [ ]` failed with specific reason
936
+
937
+ **Architect Review Agent:**
938
+ - Reads `docs/TECHNICAL.md` and the feature spec
939
+ - Verifies code follows technical decisions, patterns, and constraints
940
+ - Checks code structure, naming, boundaries, and error handling
941
+ - Adopts the most critical stance — looks for what will break, not what looks nice
942
+ - Produces checklist: `- [x]` passed or `- [ ]` failed with specific reason
943
+
944
+ 5. **Designer + Architect must both pass before QA begins.**
945
+
946
+ 6. **QA Review Agent (mandatory — runs the product)**
947
+ - Actually starts the application and tests it as a real user
948
+ - Executes every acceptance criterion from the feature spec step by step
949
+ - Tests edge cases: interruption (refresh, back, cancel), concurrency (multi-tab), boundary (empty, max, special chars), state corruption (expired session, deleted resource)
950
+ - Captures evidence for every test: screenshots, console output, state checks
951
+ - Adopts the most paranoid, impatient, careless user persona
952
+ - Produces checklist: `- [x]` passed with evidence or `- [ ]` failed with reproduction steps
953
+
954
+ 7. **Review loop**
955
+ - If ANY criterion is `[ ]` (failed): implementer fixes and re-submits
956
+ - Designer + Architect re-review if changes are structural
957
+ - QA re-tests failed scenarios + regression check on happy path
958
+ - Loop continues until ALL reviewers' criteria are `[x]`
959
+ - Only when all three reviewers fully pass does the orchestrator accept the work
960
+
961
+ ### Document References
962
+ - Project definition: `docs/PROJECT.md`
963
+ - Technical foundation: `docs/TECHNICAL.md`
964
+ - Feature specs: `docs/features/NNN.md`
965
+ - Feature registry: `docs/PROJECT.md` → Feature Registry section
465
966
  ```
466
967
 
467
968
  ## Closing
468
969
 
469
970
  **After CREATE:**
470
- - PROJECT.md has been generated.
971
+ - `docs/PROJECT.md` has been generated.
471
972
  - This document is the compass for all agents working on this project.
472
973
  - Run `/know-thy-build:project` again when the project's direction shifts.
473
974
 
474
975
  **After EVOLVE:**
475
- - PROJECT.md has been updated.
976
+ - `docs/PROJECT.md` has been updated.
476
977
  - The changelog records not just what changed, but why.
477
978
  - Run `/know-thy-build:project` again whenever the direction shifts.