km-spec-driven-development 0.1.0 → 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.
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "km-spec-driven-development",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A lightweight Spec Driven Development CLI for AI-assisted software projects",
5
5
  "bin": {
6
6
  "km-spec": "bin/km-spec"
7
7
  },
8
+ "scripts": {
9
+ "test": "bash tests/run.sh"
10
+ },
8
11
  "files": [
9
12
  "bin",
10
13
  "templates",
@@ -1,42 +1,77 @@
1
1
  # Agent Instructions
2
2
 
3
- This project uses Spec Driven Development.
3
+ This project uses Spec Driven Development (SDD).
4
4
 
5
- ## Always Read First
5
+ - Full methodology: `SDD.md`
6
+ - Execution lifecycle: `HARNESS.md` (read every session)
6
7
 
7
- Before changing code, always read:
8
+ ## Mandatory Reading Order
9
+
10
+ Before changing code, always read in this order:
8
11
 
9
12
  1. `.specs/project/STATE.md`
10
13
  2. `.specs/project/PROJECT.md`
11
14
  3. `.specs/codebase/CONVENTIONS.md`
15
+ 4. `HARNESS.md`
16
+ 5. Current feature or quick-task files (only the active work item)
17
+
18
+ ### Feature work
19
+
20
+ Also read:
21
+
22
+ - `.specs/features/<feature>/spec.md`
23
+ - `.specs/features/<feature>/context.md`
24
+ - `.specs/features/<feature>/plan.md`
25
+ - `.specs/features/<feature>/tasks.md`
26
+ - `.specs/features/<feature>/validation.md`
27
+
28
+ Legacy features may lack `context.md` or `plan.md`. If missing, create them from current templates before large implementation work, or treat gaps as `[NEEDS CLARIFICATION]`.
29
+
30
+ ### Quick-task work
12
31
 
13
- For feature work, also read:
32
+ Also read:
14
33
 
15
- - `.specs/features/[feature]/spec.md`
16
- - `.specs/features/[feature]/tasks.md`
17
- - `.specs/features/[feature]/validation.md`
34
+ - `.specs/quick/<task>/TASK.md`
35
+ - `.specs/quick/<task>/SUMMARY.md` (when closing out)
18
36
 
19
- ## Rules
37
+ Legacy single-file quick tasks may live at `.specs/quick/<task>.md`. Prefer the directory layout for new work.
20
38
 
21
- - Do not invent files, APIs, functions, or behavior.
22
- - Read existing code before modifying it.
23
- - Implement only the current task scope.
24
- - Keep changes small and reviewable.
25
- - Do not refactor unrelated code.
26
- - Follow `.specs/codebase/CONVENTIONS.md`.
27
- - Update task status after implementation.
28
- - Run validation before marking work as done.
29
- - Record validation evidence.
30
- - Update `.specs/project/STATE.md` at the end of the session.
39
+ ## Permanent Rules
40
+
41
+ 1. **Never invent** requirements, APIs, files, functions, or project conventions.
42
+ 2. **Never treat `[INFERRED]` as `[CONFIRMED]`** without evidence or explicit approval.
43
+ 3. **Read existing code** before modifying it. Prefer repository truth over chat memory.
44
+ 4. **One task at a time.** Prefer a single `IN PROGRESS` task per agent/session.
45
+ 5. **Implement only the current task scope.** No unrelated refactors or drive-by cleanups.
46
+ 6. **Follow** `.specs/codebase/CONVENTIONS.md` for structure, style, and validation commands.
47
+ 7. **Record evidence** in `validation.md` (features) or `SUMMARY.md` (quick tasks) before marking work complete.
48
+ 8. **Do not mark DONE** if required validation failed or was not executed.
49
+ 9. **Stop and record a blocker** in `STATE.md` when required information is missing.
50
+ 10. **If PROJECT.md or CONVENTIONS.md are still placeholders**, inspect the real repository (and ask the user) before assuming stack, commands, or layout.
51
+ 11. **Update** `.specs/project/STATE.md` at the end of every session where work occurred.
52
+ 12. **Update task status** as you go (`TODO` → `IN PROGRESS` → `DONE` | `BLOCKED`).
53
+
54
+ ## Confidence Markers
55
+
56
+ | Marker | Meaning |
57
+ |--------|---------|
58
+ | `[CONFIRMED]` | Explicitly known; safe to implement against |
59
+ | `[INFERRED]` | Suggestion only; not a requirement |
60
+ | `[NEEDS CLARIFICATION]` | Unresolved; do not invent an answer silently |
61
+ | `[DECISION REQUIRED]` | Needs an explicit decision (record DEC-XXX) |
31
62
 
32
63
  ## Done Means
33
64
 
34
- A task is only complete when:
65
+ A task is complete only when:
66
+
67
+ - Scope matches the task and linked requirements/acceptance criteria
68
+ - Applicable build, lint, typecheck, and tests have been run (or honestly marked N/A with reason)
69
+ - Acceptance criteria are verified
70
+ - Validation evidence is recorded
71
+ - Task status and `STATE.md` are updated
72
+
73
+ ## Out of Scope for Agents
35
74
 
36
- - Build passes.
37
- - Lint passes, if available.
38
- - Typecheck passes, if available.
39
- - Tests pass, if available.
40
- - Acceptance criteria are verified.
41
- - Validation result is recorded.
42
- - Project state is updated.
75
+ - Do not expand ceremony beyond the work tier without cause
76
+ - Do not load every feature spec at once
77
+ - Do not skip `HARNESS.md` lifecycle steps for “small” code changes that still need validation
@@ -0,0 +1,135 @@
1
+ # AI Development Harness
2
+
3
+ Operational lifecycle for agents working in this repository.
4
+ Methodology detail lives in `SDD.md`. Permanent rules live in `AGENTS.md`.
5
+
6
+ **Template:** harness@1.0
7
+
8
+ ---
9
+
10
+ ## Task States
11
+
12
+ | State | Meaning |
13
+ |-------|---------|
14
+ | `TODO` | Not started |
15
+ | `IN PROGRESS` | Active work (prefer one task per agent/session) |
16
+ | `DONE` | Completion criteria met **and** required validation evidence recorded |
17
+ | `BLOCKED` | Cannot proceed; reason recorded |
18
+
19
+ A task must **not** be marked `DONE` if required validation failed or was not executed.
20
+
21
+ ---
22
+
23
+ ## Lifecycle
24
+
25
+ ```text
26
+ Discover → Read → Plan → Implement → Validate → Review → Report
27
+ ```
28
+
29
+ ### 1. Discover
30
+
31
+ | | |
32
+ |--|--|
33
+ | **Inputs** | User request; `.specs/project/STATE.md`; roadmap only if planning |
34
+ | **Responsibilities** | Identify current feature or quick task and the next `TODO` / assigned task id |
35
+ | **Outputs** | Target path (feature slug or quick slug) and task id |
36
+ | **Stop** | No clear task → update STATE with question; do not invent scope |
37
+
38
+ ### 2. Read
39
+
40
+ | | |
41
+ |--|--|
42
+ | **Inputs** | `STATE.md`, `PROJECT.md`, `CONVENTIONS.md`, this file, current work files |
43
+ | **Feature files** | `spec.md`, `context.md`, `plan.md`, `tasks.md`, `validation.md` |
44
+ | **Quick files** | `TASK.md` (and `SUMMARY.md` when closing) |
45
+ | **Responsibilities** | Re-read real source files before changing them; treat `[INFERRED]` as non-binding |
46
+ | **Outputs** | Verified understanding of scope and constraints |
47
+ | **Stop** | Missing critical info → ask or set `BLOCKED`; do not invent REQs/APIs/paths |
48
+
49
+ ### 3. Plan
50
+
51
+ | | |
52
+ |--|--|
53
+ | **Inputs** | Current task entry; linked REQs; plan/context |
54
+ | **Responsibilities** | List atomic steps (file + action). If >5 steps or complex deps → add/update tasks first |
55
+ | **Outputs** | Step list or updated `tasks.md` |
56
+ | **Stop** | Spec/plan not ready for implementation work → finish planning tasks first |
57
+
58
+ ### 4. Implement
59
+
60
+ | | |
61
+ |--|--|
62
+ | **Inputs** | Task scope; CONVENTIONS; existing code patterns |
63
+ | **Responsibilities** | Change only task scope; no unrelated refactors; follow project structure rules |
64
+ | **Outputs** | Code/docs diffs limited to expected files |
65
+ | **Stop** | Reality contradicts plan/spec → record deviation; do not silent-workaround |
66
+
67
+ ### 5. Validate
68
+
69
+ | | |
70
+ |--|--|
71
+ | **Inputs** | Commands from `CONVENTIONS.md` → Testing; task validation section |
72
+ | **Responsibilities** | Run applicable gates; record real results |
73
+ | **Outputs** | Evidence in task notes and feature `validation.md` or quick `SUMMARY.md` |
74
+ | **Stop** | Gate failure → fix or `BLOCKED`; never mark DONE |
75
+
76
+ ### 6. Review
77
+
78
+ | | |
79
+ |--|--|
80
+ | **Inputs** | Diff; acceptance criteria; confidence markers |
81
+ | **Responsibilities** | Confirm AC met; no scope creep; markers still honest |
82
+ | **Outputs** | Pass/fail judgment; deviation notes |
83
+ | **Stop** | AC unmet → continue implement/validate loop |
84
+
85
+ ### 7. Report
86
+
87
+ | | |
88
+ |--|--|
89
+ | **Inputs** | Outcomes of this session |
90
+ | **Responsibilities** | Update task status, validation ledger, `STATE.md` |
91
+ | **Outputs** | Handoff report (below); clear next task |
92
+ | **Stop** | Never end a session without STATE update when work occurred |
93
+
94
+ ---
95
+
96
+ ## Handoff Report Format
97
+
98
+ ```markdown
99
+ ## Handoff Report
100
+
101
+ **Task:** TASK-XXX | quick: <slug>
102
+ **Status:** DONE | PARTIAL | BLOCKED
103
+
104
+ ### Files Changed
105
+ - `path` — summary
106
+
107
+ ### Commands Executed
108
+ - `command` → result
109
+
110
+ ### Results
111
+ - Build/Lint/Typecheck/Tests/AC: PASS | FAIL | SKIPPED (reason)
112
+
113
+ ### Decisions
114
+ - DEC-XXX: …
115
+
116
+ ### Deviations
117
+ - …
118
+
119
+ ### Blockers
120
+ - …
121
+
122
+ ### Next Recommended Task
123
+ - TASK-XXX — …
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Confidence Markers
129
+
130
+ | Marker | Treat as |
131
+ |--------|----------|
132
+ | `[CONFIRMED]` | Safe to implement against |
133
+ | `[INFERRED]` | Non-binding until promoted |
134
+ | `[NEEDS CLARIFICATION]` | Resolve before relying on it |
135
+ | `[DECISION REQUIRED]` | Needs explicit choice (DEC-XXX) |
package/templates/SDD.md CHANGED
@@ -75,8 +75,9 @@ The default structure keeps a clear separation between project context and codeb
75
75
  │ └── [feature-name]/
76
76
  │ ├── spec.md # Requirements, scope, acceptance criteria
77
77
  │ ├── context.md # Background, prior decisions, related code
78
- │ ├── design.md # Optional technical design for medium/large/complex features
79
- └── tasks.md # Atomic tasks with traceability
78
+ │ ├── plan.md # Implementation plan (absorbs former design.md role)
79
+ ├── tasks.md # Atomic tasks with traceability
80
+ │ └── validation.md # Validation evidence ledger
80
81
 
81
82
  └── quick/
82
83
  └── [quick-task-name]/
@@ -84,6 +85,17 @@ The default structure keeps a clear separation between project context and codeb
84
85
  └── SUMMARY.md # What was done, files changed, outcome
85
86
  ```
86
87
 
88
+ Root agent files (created by `km-spec init`):
89
+
90
+ ```
91
+ AGENTS.md # Permanent agent rules and mandatory reading order
92
+ HARNESS.md # Execution lifecycle for agents
93
+ SDD.md # Full methodology reference
94
+ ```
95
+
96
+ **CLI tiers (v0.2+):** `km-spec feature` supports `--tier standard` (default) and `--tier complex`. Complex features include additional planning sections in `plan.md`. Quick work uses `km-spec quick` (directory layout above).
97
+
98
+ **Legacy (pre-0.2):** Features may only have `spec.md`, `tasks.md`, and `validation.md`. Quick tasks may be a single `.specs/quick/<name>.md` file. `km-spec doctor` warns on legacy layouts and does not fail solely for missing `context.md` / `plan.md`.
87
99
  ### Default vs Optional Codebase Documentation
88
100
 
89
101
  By default, the codebase has only one required technical document:
@@ -292,35 +304,34 @@ These files are optional expansions. They are not generated by default and shoul
292
304
 
293
305
  ---
294
306
 
295
- ### 3.7 `features/[name]/design.md`
307
+ ### 3.7 `features/[name]/plan.md`
296
308
 
297
- **Purpose:** Technical design for the feature. Translates requirements into an implementable structure.
309
+ **Purpose:** Implementation plan for the feature. Translates requirements into an implementable structure. **This is the canonical planning artifact** (it replaces / absorbs the former `design.md` responsibility).
298
310
 
299
- **Created:** After spec.md, before tasks.md, for medium/large/complex features.
311
+ **Created:** When the feature is scaffolded (`km-spec feature`). Filled after `spec.md` and `context.md` are sufficiently clear.
300
312
 
301
- **Skipped for:** Quick tasks and simple features where the implementation path is obvious.
313
+ **Depth:** Scales with tier `standard` (default) vs `complex` (extra sections: component boundaries, data model, API contracts, security, performance, rollout, observability, rollback).
302
314
 
303
- **Updated:** When design decisions change during implementation (with DEC-XXX entries).
315
+ **Skipped for:** Quick tasks.
304
316
 
305
- **Contains:**
306
- - Component and module breakdown
307
- - Data models and schema changes
308
- - API contracts (endpoints, request/response shapes)
309
- - State management design
310
- - Error states and edge case handling
311
- - Performance considerations
312
- - Security considerations
313
- - Diagrams as needed
317
+ **Updated:** When plan decisions change during implementation (with DEC-XXX entries).
314
318
 
319
+ **Contains:**
320
+ - Technical approach
321
+ - Affected components
322
+ - Data and interface considerations
323
+ - Error handling
324
+ - Risks, decisions, alternatives, open design questions
325
+ - For complex tier: component boundaries, data model, API/interface contracts, security, performance, migration/rollout, observability, rollback
315
326
  ---
316
327
 
317
328
  ### 3.8 `features/[name]/tasks.md`
318
329
 
319
- **Purpose:** The execution plan. Breaks design into atomic, verifiable, and potentially parallelizable tasks.
330
+ **Purpose:** The execution plan. Breaks the implementation plan into atomic, verifiable, and potentially parallelizable tasks.
320
331
 
321
- **Created:** After design.md, for medium/large/complex features.
332
+ **Created:** When the feature is scaffolded. Initial tasks are planning/decomposition tasks; implementation tasks are added after analysis (do not invent product implementation tasks before requirements and context are known).
322
333
 
323
- **Skipped for:** Quick tasks. For medium features, tasks may be inlined in spec.md.
334
+ **Skipped for:** Quick tasks.
324
335
 
325
336
  **Updated:** As tasks are completed (status updated), or when new tasks are discovered during execution.
326
337
 
@@ -328,8 +339,17 @@ These files are optional expansions. They are not generated by default and shoul
328
339
  - Full task list with TASK-XXX IDs
329
340
  - Dependencies between tasks
330
341
  - Parallelization markers (`[P]`)
331
- - Per-task: objective, files, steps, acceptance criteria, tests, validation gate, status
342
+ - Per-task: objective, required context, expected files, constraints, steps, completion criteria, validation, evidence, status
343
+
344
+ ### 3.8b `features/[name]/validation.md`
345
+
346
+ **Purpose:** Evidence ledger for gates (build, lint, typecheck/static analysis, tests, acceptance criteria, review, security when applicable).
347
+
348
+ **Created:** When the feature is scaffolded.
332
349
 
350
+ **Updated:** When validation is run. Do not invent pass/fail results.
351
+
352
+ **Note:** This file records evidence only. The CLI does not run project gates.
333
353
  ---
334
354
 
335
355
  ### 3.9 `quick/[name]/TASK.md`
@@ -395,54 +415,37 @@ These files are optional expansions. They are not generated by default and shoul
395
415
 
396
416
  ---
397
417
 
398
- #### Medium Feature
399
- **Profile:** Clear functionality with defined inputs/outputs. Low ambiguity. Fewer than 3 existing dependencies impacted.
418
+ #### Medium / Standard Feature
419
+ **Profile:** Clear functionality with defined inputs/outputs. Low ambiguity. CLI: `km-spec feature "Name"` (default `--tier standard`).
400
420
 
401
421
  **Workflow:**
402
- 1. Create `features/[name]/spec.md` with requirements and acceptance criteria
403
- 2. Create `features/[name]/context.md` with relevant background
404
- 3. Design inline inside spec.md or in brief `design.md` if needed
405
- 4. Tasks inline in spec.md or a short `tasks.md`
406
- 5. Execute with harness protocol
407
- 6. Run all validation gates
408
- 7. Update `STATE.md`
422
+ 1. Scaffold with `km-spec feature "Name"` (creates `spec.md`, `context.md`, `plan.md`, `tasks.md`, `validation.md`)
423
+ 2. Fill `spec.md` with requirements and acceptance criteria (confidence markers)
424
+ 3. Fill `context.md` from real repository inspection
425
+ 4. Fill `plan.md` with technical approach (keep light if path is obvious)
426
+ 5. Decompose implementation tasks in `tasks.md`
427
+ 6. Execute with harness protocol (`HARNESS.md`)
428
+ 7. Record gates in `validation.md`
429
+ 8. Update `STATE.md`
409
430
 
410
- **Ceremony level:** Low-to-medium. Skip `design.md` if implementation path is clear.
431
+ **Ceremony level:** Low-to-medium.
411
432
 
412
433
  ---
413
434
 
414
- #### Large Feature
415
- **Profile:** Multiple components. Touches existing architecture. Clear requirements but broad scope.
435
+ #### Large / Complex Feature
436
+ **Profile:** Multiple components, new domain, integrations, or high uncertainty. CLI: `km-spec feature "Name" --tier complex`.
416
437
 
417
438
  **Workflow:**
418
- 1. Create `spec.md`, `context.md`
419
- 2. Create `design.md` with full component breakdown, API contracts, data model
420
- 3. Create `tasks.md` with TASK-XXX IDs, dependencies, parallelization markers
421
- 4. Execute task by task, updating status in `tasks.md` as each completes
422
- 5. Run validation gates per task and full suite at end
423
- 6. Update `STATE.md`
424
-
425
- **Ceremony level:** Full. Do not skip `design.md` or `tasks.md`.
426
-
427
- ---
428
-
429
- #### Complex Feature
430
- **Profile:** New domain, high uncertainty, external integrations, technical risks, or research required.
431
-
432
- **Workflow:**
433
- 1. **Exploration phase:** Research before specifying. Use sub-agents for spikes.
434
- 2. Create `spec.md` after exploration — not before
435
- 3. Create `context.md` with extensive background and risk notes
436
- 4. Create `design.md` with alternatives considered and DEC-XXX decisions recorded
437
- 5. Create `tasks.md` with RISK-XXX markers on high-uncertainty tasks
438
- 6. Review design before execution (checkpoint)
439
- 7. Execute in phases — stop and respec if reality diverges significantly
440
- 8. Run validation gates including security review
441
- 9. UAT if applicable
442
- 10. Update `STATE.md` with all decisions, learnings, and deferred items
443
-
444
- **Ceremony level:** Maximum. Expect to iterate on `design.md` during implementation.
439
+ 1. Scaffold with `--tier complex` (adds expanded `plan.md` sections)
440
+ 2. Explore / spike before promoting requirements to `[CONFIRMED]`
441
+ 3. Fill `spec.md`, `context.md`, then complete complex `plan.md` sections
442
+ 4. Review plan before implementation tasks
443
+ 5. Decompose `tasks.md` with dependencies and RISK markers as needed
444
+ 6. Execute in phases — stop and replan if reality diverges
445
+ 7. Validate (including security when applicable); record evidence
446
+ 8. Update `STATE.md`
445
447
 
448
+ **Ceremony level:** Full. Do not skip `plan.md` depth for complex tier.
446
449
  ---
447
450
 
448
451
  ### Safety Valve Rule
@@ -489,7 +492,8 @@ Load only when working on the relevant feature or area:
489
492
  |------|-----------|
490
493
  | `features/[name]/spec.md` | Working on this feature |
491
494
  | `features/[name]/context.md` | Need background on this feature |
492
- | `features/[name]/design.md` | Need architecture decisions for this feature |
495
+ | `features/[name]/plan.md` | Need implementation plan / architecture decisions for this feature |
496
+ | `features/[name]/validation.md` | Recording or reviewing gate evidence |
493
497
  | `features/[name]/tasks.md` | Checking task status or picking next task |
494
498
  | `codebase/CONVENTIONS.md` → Technical Context | Adding dependencies or checking compatibility |
495
499
  | `codebase/CONVENTIONS.md` → Architecture | Making structural or cross-module changes |
@@ -641,7 +645,7 @@ If implementation reveals that the spec is wrong, incomplete, or contradicts an
641
645
  2. Record the deviation in `STATE.md` under "Deviations".
642
646
  3. If the deviation is minor and resolution is obvious → resolve and document.
643
647
  4. If the deviation requires a decision → document the options and ask.
644
- 5. Update `spec.md` or `design.md` to reflect any approved changes before continuing.
648
+ 5. Update `spec.md` or `plan.md` to reflect any approved changes before continuing.
645
649
 
646
650
  ---
647
651
 
@@ -669,7 +673,7 @@ A sub-agent receives a self-contained briefing. It must never rely on chat histo
669
673
  **Required input:**
670
674
  ```
671
675
  1. Task description (exact scope, no ambiguity)
672
- 2. Relevant spec files (spec.md, context.md, or design.md for the area)
676
+ 2. Relevant spec files (spec.md, context.md, or plan.md for the area)
673
677
  3. Relevant codebase docs (CONVENTIONS.md always; others on demand)
674
678
  4. Specific files to read or modify
675
679
  5. Acceptance criteria
@@ -755,7 +759,7 @@ Project Goal
755
759
  └── REQ-XXX (requirement in spec.md)
756
760
  └── TASK-XXX (task in tasks.md)
757
761
  ├── TEST-XXX (test file or validation evidence)
758
- ├── DEC-XXX (decision in design.md or STATE.md)
762
+ ├── DEC-XXX (decision in plan.md or STATE.md)
759
763
  └── Commit (references TASK-XXX in message)
760
764
  ```
761
765
 
@@ -826,15 +830,19 @@ Every task must reference the requirements it satisfies. Every test must referen
826
830
 
827
831
  ---
828
832
 
829
- ### 10.2 `design.md` Template
833
+ ### 10.2 `plan.md` Template
834
+
835
+ > Canonical name is **`plan.md`** (formerly referred to as `design.md` in earlier SDD drafts).
836
+ > The CLI scaffolds a guided `plan.md` via templates; the outline below is the conceptual structure.
830
837
 
831
838
  ```markdown
832
- # [Feature Name] — Technical Design
839
+ # [Feature Name] — Implementation Plan
833
840
 
834
841
  **Feature ID:** FEAT-XXX
835
842
  **Linked Spec:** spec.md
843
+ **Linked Context:** context.md
836
844
  **Created:** YYYY-MM-DD
837
- **Status:** Draft | Approved | Superseded
845
+ **Status:** Draft | Ready for implementation | Superseded
838
846
 
839
847
  ## Overview
840
848
 
@@ -927,7 +935,7 @@ created_at | datetime| required |
927
935
 
928
936
  **Feature ID:** FEAT-XXX
929
937
  **Linked Spec:** spec.md
930
- **Linked Design:** design.md
938
+ **Linked Plan:** plan.md
931
939
  **Created:** YYYY-MM-DD
932
940
 
933
941
  ## Status Summary
@@ -1447,7 +1455,7 @@ Tokens expire after 7 days and rotate on each use.
1447
1455
  ```
1448
1456
 
1449
1457
  ```
1450
- spec(user-profile): add design.md with API contract [TASK-003]
1458
+ spec(user-profile): add plan.md with API contract [TASK-003]
1451
1459
  ```
1452
1460
 
1453
1461
  ```
@@ -1574,7 +1582,7 @@ support tickets. This feature closes the most common support request.
1574
1582
 
1575
1583
  #### Step 3: Design (brief, medium feature)
1576
1584
 
1577
- **File:** `.specs/features/email-notifications/design.md`
1585
+ **File:** `.specs/features/email-notifications/plan.md`
1578
1586
 
1579
1587
  ```markdown
1580
1588
  # Email Notifications — Design
@@ -1732,19 +1740,19 @@ The `.specs/` structure is tool-independent. It works as a plain text contract t
1732
1740
 
1733
1741
  **Usage pattern:**
1734
1742
  1. Start each session: `Read .specs/project/STATE.md`
1735
- 2. Load feature context: `Read .specs/features/[name]/spec.md` and `context.md`
1736
- 3. Use `CLAUDE.md` to point to the harness: add a line pointing to this `SDD.md`
1743
+ 2. Load feature context: `Read` feature `spec.md`, `context.md`, `plan.md`, `tasks.md`
1744
+ 3. Use `CLAUDE.md` / project `AGENTS.md` to point at `HARNESS.md`
1737
1745
  4. Use Claude Code's task system to track TASK-XXX progress
1738
- 5. Use `Bash` tool to run validation gates and capture evidence
1746
+ 5. Use `Bash` tool to run validation gates and capture evidence in `validation.md`
1739
1747
  6. End each session: update `STATE.md` before closing
1740
1748
 
1741
1749
  **CLAUDE.md suggestion:**
1742
1750
  ```markdown
1743
1751
  # Development Guide
1744
- This project uses Spec Driven Development. See `SDD.md` for the full methodology.
1752
+ This project uses Spec Driven Development. See `AGENTS.md` and `HARNESS.md`.
1753
+ Full methodology: `SDD.md`.
1745
1754
 
1746
1755
  Always start a session by reading `.specs/project/STATE.md`.
1747
- All work follows the AI Development Harness in `SDD.md` Section 7.
1748
1756
  ```
1749
1757
 
1750
1758
  ---
@@ -1789,7 +1797,7 @@ All work follows the AI Development Harness in `SDD.md` Section 7.
1789
1797
  **Usage pattern:**
1790
1798
  1. Use Copilot Chat with explicit file context: "Given `spec.md` [paste], implement `sendShippedEmail`"
1791
1799
  2. Use `@workspace` in Copilot Chat to reference the full codebase (when available)
1792
- 3. Copilot is best for filling in implementation detail after design is done in `design.md`
1800
+ 3. Copilot is best for filling in implementation detail after the plan is done in `plan.md`
1793
1801
  4. Manually validate and update `tasks.md` — Copilot does not maintain state
1794
1802
 
1795
1803
  **Limitation:** No persistent memory. Must re-establish context per chat session.
@@ -1841,7 +1849,7 @@ The orchestrating agent is responsible for integrating the sub-agent's output ba
1841
1849
 
1842
1850
  ### Start lean, grow as needed
1843
1851
 
1844
- Do not create every `.specs/` file before writing any code. For a quick task, `quick/[name]/TASK.md` is sufficient. For a new medium feature, start with `spec.md` and `context.md`. Add `design.md` and `tasks.md` when the complexity warrants it.
1852
+ Do not create every `.specs/` file by hand before writing any code. Prefer `km-spec quick` or `km-spec feature` scaffolds. For a quick task, `quick/[name]/TASK.md` is sufficient. For a standard feature, fill `spec.md` and `context.md` before deep implementation; complete `plan.md` depth based on tier.
1845
1853
 
1846
1854
  ### STATE.md is the most important file
1847
1855
 
@@ -1849,7 +1857,7 @@ Every agent must read it first and update it last. A well-maintained `STATE.md`
1849
1857
 
1850
1858
  ### Trust the traceability chain
1851
1859
 
1852
- When requirements change, follow the chain: update `spec.md`, then `design.md`, then `tasks.md`, then the code. Never update code and forget to update the spec. The spec is the contract — the code is the execution.
1860
+ When requirements change, follow the chain: update `spec.md`, then `plan.md`, then `tasks.md`, then the code. Never update code and forget to update the spec. The spec is the contract — the code is the execution.
1853
1861
 
1854
1862
  ### Keep validation evidence
1855
1863
 
@@ -1869,5 +1877,6 @@ Update `SDD.md` itself when the team finds patterns that work better, when tools
1869
1877
 
1870
1878
  ---
1871
1879
 
1872
- *SDD v1.0.0 — Built on the TLC Spec Driven Development model.*
1880
+ *SDD v1.1.0 (aligned with km-spec 0.2.0) — Built on the TLC Spec Driven Development model.*
1873
1881
  *Tool-independent. Complexity-adaptive. AI-native.*
1882
+ *CLI scaffolds use `plan.md` + `validation.md`; see `HARNESS.md` for the agent lifecycle.*
@@ -0,0 +1,69 @@
1
+ <!-- km-spec-template: feature/context@1.0 -->
2
+ # Context: {{FEATURE_NAME}}
3
+
4
+ | Field | Value |
5
+ |-------|-------|
6
+ | **Feature ID** | {{FEATURE_ID}} |
7
+ | **Linked Spec** | `spec.md` |
8
+ | **Created** | {{CREATED_DATE}} |
9
+ | **Template** | feature/context@{{TEMPLATE_VERSION}} |
10
+
11
+ <!--
12
+ AGENT INSTRUCTIONS
13
+ - Populate this file by reading the real repository. Do not invent paths.
14
+ - Mark unknown items [NEEDS CLARIFICATION] until verified in source.
15
+ - Prefer concrete file paths and symbols over vague module names.
16
+ -->
17
+
18
+ ## Background and Motivation
19
+
20
+ [NEEDS CLARIFICATION]: Why does this feature exist now? What problem does it solve for users or the system?
21
+
22
+ {{DESCRIPTION_CONTEXT}}
23
+
24
+ ## Related Code Paths
25
+
26
+ List real paths after inspection. Do not invent files.
27
+
28
+ | Area | Path / Symbol | Notes | Confidence |
29
+ |------|---------------|-------|------------|
30
+ | Entry / API | [NEEDS CLARIFICATION] | | [NEEDS CLARIFICATION] |
31
+ | Domain / service | [NEEDS CLARIFICATION] | | [NEEDS CLARIFICATION] |
32
+ | Data / persistence | [NEEDS CLARIFICATION] | | [NEEDS CLARIFICATION] |
33
+ | Tests | [NEEDS CLARIFICATION] | | [NEEDS CLARIFICATION] |
34
+
35
+ ## Existing Patterns to Follow
36
+
37
+ - [NEEDS CLARIFICATION]: Reference an existing similar feature or module and the pattern to copy.
38
+ - Check `.specs/codebase/CONVENTIONS.md` for project-wide patterns.
39
+
40
+ ## Prior Decisions
41
+
42
+ | ID | Decision | Source | Confidence |
43
+ |----|----------|--------|------------|
44
+ | — | [NEEDS CLARIFICATION]: Link DEC-XXX from STATE.md or CONVENTIONS if any apply. | | [NEEDS CLARIFICATION] |
45
+
46
+ ## Likely Impacted Files
47
+
48
+ Fill only after inspecting the codebase (target ≤ a reviewable set for the first slice).
49
+
50
+ - [NEEDS CLARIFICATION]: `path/to/file` — reason
51
+
52
+ ## Risks
53
+
54
+ | ID | Risk | Severity | Notes |
55
+ |----|------|----------|-------|
56
+ | RISK-001 | [NEEDS CLARIFICATION]: Unknown risk until code is inspected. | TBD | |
57
+
58
+ ## Anti-Patterns to Avoid
59
+
60
+ - [NEEDS CLARIFICATION]: Patterns in this codebase that should not be copied for this feature.
61
+ - Do not introduce unrelated refactors while implementing this feature.
62
+
63
+ ## Document Completion Criteria
64
+
65
+ This `context.md` is **Ready for plan** when:
66
+
67
+ - [ ] Related code paths point to files that exist in the repository.
68
+ - [ ] Likely impacted files are based on inspection, not guesswork.
69
+ - [ ] Relevant patterns and risks are noted or explicitly marked N/A with rationale.