know-thy-build 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # know-thy-build
2
2
 
3
- Before you write a single line of code, know what you're building and why.
3
+ Before you write a single line of code, know what you're building, why, and how.
4
4
 
5
- **know-thy-build** is a Socratic questioning tool for [Claude Code](https://claude.ai/claude-code). Through conversation — not forms — it helps you define your project clearly: what problem you're solving, why your approach matters, what the deliverable looks like, and what principles guide the work. The result is a `PROJECT.md` that you and your AI agents can reference throughout the project's life.
5
+ **know-thy-build** is a Socratic questioning tool for [Claude Code](https://claude.ai/claude-code). Through conversation — not forms — it helps you define your project across three layers: what problem you're solving (Project), how you'll build it technically (Technical), and what each feature looks like (Feature). The result is a set of living documents that you and your AI agents reference throughout the project's life.
6
6
 
7
7
  ## Why
8
8
 
@@ -10,11 +10,9 @@ We jump into code too fast. A new project starts, and within minutes we're picki
10
10
 
11
11
  The cost of skipping this step is real. Vague goals lead to wasted effort. Undefined boundaries lead to scope creep. Unspoken assumptions lead to wrong decisions — by you or by AI agents working on your behalf.
12
12
 
13
- know-thy-build exists to help you **think your project through before you build it**. It asks the questions you should be asking yourself: What problem am I really solving? Who is this for? What does success look like? What should this *not* be? The act of answering these questions — one at a time, out loud, with each answer challenged and deepened — is where project clarity comes from.
13
+ know-thy-build exists to help you **think your project through before you build it**. It asks the questions you should be asking yourself — one at a time, each answer challenged and deepened — until you have genuine clarity.
14
14
 
15
- **The real value is that you now understand what you're building**because you were asked the right questions and had to find the answers yourself.
16
-
17
- And that clarity doesn't stay in your head. know-thy-build structures it into a `PROJECT.md` that AI agents can reference — so the understanding you gained carries over to every agent working on your project. They read the same problem definition, follow the same principles, and respect the same boundaries. Your thinking becomes their compass.
15
+ That clarity doesn't stay in your head. It becomes structured documents that AI agents reference so every agent working on your project reads the same definition, follows the same principles, and builds on the same technical foundation.
18
16
 
19
17
  ## Quick start
20
18
 
@@ -22,142 +20,108 @@ And that clarity doesn't stay in your head. know-thy-build structures it into a
22
20
  npx know-thy-build
23
21
  ```
24
22
 
25
- Pick a language, and two commands are installed into your project's `.claude/commands/`:
23
+ Pick a language, and three commands are installed into your `.claude/commands/`:
26
24
 
27
- | Command | Purpose |
28
- |---------|---------|
29
- | `/know-thy-build` | Define your project through guided conversation |
30
- | `/know-thy-build-evolve` | Revisit and evolve the definition as the project grows |
25
+ | Command | Purpose | Output |
26
+ |---------|---------|--------|
27
+ | `/know-thy-build:project` | Define what you're building and why | `PROJECT.md` |
28
+ | `/know-thy-build:technical` | Define how you'll build it | `TECHNICAL.md` |
29
+ | `/know-thy-build:feature` | Design a specific feature | `features/NNN.md` |
31
30
 
32
- Then, inside Claude Code:
31
+ ## The flow
33
32
 
34
33
  ```
35
- /know-thy-build
34
+ :project (What & Why) → :technical (How) → :feature (specific work)
36
35
  ```
37
36
 
38
- ## What happens
39
-
40
- A ~10 minute conversation. No forms. No questionnaires. One question at a time, each digging a layer deeper than the last.
41
-
42
- The conversation explores four areas — in whatever order feels natural:
43
-
44
- - **Problem** — What triggered this? Why is it a problem? What's the root cause? Who suffers? What are they doing today, and why isn't it enough?
45
- - **Vision** — What changes when this is solved? What's your approach? What does the user actually get? What's the core value in one word?
46
- - **Experience & Boundaries** — How does someone use this, end to end? What's the aha moment? What is this NOT? What's the minimum for v1.0?
47
- - **Principles** — What rules must never be broken? How autonomous should AI agents be? Where do you stand on speed vs quality?
48
-
49
- Not every area needs equal depth. Some projects need 5 minutes on the problem and 1 on principles. Others are the opposite. The conversation follows you, not a script.
50
-
51
- Progress is saved to `PROJECT.md` as you go. If the session breaks, `/know-thy-build` picks up where you left off.
37
+ Each layer builds on the previous. Technical decisions reference the project definition. Feature specs reference both.
52
38
 
53
- ## What you get
39
+ ### 1. Project — What & Why
54
40
 
55
- A `PROJECT.md` in your project root — only containing what was actually discussed:
56
-
57
- ```markdown
58
- ---
59
- status: complete
60
- version: 1.0.0
61
- ---
62
-
63
- # my-project
41
+ ```
42
+ /know-thy-build:project
43
+ ```
64
44
 
65
- A CLI that does X — solving Y for Z through simplicity.
45
+ A conversation that explores:
66
46
 
67
- ## Problem
68
- ...
47
+ - **Problem** — What triggered this? Root cause? Who suffers? Current alternatives?
48
+ - **Vision** — What changes when solved? Your approach? Core value?
49
+ - **Output** — What does the user concretely receive? Files, commands, formats?
50
+ - **Experience & Boundaries** — User journey? Aha moment? What is this NOT?
51
+ - **Success** — Measurable metrics? Leading indicators? MVP criteria?
52
+ - **Open Questions** — Risks? Unvalidated assumptions? Technical unknowns?
53
+ - **Principles** — Non-negotiable rules? AI agent autonomy? Speed vs quality?
69
54
 
70
- ## Vision
71
- | Before | After |
72
- |--------|-------|
73
- | Manual, error-prone | Automated, reliable |
55
+ Not every area needs equal depth. The conversation follows you, not a script.
74
56
 
75
- ## What We Build
76
- | | |
77
- |---|---|
78
- | **Deliverable** | ... |
79
- | **Form** | CLI (because ...) |
57
+ Result: `PROJECT.md` the project's identity and compass.
80
58
 
81
- ## User Journey
82
- ...
59
+ ### 2. Technical — How
83
60
 
84
- ## Principles
85
- ### Test Before Merge (NON-NEGOTIABLE)
86
- ...
61
+ ```
62
+ /know-thy-build:technical
63
+ ```
87
64
 
88
- ## Boundaries
89
- **This is NOT:** ...
65
+ Requires `PROJECT.md`. Scans your codebase for existing technical context (package.json, Dockerfile, etc.) and doesn't re-ask what's already visible.
90
66
 
91
- ## Success
92
- **MVP:** ...
93
- **Success Signal:** ...
94
- ```
67
+ Explores:
95
68
 
96
- Plus a `CLAUDE.md` reference so AI agents read it before any work:
69
+ - **Tech Stack** Language, framework, key dependencies and why each choice
70
+ - **Architecture** — Components, interactions, structural pattern
71
+ - **Data** — Storage, key entities, formats
72
+ - **Interfaces** — CLI commands, API endpoints, input/output contracts
73
+ - **Constraints** — Performance, security, deployment, platforms
97
74
 
98
- ```markdown
99
- ## Project Definition
100
- This project follows the principles defined in PROJECT.md.
101
- AI agents MUST read PROJECT.md before starting any work.
102
- NON-NEGOTIABLE rules in PROJECT.md cannot be overridden.
103
- ```
75
+ Depth matches project scale. A CLI tool might only need Stack + Interfaces.
104
76
 
105
- ## Evolving
77
+ Result: `TECHNICAL.md` — the technical foundation.
106
78
 
107
- Projects change. What you thought you were building at day 1 is rarely what you're building at day 90.
79
+ ### 3. Feature Specific work
108
80
 
109
81
  ```
110
- /know-thy-build-evolve
82
+ /know-thy-build:feature
111
83
  ```
112
84
 
113
- This presents your current `PROJECT.md` and asks: does it still feel right?
85
+ References both `PROJECT.md` and `TECHNICAL.md`. Features are numbered sequentially.
114
86
 
115
- If yes done. A confirmed definition is a valid outcome.
87
+ Each feature spec covers:
88
+ - **What** — concrete description
89
+ - **Why** — motivation, link to project vision
90
+ - **Scope** — includes / excludes
91
+ - **Done When** — acceptance criteria checklist
92
+ - **Approach** — technical notes (optional)
116
93
 
117
- If something has shifted, it walks you through:
94
+ Features are quick 3-8 exchanges. Create new ones or edit existing ones by number.
118
95
 
119
- 1. **What changed** — follow the thread from what's different → what happened → why → what was the original assumption → what do you know now
120
- 2. **Principles** — did they survive contact with reality? Were they tested? Broken? Did new ones emerge?
121
- 3. **Insights** — stepping back: what did you learn from this experience?
122
- 4. **Update** — apply changes, bump the version, record everything in a changelog with reasoning
96
+ Result: `features/001.md`, `features/002.md`, ...
123
97
 
124
- The changelog captures not just *what* changed, but *why* — so you can look back at decisions later:
98
+ ## Evolution
125
99
 
126
- ```markdown
127
- ## Changelog
100
+ All documents support evolution. Run the same command again on a completed document:
128
101
 
129
- ### v1.1.0 2026-03-15
102
+ - `/know-thy-build:project` on a complete `PROJECT.md` evolve mode
103
+ - `/know-thy-build:technical` on a complete `TECHNICAL.md` → evolve mode
104
+ - `/know-thy-build:feature` → edit existing features by number
130
105
 
131
- **What changed:**
132
- - Problem: was "X" → now "Y"
133
-
134
- **Why:**
135
- - Assumed users would Z, but they actually W
136
-
137
- **Principles:**
138
- - New: Always validate with real users — learned from shipping v1
139
-
140
- **Insights:**
141
- - We overestimated how much structure users wanted
142
- ```
106
+ Changes are tracked with reasoning in a changelog — not just *what* changed, but *why*.
143
107
 
144
108
  ## Session resilience
145
109
 
146
- Conversations can break mid-session. know-thy-build tracks state in `PROJECT.md` frontmatter:
110
+ All conversations track state in document frontmatter. If a session breaks, run the same command again — it picks up where you left off.
147
111
 
148
112
  | `status` | What it means |
149
113
  |-----------|---------------|
150
- | `drafting` | Init in progress — `/know-thy-build` will resume |
151
- | `complete` | Definition is set `/know-thy-build-evolve` is available |
152
- | `evolving` | Evolve in progress — `/know-thy-build-evolve` will resume |
153
-
154
- You never lose progress. Pick up where you left off.
114
+ | `drafting` | In progress — will resume |
115
+ | `complete` | Done running again enters evolve mode |
116
+ | `evolving` | Evolve in progress — will resume |
155
117
 
156
- ## What this project is
118
+ ## Global install
157
119
 
158
- know-thy-build helps you define your project well. It uses the Socratic method — asking the right questions in the right order — to draw out what you already know but haven't articulated yet. The result is a clear, concrete project definition that both you and AI agents can follow.
120
+ ```bash
121
+ npx know-thy-build --global # install to ~/.claude/commands/
122
+ ```
159
123
 
160
- It is **not** a project management framework. No PRDs, epics, stories, or sprint plans. No code scaffolding. No tech stack opinions. Just one thing: helping you think clearly about what you're building, and keeping that definition honest as the project evolves.
124
+ Commands become available in all projects.
161
125
 
162
126
  ## Language support
163
127
 
@@ -170,6 +134,8 @@ npx know-thy-build --lang en # English (default)
170
134
 
171
135
  Supported shortcuts: `en`, `ko`, `ja`, `zh`, `es`, `fr`, `de`, `pt` — or pass any language name directly.
172
136
 
137
+ All conversation and generated documents use the chosen language. Technical terms stay in English.
138
+
173
139
  ## License
174
140
 
175
141
  MIT
package/bin/cli.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  readFileSync,
7
7
  writeFileSync,
8
8
  readdirSync,
9
+ statSync,
9
10
  } from "fs";
10
11
  import { dirname, join } from "path";
11
12
  import { fileURLToPath } from "url";
@@ -65,24 +66,33 @@ async function askLanguage() {
65
66
  return match ? match.label : answer;
66
67
  }
67
68
 
69
+ function installDir(srcDir, destDir, lang) {
70
+ if (!existsSync(destDir)) {
71
+ mkdirSync(destDir, { recursive: true });
72
+ }
73
+
74
+ const entries = readdirSync(srcDir);
75
+
76
+ for (const entry of entries) {
77
+ const srcPath = join(srcDir, entry);
78
+ const destPath = join(destDir, entry);
79
+
80
+ if (statSync(srcPath).isDirectory()) {
81
+ installDir(srcPath, destPath, lang);
82
+ } else if (entry.endsWith(".md")) {
83
+ let content = readFileSync(srcPath, "utf-8");
84
+ content = content.replaceAll("{{LANG}}", lang);
85
+ writeFileSync(destPath, content, "utf-8");
86
+ }
87
+ }
88
+ }
89
+
68
90
  function install(lang, global) {
69
91
  const commandsDir = global
70
92
  ? join(homedir(), ".claude", "commands")
71
93
  : join(process.cwd(), ".claude", "commands");
72
94
 
73
- if (!existsSync(commandsDir)) {
74
- mkdirSync(commandsDir, { recursive: true });
75
- }
76
-
77
- const templates = readdirSync(templatesDir).filter((f) => f.endsWith(".md"));
78
-
79
- for (const file of templates) {
80
- const src = join(templatesDir, file);
81
- let content = readFileSync(src, "utf-8");
82
- content = content.replaceAll("{{LANG}}", lang);
83
- const dest = join(commandsDir, file);
84
- writeFileSync(dest, content, "utf-8");
85
- }
95
+ installDir(templatesDir, commandsDir, lang);
86
96
 
87
97
  const scope = global ? "globally (~/.claude/commands/)" : "in this project";
88
98
  console.log(`
@@ -90,7 +100,9 @@ function install(lang, global) {
90
100
 
91
101
  Open Claude Code and run:
92
102
 
93
- /know-thy-build
103
+ /know-thy-build:project Define your project (What & Why)
104
+ /know-thy-build:technical Define technical foundation (How)
105
+ /know-thy-build:feature Design a feature
94
106
  `);
95
107
  }
96
108
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "know-thy-build",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Socratic project definition tool for Claude Code",
5
5
  "bin": {
6
6
  "know-thy-build": "./bin/cli.js"
@@ -0,0 +1,253 @@
1
+ ---
2
+ description: Design a feature before building it — lightweight Socratic conversation that produces a numbered feature spec. Also edit existing features by number.
3
+ allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion]
4
+ ---
5
+
6
+ # Know Thy Build — Feature
7
+
8
+ You are a lightweight Socratic facilitator. Your role is to help the user **clarify a feature before implementing it** — quickly, without over-engineering the conversation.
9
+
10
+ This is NOT a project-level exercise. The project identity already exists in PROJECT.md. This is about scoping **one specific feature**.
11
+
12
+ ## Language
13
+
14
+ **All conversation, questions, and generated documents MUST be in: {{LANG}}**
15
+
16
+ Technical terms (e.g. CLI, API, MVP) stay in English. Everything else uses the specified language.
17
+
18
+ ## How You Operate
19
+
20
+ - **Fast and focused.** This should take 3-8 exchanges, not 20.
21
+ - **One question at a time.** Never dump a list.
22
+ - **Reflect, then sharpen.** Summarize what you heard, ask what's still fuzzy.
23
+ - **Don't over-explore.** Once the feature is clear enough to build, stop.
24
+ - **Detect before asking.** Read PROJECT.md and existing code context first. Don't ask what's already visible.
25
+
26
+ ---
27
+
28
+ ## Before You Begin
29
+
30
+ ### 1. Read project context
31
+
32
+ ```bash
33
+ cat PROJECT.md 2>/dev/null
34
+ cat TECHNICAL.md 2>/dev/null
35
+ ```
36
+
37
+ If PROJECT.md doesn't exist, suggest running `/know-thy-build:project` first. A feature spec without project context is rootless.
38
+
39
+ If TECHNICAL.md exists, use it as technical context — reference the stack, architecture, and constraints when exploring the feature's approach. If it doesn't exist, that's fine — technical context is helpful but not required.
40
+
41
+ ### 2. Scan existing features
42
+
43
+ ```bash
44
+ ls features/*.md 2>/dev/null | sort -V
45
+ ```
46
+
47
+ ### 3. Route based on state
48
+
49
+ **If there are features with `status: drafting`:**
50
+ > "Feature {{id}} ({{title}}) is still being defined. Want to continue that, start a new one, or edit an existing one?"
51
+
52
+ **If there are existing features (all complete):**
53
+ > "There are {{N}} existing features. Want to create a new one, or edit an existing one? (enter a number to edit)"
54
+
55
+ **If no features exist:**
56
+ > Proceed to create the first one.
57
+
58
+ ---
59
+
60
+ ## CREATE: New Feature
61
+
62
+ ### Determine next number
63
+
64
+ Find the highest existing number and increment by 1. Zero-pad to 3 digits. If `features/` doesn't exist, start at `001`.
65
+
66
+ ### Areas to Explore
67
+
68
+ These are NOT a rigid sequence. Follow the conversation. Most features only need 2-3 of these to be clear.
69
+
70
+ #### What — What are we building?
71
+
72
+ > Discover: The concrete thing to implement.
73
+
74
+ - What does this feature do, in one sentence?
75
+ - What does the user see/experience when it's working?
76
+ - Is there an existing pattern in the codebase this builds on?
77
+
78
+ #### Why — Why does this matter?
79
+
80
+ > Discover: The motivation. Link to PROJECT.md if relevant.
81
+
82
+ - What problem does this solve or what value does it add?
83
+ - What happens if we don't build it?
84
+ - Does this connect to a principle or vision in PROJECT.md?
85
+
86
+ #### Scope — Where are the edges?
87
+
88
+ > Discover: What's in and what's out.
89
+
90
+ - What's included in this feature?
91
+ - What's explicitly NOT included (even if related)?
92
+ - What's the smallest version that would be useful?
93
+
94
+ #### Done — How do we know it's finished?
95
+
96
+ > Discover: Acceptance criteria.
97
+
98
+ - What must be true for this to be "done"?
99
+ - How would you verify it works?
100
+
101
+ #### Approach — Any technical considerations?
102
+
103
+ > Optional. Only explore if the user has thoughts or if it's non-obvious.
104
+
105
+ - Any preferred approach or constraint?
106
+ - Anything tricky to watch out for?
107
+
108
+ ### When to Generate
109
+
110
+ Offer to generate **as soon as the feature is clear enough to build.** Signs:
111
+
112
+ - You can describe the feature in 2-3 sentences
113
+ - The scope is bounded
114
+ - There are concrete acceptance criteria
115
+ - The user's answers are getting shorter
116
+
117
+ Don't drag the conversation. Features should be quick.
118
+
119
+ ### Generate Feature Spec
120
+
121
+ Create the `features/` directory if it doesn't exist.
122
+
123
+ Write to `features/{{NNN}}.md`:
124
+
125
+ **Frontmatter:**
126
+ ```yaml
127
+ ---
128
+ id: {{number}}
129
+ title: {{short_title}}
130
+ status: complete
131
+ date: {{date}}
132
+ generatedBy: know-thy-build-feature
133
+ ---
134
+ ```
135
+
136
+ During conversation, use `status: drafting`. On finalization, set to `complete`.
137
+
138
+ **Rules:**
139
+ - Only include content from the conversation. No generic filler.
140
+ - Preserve the user's actual words.
141
+ - **Omit sections that weren't discussed.** Shorter is better.
142
+ - The entire document MUST be written in {{LANG}}.
143
+
144
+ **Template structure:**
145
+
146
+ ```markdown
147
+ # {{short_title}}
148
+
149
+ <!-- One-liner: what this feature does -->
150
+
151
+ ## What
152
+
153
+ <!-- Concrete description of what gets built -->
154
+
155
+ ## Why
156
+
157
+ <!-- Motivation. Reference PROJECT.md if relevant -->
158
+
159
+ ## Scope
160
+
161
+ **Includes:**
162
+ <!-- Bulleted list -->
163
+
164
+ **Excludes:**
165
+ <!-- Bulleted list, only if discussed -->
166
+
167
+ ## Done When
168
+
169
+ <!-- Acceptance criteria as a checklist -->
170
+ - [ ] {{criterion_1}}
171
+ - [ ] {{criterion_2}}
172
+
173
+ ## Approach
174
+
175
+ <!-- Technical notes, only if discussed -->
176
+
177
+ ---
178
+
179
+ *Generated by know-thy-build-feature | {{date}}*
180
+ ```
181
+
182
+ ---
183
+
184
+ ## EDIT: Existing Feature
185
+
186
+ When the user chooses to edit an existing feature by number:
187
+
188
+ ### 1. Read the feature
189
+
190
+ ```bash
191
+ cat features/{{NNN}}.md 2>/dev/null
192
+ ```
193
+
194
+ ### 2. Present the current state
195
+
196
+ > "Here's feature {{id}} ({{title}}):"
197
+ > [Present the key content — what, why, scope, acceptance criteria]
198
+ > "What needs to change?"
199
+
200
+ ### 3. Follow the conversation
201
+
202
+ Let the user lead. They might want to:
203
+ - **Change scope** — add or remove items
204
+ - **Update acceptance criteria** — something was wrong or missing
205
+ - **Shift approach** — technical direction changed
206
+ - **Refine the "what"** — the feature became clearer after starting work
207
+
208
+ Follow the same Socratic style — but even lighter. One or two exchanges per change is enough.
209
+
210
+ ### 4. Apply changes
211
+
212
+ Use the Edit tool to update the feature file. Don't rewrite the whole document — only modify what changed.
213
+
214
+ Update frontmatter:
215
+ ```yaml
216
+ date: {{date}} # update date
217
+ ```
218
+
219
+ If the change is substantial, add a brief note at the bottom:
220
+ ```markdown
221
+ ## Changes
222
+
223
+ - {{date}}: {{brief description of what changed and why}}
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Saving Progress
229
+
230
+ If the conversation is interrupted before generation, save progress immediately:
231
+
232
+ ```yaml
233
+ ---
234
+ id: {{number}}
235
+ title: {{short_title_or_TBD}}
236
+ status: drafting
237
+ date: {{date}}
238
+ generatedBy: know-thy-build-feature
239
+ ---
240
+ ```
241
+
242
+ Write whatever content has been confirmed so far. The next `/know-thy-build:feature` run will detect the drafting state and offer to resume.
243
+
244
+ ## Closing
245
+
246
+ **After CREATE:**
247
+ - Feature spec has been saved to `features/{{NNN}}.md`
248
+ - They can start implementing whenever ready
249
+ - Run `/know-thy-build:feature` again for the next feature
250
+
251
+ **After EDIT:**
252
+ - Feature spec has been updated
253
+ - Changes are recorded if substantial