@drafthq/draft 3.5.3 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/README.md +28 -49
  5. package/bin/README.md +47 -1
  6. package/cli/src/hosts/cursor.js +3 -0
  7. package/cli/src/installer.js +8 -4
  8. package/cli/src/lib/cursor-registry.js +10 -0
  9. package/cli/src/lib/fsx.js +3 -0
  10. package/cli/src/lib/marker.js +8 -3
  11. package/core/agents/architect.md +21 -9
  12. package/core/agents/debugger.md +5 -0
  13. package/core/agents/ops.md +7 -2
  14. package/core/agents/planner.md +7 -0
  15. package/core/agents/rca.md +14 -3
  16. package/core/agents/reviewer.md +1 -0
  17. package/core/agents/writer.md +6 -0
  18. package/core/knowledge-base.md +22 -3
  19. package/core/methodology.md +30 -5
  20. package/core/shared/condensation.md +28 -18
  21. package/core/shared/context-verify.md +3 -1
  22. package/core/shared/cross-skill-dispatch.md +7 -3
  23. package/core/shared/draft-context-loading.md +3 -0
  24. package/core/shared/git-report-metadata.md +2 -1
  25. package/core/shared/graph-query.md +24 -26
  26. package/core/shared/graph-usage-report.md +1 -1
  27. package/core/shared/jira-sync.md +10 -6
  28. package/core/shared/okf-retrieval.md +1 -1
  29. package/core/shared/parallel-analysis.md +14 -7
  30. package/core/shared/pattern-learning.md +2 -0
  31. package/core/shared/template-contract.md +1 -1
  32. package/core/shared/tool-resolver.md +20 -15
  33. package/core/shared/vcs-commands.md +5 -2
  34. package/core/templates/ai-context.md +3 -2
  35. package/core/templates/ai-profile.md +7 -0
  36. package/core/templates/architecture.md +6 -2
  37. package/core/templates/discovery.md +1 -1
  38. package/core/templates/guardrails.md +9 -0
  39. package/core/templates/hld.md +5 -4
  40. package/core/templates/intake-questions.md +45 -0
  41. package/core/templates/jira.md +11 -2
  42. package/core/templates/lld.md +8 -5
  43. package/core/templates/okf/concept.md +0 -1
  44. package/core/templates/plan.md +1 -1
  45. package/core/templates/product.md +11 -2
  46. package/core/templates/rca.md +6 -0
  47. package/core/templates/service-index.md +1 -0
  48. package/core/templates/spec.md +15 -0
  49. package/core/templates/tech-stack.md +12 -0
  50. package/core/templates/workflow.md +20 -0
  51. package/integrations/agents/AGENTS.md +1449 -817
  52. package/integrations/copilot/.github/copilot-instructions.md +1449 -817
  53. package/package.json +1 -1
  54. package/scripts/fetch-memory-engine.sh +25 -7
  55. package/scripts/lib.sh +90 -6
  56. package/scripts/tools/_graph_queries.sh +22 -8
  57. package/scripts/tools/_lib.sh +81 -11
  58. package/scripts/tools/adr-index.sh +1 -1
  59. package/scripts/tools/check-repo-size.sh +125 -0
  60. package/scripts/tools/check-skill-line-caps.sh +3 -4
  61. package/scripts/tools/check-template-noop.sh +0 -1
  62. package/scripts/tools/check-track-hygiene.sh +41 -21
  63. package/scripts/tools/classify-files.sh +3 -3
  64. package/scripts/tools/cycle-detect.sh +18 -17
  65. package/scripts/tools/detect-test-framework.sh +1 -1
  66. package/scripts/tools/emit-skill-metrics.sh +7 -2
  67. package/scripts/tools/fix-whitespace.sh +3 -0
  68. package/scripts/tools/freshness-check.sh +2 -2
  69. package/scripts/tools/git-metadata.sh +12 -6
  70. package/scripts/tools/graph-arch.sh +5 -11
  71. package/scripts/tools/graph-callers.sh +10 -15
  72. package/scripts/tools/graph-deps.sh +3 -10
  73. package/scripts/tools/graph-errors.sh +4 -11
  74. package/scripts/tools/graph-hierarchy.sh +4 -11
  75. package/scripts/tools/graph-impact.sh +21 -19
  76. package/scripts/tools/graph-init.sh +13 -9
  77. package/scripts/tools/graph-preflight.sh +4 -1
  78. package/scripts/tools/graph-query.sh +74 -18
  79. package/scripts/tools/graph-risk.sh +3 -10
  80. package/scripts/tools/graph-search.sh +4 -11
  81. package/scripts/tools/graph-snapshot.sh +38 -9
  82. package/scripts/tools/graph-snippet.sh +3 -10
  83. package/scripts/tools/graph-tests.sh +3 -10
  84. package/scripts/tools/graph-traces.sh +3 -10
  85. package/scripts/tools/hotspot-rank.sh +6 -12
  86. package/scripts/tools/install-smoke-test.sh +223 -0
  87. package/scripts/tools/mermaid-from-graph.sh +5 -11
  88. package/scripts/tools/migrate-track-frontmatter.sh +11 -10
  89. package/scripts/tools/okf-coverage-check.sh +8 -7
  90. package/scripts/tools/okf-emit-catalog.sh +256 -0
  91. package/scripts/tools/okf-fix-links.sh +251 -0
  92. package/scripts/tools/okf-plan-concepts.sh +242 -14
  93. package/scripts/tools/okf-render-views.sh +63 -21
  94. package/scripts/tools/okf-validate-all.sh +20 -9
  95. package/scripts/tools/okf-validate-quality.sh +15 -10
  96. package/scripts/tools/okf-validate.sh +20 -6
  97. package/scripts/tools/parse-git-log.sh +23 -5
  98. package/scripts/tools/parse-reports.sh +1 -1
  99. package/scripts/tools/render-track.sh +1 -1
  100. package/scripts/tools/resolve-tools.sh +24 -8
  101. package/scripts/tools/run-coverage.sh +1 -1
  102. package/scripts/tools/scan-markers.sh +4 -4
  103. package/scripts/tools/validate-frontmatter.sh +2 -2
  104. package/scripts/tools/verify-citations.sh +3 -4
  105. package/scripts/tools/verify-doc-anchors.sh +14 -34
  106. package/scripts/tools/verify-graph-binary.sh +15 -5
  107. package/skills/GRAPH.md +21 -10
  108. package/skills/adr/SKILL.md +25 -7
  109. package/skills/assist-review/SKILL.md +2 -1
  110. package/skills/bughunt/SKILL.md +55 -12
  111. package/skills/bughunt/references/regression-tests.md +14 -4
  112. package/skills/change/SKILL.md +19 -9
  113. package/skills/coverage/SKILL.md +28 -12
  114. package/skills/debug/SKILL.md +13 -3
  115. package/skills/decompose/SKILL.md +42 -12
  116. package/skills/deep-review/SKILL.md +19 -6
  117. package/skills/deploy-checklist/SKILL.md +10 -3
  118. package/skills/documentation/SKILL.md +12 -1
  119. package/skills/draft/SKILL.md +40 -29
  120. package/skills/draft/context-files.md +8 -1
  121. package/skills/draft/quality-guide.md +10 -2
  122. package/skills/graph/SKILL.md +2 -2
  123. package/skills/impact/SKILL.md +4 -2
  124. package/skills/implement/SKILL.md +62 -20
  125. package/skills/incident-response/SKILL.md +5 -2
  126. package/skills/init/SKILL.md +112 -30
  127. package/skills/init/references/architecture-spec.md +32 -8
  128. package/skills/init/references/okf-emitter.md +42 -78
  129. package/skills/jira/SKILL.md +33 -13
  130. package/skills/jira/references/review.md +61 -19
  131. package/skills/learn/SKILL.md +30 -7
  132. package/skills/new-track/SKILL.md +73 -18
  133. package/skills/quick-review/SKILL.md +8 -3
  134. package/skills/revert/SKILL.md +11 -5
  135. package/skills/review/SKILL.md +126 -27
  136. package/skills/review/references/zero-setup-mode.md +117 -0
  137. package/skills/standup/SKILL.md +10 -2
  138. package/skills/status/SKILL.md +7 -7
  139. package/skills/tech-debt/SKILL.md +9 -3
  140. package/skills/testing-strategy/SKILL.md +10 -2
  141. package/skills/tour/SKILL.md +2 -1
  142. package/skills/upload/SKILL.md +4 -3
  143. package/core/templates/track-architecture.md +0 -311
@@ -69,6 +69,7 @@ Before investigating, load and reference the project's big picture documents:
69
69
  **Output:** Reproduction confirmed with evidence. Blast radius and SLO impact documented. Investigation scoped to specific module(s).
70
70
 
71
71
  **Anti-patterns:**
72
+
72
73
  - Starting to read code before reproducing
73
74
  - Assuming the bug reporter's diagnosis is correct
74
75
  - Investigating the entire system instead of scoping first
@@ -82,18 +83,23 @@ Before investigating, load and reference the project's big picture documents:
82
83
  **Techniques (use the most appropriate):**
83
84
 
84
85
  #### Control Flow Tracing
86
+
85
87
  Follow the execution path from entry point to failure:
86
- ```
88
+
89
+ ```text
87
90
  request arrives → handler (file:line)
88
91
  → validation (file:line) ✓ passes
89
92
  → service call (file:line) ✓ returns data
90
93
  → transformation (file:line) ✗ FAILS HERE
91
94
  ```
95
+
92
96
  Document each hop with `file:line` references.
93
97
 
94
98
  #### Data Flow Tracing
99
+
95
100
  Track data transformation through the system:
96
- ```
101
+
102
+ ```yaml
97
103
  input: { userId: "abc", role: "admin" }
98
104
  → after auth middleware (file:line): { userId: "abc", role: "admin", verified: true }
99
105
  → after service layer (file:line): { userId: "abc", role: null } ← DATA LOST HERE
@@ -101,6 +107,7 @@ input: { userId: "abc", role: "admin" }
101
107
  ```
102
108
 
103
109
  #### Differential Analysis (Google SRE Practice)
110
+
104
111
  Compare what works vs. what doesn't:
105
112
 
106
113
  | Aspect | Working Case | Failing Case | Difference |
@@ -112,8 +119,10 @@ Compare what works vs. what doesn't:
112
119
  This narrows the investigation to the specific difference that causes the failure.
113
120
 
114
121
  #### 5 Whys (Toyota/Google Practice)
122
+
115
123
  Once you find the immediate cause, ask "why" to find the root:
116
- ```
124
+
125
+ ```text
117
126
  1. Why did the request fail? → NullPointerException at file:line
118
127
  2. Why was the value null? → The cache returned stale data
119
128
  3. Why was the cache stale? → The invalidation event was dropped
@@ -125,6 +134,7 @@ Once you find the immediate cause, ask "why" to find the root:
125
134
  **Output:** Data/control flow trace with exact code references. Divergence point identified.
126
135
 
127
136
  **Anti-patterns:**
137
+
128
138
  - Reading code randomly instead of tracing the specific flow
129
139
  - Assuming you know the code path without verifying
130
140
  - Skipping the "what works" comparison
@@ -149,6 +159,7 @@ Once you find the immediate cause, ask "why" to find the root:
149
159
  | 1 | Cache returns stale data when TTL=0 | Unit test with TTL=0 | Should return stale | Returns stale | **Confirmed** |
150
160
 
151
161
  **If hypothesis fails:**
162
+
152
163
  - Do NOT try a random different fix
153
164
  - Record the failed hypothesis (it narrows the search space)
154
165
  - Return to Phase 2 with updated understanding
@@ -84,6 +84,7 @@ Check against the track's `spec.md`:
84
84
  - [ ] Integration points work as specified
85
85
 
86
86
  **Verdict options:**
87
+
87
88
  - **PASS** — All requirements met, all acceptance criteria verified
88
89
  - **PASS WITH NOTES** — All requirements met but minor gaps exist in acceptance criteria verification
89
90
  - **FAIL** — Missing requirements or acceptance criteria not met
@@ -37,6 +37,7 @@ You are a technical writer agent. When generating documentation, follow structur
37
37
  ### Step 1: Audience Analysis
38
38
 
39
39
  Before writing, answer:
40
+
40
41
  - Who will read this? (role, experience level)
41
42
  - When will they read it? (onboarding, debugging, integrating)
42
43
  - What question are they trying to answer?
@@ -45,6 +46,7 @@ Before writing, answer:
45
46
  ### Step 2: Information Architecture
46
47
 
47
48
  Organize content using this hierarchy:
49
+
48
50
  1. **Title** — What is this document about?
49
51
  2. **TL;DR** — 1-3 sentence summary for scanners
50
52
  3. **Quick Start** — Minimum steps to get started (if applicable)
@@ -71,22 +73,26 @@ Organize content using this hierarchy:
71
73
  ## Documentation Modes
72
74
 
73
75
  ### README Mode
76
+
74
77
  - Audience: New team members, external visitors
75
78
  - Structure: What → Why → Quick Start → Architecture Overview → Development → Deployment → Contributing
76
79
  - Sources: product.md, tech-stack.md, .ai-context.md, workflow.md
77
80
 
78
81
  ### Runbook Mode
82
+
79
83
  - Audience: Operators, on-call engineers
80
84
  - Structure: Service Overview → Health Checks → Common Issues → Escalation → Recovery Procedures
81
85
  - Sources: .ai-context.md (service map), tech-stack.md (infrastructure), incident history
82
86
  - Reference: `core/agents/ops.md` for operational mindset
83
87
 
84
88
  ### API Mode
89
+
85
90
  - Audience: Integrators, frontend developers
86
91
  - Structure: Authentication → Endpoints (grouped by resource) → Request/Response Examples → Error Codes → Rate Limits
87
92
  - Sources: Code analysis, tech-stack.md (API patterns), existing API tests
88
93
 
89
94
  ### Onboarding Mode
95
+
90
96
  - Audience: New team members (day 1-5)
91
97
  - Structure: Prerequisites → Environment Setup → First Task Walkthrough → Key Concepts → Who to Ask
92
98
  - Sources: All draft context files, workflow.md, guardrails.md
@@ -7,28 +7,33 @@ AI guidance during track creation must be grounded in vetted sources. When provi
7
7
  ## Books
8
8
 
9
9
  ### Architecture & Design
10
+
10
11
  - **Domain-Driven Design** (Eric Evans) — Bounded contexts, ubiquitous language, aggregates, strategic design
11
12
  - **Clean Architecture** (Robert Martin) — Dependency rule, boundaries, use cases, separation of concerns
12
13
  - **Designing Data-Intensive Applications** (Martin Kleppmann) — Data models, replication, partitioning, consistency, stream processing
13
14
  - **Building Evolutionary Architectures** (Ford, Parsons, Kua) — Fitness functions, incremental change, architectural governance
14
15
 
15
16
  ### Reliability & Operations
17
+
16
18
  - **Release It!** (Michael Nygard) — Stability patterns, circuit breakers, bulkheads, timeouts, failure modes
17
19
  - **Site Reliability Engineering** (Google) — SLOs, error budgets, toil reduction, incident response
18
20
  - **The Phoenix Project** (Kim, Behr, Spafford) — Flow, feedback, continuous improvement
19
21
 
20
22
  ### Craft & Practice
23
+
21
24
  - **The Pragmatic Programmer** (Hunt, Thomas, 20th Anniversary ed., 2019) — Tracer bullets, DRY, orthogonality, good enough software
22
25
  - **Clean Code** (Robert Martin) — Naming, functions, error handling, code smells
23
26
  - **Refactoring** (Martin Fowler, 2nd ed., 2018) — Code smells, refactoring patterns, incremental improvement
24
27
  - **Working Effectively with Legacy Code** (Michael Feathers) — Seams, characterization tests, breaking dependencies
25
28
 
26
29
  ### Microservices & Distribution
30
+
27
31
  - **Building Microservices** (Sam Newman, 2nd ed., 2021) — Service boundaries, decomposition, communication patterns
28
32
  - **Microservices Patterns** (Chris Richardson) — Saga, CQRS, event sourcing, API gateway
29
33
  - **Enterprise Integration Patterns** (Hohpe, Woolf) — Messaging, routing, transformation, endpoints
30
34
 
31
35
  ### Testing
36
+
32
37
  - **Growing Object-Oriented Software, Guided by Tests** (Freeman, Pryce) — TDD outside-in, mock objects
33
38
  - **Unit Testing Principles, Practices, and Patterns** (Khorikov) — Test pyramid, test doubles, maintainable tests
34
39
 
@@ -37,21 +42,25 @@ AI guidance during track creation must be grounded in vetted sources. When provi
37
42
  ## Standards & Principles
38
43
 
39
44
  ### Security
45
+
40
46
  - **OWASP Top 10** — Injection, broken auth, XSS, insecure deserialization, security misconfiguration
41
47
  - **OWASP ASVS** — Application Security Verification Standard, security requirements
42
48
  - **OWASP Cheat Sheets** — Specific guidance for auth, session management, input validation
43
49
 
44
50
  ### Design Principles
51
+
45
52
  - **SOLID** — Single responsibility, open/closed, Liskov substitution, interface segregation, dependency inversion
46
53
  - **12-Factor App** — Codebase, dependencies, config, backing services, build/release/run, processes, port binding, concurrency, disposability, dev/prod parity, logs, admin processes
47
54
  - **KISS / YAGNI / DRY** — Simplicity, avoiding premature abstraction, avoiding duplication
48
55
 
49
56
  ### API Design
57
+
50
58
  - **REST Constraints** — Stateless, cacheable, uniform interface, layered system
51
59
  - **GraphQL Best Practices** — Schema design, resolvers, N+1 prevention
52
60
  - **API Versioning Strategies** — URL, header, content negotiation
53
61
 
54
62
  ### Cloud Native
63
+
55
64
  - **CNCF Patterns** — Containers, service mesh, observability, declarative configuration
56
65
  - **GitOps Principles** — Declarative, versioned, automated, auditable
57
66
 
@@ -60,15 +69,19 @@ AI guidance during track creation must be grounded in vetted sources. When provi
60
69
  ## Patterns
61
70
 
62
71
  ### Creational (GoF)
72
+
63
73
  - Factory, Abstract Factory, Builder, Prototype, Singleton
64
74
 
65
75
  ### Structural (GoF)
76
+
66
77
  - Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
67
78
 
68
79
  ### Behavioral (GoF)
80
+
69
81
  - Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor
70
82
 
71
83
  ### Resilience
84
+
72
85
  - **Circuit Breaker** — Fail fast, prevent cascade failures
73
86
  - **Bulkhead** — Isolate failures, limit blast radius
74
87
  - **Retry with Backoff** — Transient failure recovery
@@ -76,12 +89,14 @@ AI guidance during track creation must be grounded in vetted sources. When provi
76
89
  - **Fallback** — Graceful degradation
77
90
 
78
91
  ### Data
92
+
79
93
  - **CQRS** — Separate read/write models
80
94
  - **Event Sourcing** — Append-only event log as source of truth
81
95
  - **Saga** — Distributed transaction coordination
82
96
  - **Outbox** — Reliable event publishing
83
97
 
84
98
  ### Integration (EIP)
99
+
85
100
  - Message Channel, Message Router, Message Translator, Message Endpoint
86
101
  - Publish-Subscribe, Request-Reply, Competing Consumers
87
102
  - Dead Letter Channel, Wire Tap, Content-Based Router
@@ -91,23 +106,27 @@ AI guidance during track creation must be grounded in vetted sources. When provi
91
106
  ## Anti-Patterns to Flag
92
107
 
93
108
  ### Distributed Systems
109
+
94
110
  - **Fallacies of Distributed Computing** — Network reliability, zero latency, infinite bandwidth, secure network, topology stability, single admin, zero transport cost, homogeneous network
95
111
  - **Distributed Monolith** — Microservices with tight coupling
96
112
  - **Shared Database** — Services coupled through data
97
113
 
98
114
  ### Architecture
115
+
99
116
  - **Big Ball of Mud** — No discernible structure
100
117
  - **Golden Hammer** — Using one solution for everything
101
118
  - **Cargo Cult** — Copying patterns without understanding
102
119
  - **Premature Optimization** — Optimizing before measuring
103
120
 
104
121
  ### Code
122
+
105
123
  - **God Class** — Class doing too much
106
124
  - **Feature Envy** — Method more interested in other class's data
107
125
  - **Shotgun Surgery** — Changes requiring many small edits across codebase
108
126
  - **Leaky Abstraction** — Implementation details bleeding through interface
109
127
 
110
128
  ### Security
129
+
111
130
  - **Security by Obscurity** — Hiding instead of securing
112
131
  - **Trust on First Use** — Accepting unverified credentials
113
132
  - **Hardcoded Secrets** — Credentials in source code
@@ -119,9 +138,9 @@ AI guidance during track creation must be grounded in vetted sources. When provi
119
138
  When providing guidance, cite sources naturally:
120
139
 
121
140
  > "Consider CQRS here (DDIA, Ch. 11) — separates read/write concerns which fits your high-read workload."
122
-
141
+ >
123
142
  > "This violates the Dependency Rule (Clean Architecture) — domain shouldn't know about infrastructure."
124
-
143
+ >
125
144
  > "Watch for N+1 queries (common GraphQL pitfall) — use DataLoader pattern."
126
-
145
+ >
127
146
  > "Circuit breaker pattern (Release It!) would help here — fail fast instead of cascading timeouts."
@@ -9,6 +9,7 @@ Draft is a methodology for Context-Driven Development that ensures consistent, h
9
9
  ### The Core Problem
10
10
 
11
11
  AI coding assistants are powerful but undirected. Without structure, they:
12
+
12
13
  - Make assumptions about requirements
13
14
  - Choose arbitrary technical approaches
14
15
  - Produce code that doesn't fit the existing codebase
@@ -73,7 +74,7 @@ Draft solves this through **Context-Driven Development**: structured documents t
73
74
 
74
75
  ### The Constraint Hierarchy
75
76
 
76
- ```
77
+ ```text
77
78
  product.md → "Build a task manager for developers"
78
79
 
79
80
  tech-stack.md → "Use React, TypeScript, Tailwind"
@@ -93,7 +94,7 @@ Each layer narrows the solution space. By the time AI writes code, most decision
93
94
 
94
95
  Draft uses a layered context system inspired by memory tiering — see `core/shared/draft-context-loading.md` for the authoritative specification.
95
96
 
96
- ```
97
+ ```text
97
98
  Layer 0: .ai-profile.md (20-50 lines) — Always loaded. Minimum project context.
98
99
  Layer 1: .ai-context.md (200-400 lines) — Base context: boundaries, invariants, flows.
99
100
  Layer 1.5: draft/graph/*.jsonl — Structural graph (when available).
@@ -145,6 +146,7 @@ graph LR
145
146
  ### Keeping AI Constrained
146
147
 
147
148
  Without constraints, AI will:
149
+
148
150
  1. **Over-engineer** — add abstractions, utilities, "improvements" you didn't ask for
149
151
  2. **Assume context** — guess at requirements instead of asking
150
152
  3. **Lose focus** — drift across the codebase making tangential changes
@@ -164,6 +166,7 @@ The AI becomes an executor of pre-approved work, not an autonomous decision-make
164
166
  **This is Draft's most important feature.**
165
167
 
166
168
  The workflow:
169
+
167
170
  1. Developer runs `/draft:plan` — AI routes to the right planning workflow, usually `/draft:new-track`
168
171
  2. Developer reviews and edits these documents
169
172
  3. Developer commits them for peer review
@@ -178,6 +181,7 @@ The workflow:
178
181
  | AI decisions are implicit | AI decisions are documented |
179
182
 
180
183
  **Benefits:**
184
+
181
185
  - **Faster reviews** — Reviewers approve approach, not implementation details
182
186
  - **Fewer rewrites** — Catch design issues before code exists
183
187
  - **Knowledge transfer** — Specs document *why*, not just *what*
@@ -201,12 +205,14 @@ Draft's artifacts are designed for team collaboration through standard git workf
201
205
  ### When to Use Draft
202
206
 
203
207
  **Good fit:**
208
+
204
209
  - Features requiring design decisions
205
210
  - Work that will be reviewed by others
206
211
  - Complex multi-step implementations
207
212
  - Anything where "just do it" has failed before
208
213
 
209
214
  **Overkill:**
215
+
210
216
  - One-line bug fixes
211
217
  - Typo corrections
212
218
  - Exploratory prototypes you'll throw away
@@ -249,6 +255,7 @@ Writing specs feels slower. It isn't.
249
255
  | Wrong feature entirely | Days wasted | Caught in review |
250
256
 
251
257
  The overhead is constant (~20% for simple tasks). The savings scale with:
258
+
252
259
  - **Complexity** — More moving parts = more value from upfront planning
253
260
  - **Team size** — More reviewers = more value from documented decisions
254
261
  - **Criticality** — Higher stakes = more value from discipline
@@ -306,7 +313,7 @@ Draft works with **Claude Code** (native `.claude-plugin/` support) and **Cursor
306
313
 
307
314
  ## Core Workflow
308
315
 
309
- ```
316
+ ```text
310
317
  Context → Spec & Plan → Implement
311
318
  ```
312
319
 
@@ -321,7 +328,7 @@ A **track** is a high-level unit of work (feature, bug fix, refactor). Each trac
321
328
 
322
329
  Two layouts are supported; both are valid:
323
330
 
324
- ```
331
+ ```text
325
332
  # Single-track project (default) # Multi-track project
326
333
  draft/ draft/tracks/<track-id>/
327
334
  ├── spec.md ├── spec.md
@@ -387,6 +394,7 @@ Plans are organized into phases:
387
394
  ### Task Granularity
388
395
 
389
396
  Good tasks are:
397
+
390
398
  - Completable in a focused session
391
399
  - Have clear success criteria
392
400
  - Produce testable output
@@ -534,6 +542,7 @@ Creates a new track (feature, bug fix, or refactor) with a specification and pha
534
542
  #### Context Loading
535
543
 
536
544
  Every new track loads the full project context before spec creation:
545
+
537
546
  - `draft/product.md` — product vision, users, goals, guidelines
538
547
  - `draft/tech-stack.md` — languages, frameworks, patterns, accepted patterns
539
548
  - `draft/.ai-context.md` — system map, modules, data flows, invariants, security architecture (if exists). Falls back to `draft/architecture.md` for legacy projects.
@@ -555,6 +564,7 @@ New track auto-detects the track type from the description and dialogue:
555
564
  #### Specification Creation (Feature)
556
565
 
557
566
  Engages in dialogue to understand scope before generating `spec.md`:
567
+
558
568
  - **What** — Exact scope and boundaries
559
569
  - **Why** — Business/user value
560
570
  - **Acceptance criteria** — How we know it's done
@@ -564,6 +574,7 @@ Engages in dialogue to understand scope before generating `spec.md`:
564
574
  #### Specification Creation (Bug / RCA)
565
575
 
566
576
  For bugs, incidents, and Jira-sourced issues. Focused investigation, not broad exploration:
577
+
567
578
  - **Symptoms** — Exact error, affected users/flows, frequency
568
579
  - **Reproduction** — Steps to trigger, environment conditions
569
580
  - **Blast Radius** — What's broken AND what's not (scopes the investigation)
@@ -575,6 +586,7 @@ The spec is presented for approval and iterated until the developer is satisfied
575
586
  #### Plan Creation
576
587
 
577
588
  Based on the approved spec, generates a phased task breakdown in `plan.md`:
589
+
578
590
  - **Feature tracks:** Tasks organized into phases (Foundation → Implementation → Integration → Polish)
579
591
  - **Bug tracks:** Fixed 3-phase structure: Investigate & Reproduce → Root Cause Analysis → Fix & Verify. Includes an RCA Log table for tracking hypotheses.
580
592
  - Each task specifies target files and test files
@@ -586,6 +598,7 @@ Also creates `metadata.json` (status tracking) and registers the track in `draft
586
598
  #### Track ID
587
599
 
588
600
  Auto-generated kebab-case from the description:
601
+
589
602
  - Full description converted to lowercase
590
603
  - Spaces replaced with hyphens
591
604
  - Special characters removed
@@ -620,6 +633,7 @@ Implements tasks from the active track's plan, following the TDD workflow when e
620
633
  #### Task Selection
621
634
 
622
635
  Scans `plan.md` for the first uncompleted task:
636
+
623
637
  - `[ ]` Pending — picks this one
624
638
  - `[~]` In Progress — resumes this one
625
639
  - `[x]` Completed — skips
@@ -668,6 +682,7 @@ This keeps `/draft:implement` as the common entry point while preserving explici
668
682
  #### Phase Boundary Review
669
683
 
670
684
  When all tasks in a phase are `[x]`, a three-stage review is triggered:
685
+
671
686
  1. **Stage 1: Automated Validation** — Fast static checks (architecture conformance, dead code, circular dependencies, OWASP security, performance anti-patterns)
672
687
  2. **Stage 2: Spec Compliance** — Verify all requirements for the phase are implemented
673
688
  3. **Stage 3: Code Quality** — Verify patterns, error handling, test quality; classify issues as Critical/Important/Minor
@@ -692,6 +707,7 @@ When all phases complete: update `plan.md`, `metadata.json`, and `draft/tracks.m
692
707
  ### `/draft:status` — Show Progress
693
708
 
694
709
  Displays a comprehensive overview of project progress:
710
+
695
711
  - All active tracks with phase and task counts
696
712
  - Current task indicator
697
713
  - Module status (if `.ai-context.md` exists) with coverage percentages
@@ -789,6 +805,7 @@ Documents significant technical decisions with context, alternatives, and conseq
789
805
  #### When to Use
790
806
 
791
807
  Create an ADR during or after `/draft:plan` when making architectural decisions:
808
+
792
809
  - Adopting a new technology or framework
793
810
  - Changing system architecture or module boundaries
794
811
  - Selecting between multiple viable approaches with trade-offs
@@ -799,6 +816,7 @@ Skip ADRs for trivial decisions (variable naming, formatting) or reversible choi
799
816
  #### ADR Structure
800
817
 
801
818
  Each ADR contains:
819
+
802
820
  - **Context** — The issue or forces driving the decision (technical, business, organizational)
803
821
  - **Decision** — What we're proposing/doing, stated in active voice ("We will...")
804
822
  - **Alternatives Considered** — At least 2 alternatives with pros/cons and rejection rationale
@@ -885,6 +903,7 @@ When graph data exists, baseline review always includes blast-radius / hotspot i
885
903
  #### Track-Level Review
886
904
 
887
905
  Reviews a track's implementation against its spec.md and plan.md:
906
+
888
907
  - **Stage 1 (Automated Validation):** Fast, static checks for structural flaws (dead code, circular dependencies, OWASP secrets, N+1 patterns).
889
908
  - **Stage 2 (Spec Compliance):** Verifies all functional requirements and acceptance criteria are met.
890
909
  - **Stage 3 (Code Quality):** Evaluates architecture, error handling, testing, and maintainability.
@@ -894,6 +913,7 @@ Extracts commit SHAs from plan.md to determine diff range. Supports fuzzy track
894
913
  #### Project-Level Review
895
914
 
896
915
  Reviews arbitrary changes (static validation + code quality only, no spec compliance):
916
+
897
917
  - `project` — uncommitted changes
898
918
  - `files <pattern>` — specific file patterns
899
919
  - `commits <range>` — commit range
@@ -963,6 +983,7 @@ Handles mid-track requirement changes without losing work. Analyzes the impact o
963
983
  #### When to Use
964
984
 
965
985
  Use when requirements shift after a track is already in progress:
986
+
966
987
  - A stakeholder changes scope mid-sprint
967
988
  - A dependency constraint forces a pivot
968
989
  - New information invalidates part of the original spec
@@ -992,6 +1013,7 @@ Use when requirements shift after a track is already in progress:
992
1013
  Draft supports granular pre-implementation design for complex projects. **Architecture mode is automatically enabled when `draft/tracks/<id>/.ai-context.md` exists** (created by `/draft:decompose`). Falls back to `draft/tracks/<id>/architecture.md` for legacy projects.
993
1014
 
994
1015
  **How it works:**
1016
+
995
1017
  1. Run `/draft:decompose` on a track → Creates `draft/tracks/<id>/architecture.md` (and derived `.ai-context.md`)
996
1018
  2. Run `/draft:implement` → Automatically detects `architecture.md` and enables architecture features
997
1019
  3. Features: Story writing, Execution State design, Function Skeletons, ~200-line chunk reviews
@@ -1071,19 +1093,21 @@ Coverage complements TDD — TDD is the process (write test, implement, refactor
1071
1093
  ### When to Use Architecture Mode
1072
1094
 
1073
1095
  **Good fit:**
1096
+
1074
1097
  - Multi-module features with component dependencies
1075
1098
  - New projects where architecture decisions haven't been made
1076
1099
  - Complex algorithms or data transformations
1077
1100
  - Teams wanting maximum review granularity
1078
1101
 
1079
1102
  **Overkill:**
1103
+
1080
1104
  - Simple features touching 1-2 files
1081
1105
  - Bug fixes with clear scope
1082
1106
  - Configuration changes
1083
1107
 
1084
1108
  ### Workflow with Architecture Mode
1085
1109
 
1086
- ```
1110
+ ```text
1087
1111
  /draft:init
1088
1112
  │ (creates draft/architecture.md + draft/.ai-context.md for brownfield)
1089
1113
 
@@ -1115,6 +1139,7 @@ Sync tracks to Jira via the unified router:
1115
1139
  `/draft:jira preview` → review/edit export → `/draft:jira create`
1116
1140
 
1117
1141
  Story points are auto-calculated from task count:
1142
+
1118
1143
  - 1-2 tasks = 1 point
1119
1144
  - 3-4 tasks = 2 points
1120
1145
  - 5-6 tasks = 3 points
@@ -4,11 +4,12 @@
4
4
 
5
5
  ---
6
6
 
7
- This is a self-contained, callable procedure for generating `draft/.ai-context.md` from `draft/architecture.md`.
7
+ This is a self-contained, callable procedure for generating `draft/.ai-context.md` from `draft/architecture.md`.
8
8
 
9
9
  **Critical fidelity requirement**: The condensation must faithfully preserve the core operational models (workflows, lifecycles, state machines) from architecture.md §3 "Primary Control & Data Flows", along with invariants (§2) and extension points (§8). These behavioral models are the highest-value content for downstream coding accuracy.
10
10
 
11
11
  **Mapping (architecture.md → .ai-context.md)** (modern 10-section graph-primary):
12
+
12
13
  - Primary Control & Data Flows (§3) → `## GRAPH:OPERATIONAL` + GRAPH:DATAFLOW (states, transitions, error/recovery paths in compact form)
13
14
  - Module & Dependency Map (§4) + hotspots → `GRAPH:MODULE-HOTSPOTS`, `GRAPH:FAN-IN`, `GRAPH:PROTO-MAP` etc.
14
15
  - Critical Invariants (§2) → INVARIANTS
@@ -18,14 +19,14 @@ Any skill that mutates `architecture.md` should execute this subroutine afterwar
18
19
 
19
20
  **Called by:** `/draft:init`, `/draft:init refresh`, `/draft:implement`, `/draft:decompose`, `/draft:coverage`
20
21
 
21
- ### Inputs
22
+ ## Inputs
22
23
 
23
24
  | Input | Path | Description |
24
25
  |-------|------|-------------|
25
26
  | architecture.md | `draft/architecture.md` | Comprehensive human-readable engineering reference (source of truth) |
26
27
  | schema.yaml | `draft/graph/schema.yaml` | Graph metrics for tier computation (optional — skip if absent) |
27
28
 
28
- ### Outputs
29
+ ## Outputs
29
30
 
30
31
  | Output | Path | Description |
31
32
  |--------|------|-------------|
@@ -34,7 +35,7 @@ Any skill that mutates `architecture.md` should execute this subroutine afterwar
34
35
 
35
36
  **Note:** `.ai-profile.md` generation is a separate step (the Profile Generation Subroutine defined in `skills/init/SKILL.md`). The Condensation Subroutine generates `.ai-context.md` only. Skills that call this subroutine should also trigger profile regeneration if `draft/.ai-profile.md` exists.
36
37
 
37
- ### Target Size
38
+ ## Target Size
38
39
 
39
40
  Compute tier from `draft/graph/schema.yaml` after graph build:
40
41
 
@@ -55,21 +56,22 @@ If `schema.yaml` does not exist: default to tier 2 (180–280 lines).
55
56
  - Below tier minimum: incomplete condensation — ensure all sections are represented
56
57
  - Above tier maximum: insufficient compression — apply prioritization rules below
57
58
 
58
- ### Procedure
59
+ ## Procedure
59
60
 
60
- #### Step 1: Read Source
61
+ ### Step 1: Read Source
61
62
 
62
63
  Read the full contents of `draft/architecture.md`. Extract the YAML frontmatter metadata block — it will be reused (with updated `generated_by` and `generated_at`) for the output file.
63
64
 
64
- #### Step 2: Write YAML Frontmatter
65
+ ### Step 2: Write YAML Frontmatter
65
66
 
66
67
  Start `draft/.ai-context.md` with a stable frontmatter block. Git state is centralized in `draft/metadata.json` — do NOT copy `git.*` or `synced_to_commit` from `architecture.md` into this file. Set:
68
+
67
69
  - `project`: from `architecture.md` frontmatter
68
70
  - `module`: from `architecture.md` frontmatter (usually `root`)
69
71
  - `generated_by`: the calling command (e.g., `draft:init`, `draft:implement`)
70
72
  - `generated_at`: current ISO 8601 timestamp
71
73
 
72
- #### Step 3: Transform Sections
74
+ ### Step 3: Transform Sections
73
75
 
74
76
  Transform each `architecture.md` section into machine-optimized format using this mapping:
75
77
 
@@ -86,28 +88,32 @@ Transform each `architecture.md` section into machine-optimized format using thi
86
88
  | §9 Graph Coverage Gaps | GRAPH:GAPS | Bullet list of known limitations |
87
89
  | §10 Relationship to Other Docs | META:DOCS | Pointer map to authoritative files |
88
90
 
89
- #### Step 3.5: Generate Graph Summary Sections
91
+ ### Step 3.5: Generate Graph Summary Sections
90
92
 
91
93
  If `draft/graph/schema.yaml` exists, generate these sections via live engine queries.
92
94
 
93
95
  **GRAPH:MODULES** (tier ≥ 2 only):
96
+
94
97
  - Query: `scripts/tools/graph-arch.sh --repo . | jq '.packages[]'` (each has `name`, `node_count`, `fan_in`, `fan_out`)
95
98
  - Format: `{name}|{node_count} nodes|fan_in:{fan_in} fan_out:{fan_out}`
96
99
  - Order by `node_count` descending
97
100
  - Omit this section entirely for tier-1 codebases (≤5 modules) where Component Graph is sufficient
98
101
 
99
102
  **GRAPH:HOTSPOTS** (all tiers):
103
+
100
104
  - Query: `scripts/tools/hotspot-rank.sh --repo . --top 10`; take top 10 results
101
105
  - Format: `{name}|fanIn:{fanIn}` (use `id` for disambiguation when names collide)
102
106
  - Always include regardless of tier
103
107
 
104
108
  **GRAPH:CYCLES** (all tiers):
109
+
105
110
  - Run `scripts/tools/cycle-detect.sh --repo .`; read `.cycles[]` (each is an array of qualified symbol names)
106
111
  - Output `None ✓` if empty
107
112
  - Otherwise output each cycle on its own line: `"A → B → C → A"`
108
113
  - Always include — absence is positive signal that the call graph is acyclic
109
114
 
110
115
  **GRAPH:MODULE-HOTSPOTS** (tier ≥ 3 only):
116
+
111
117
  - Query: `scripts/tools/hotspot-rank.sh --repo .`; group results by the package segment of each `id` (the qualified name minus the leaf symbol)
112
118
  - For each module: take its top 3 symbols by `fanIn`, format as indented lines under the module name
113
119
  - Format: `{module}: {name}|fanIn:{N}` with subsequent symbols indented to align
@@ -115,18 +121,20 @@ If `draft/graph/schema.yaml` exists, generate these sections via live engine que
115
121
  - Omit modules with no hotspot entries; omit entire section for tier 1–2 (covered by global GRAPH:HOTSPOTS)
116
122
 
117
123
  **GRAPH:FAN-IN** (tier ≥ 3 only):
124
+
118
125
  - Query: `scripts/tools/graph-arch.sh --repo . | jq '.packages[]'`, use the `fan_in` field per module
119
126
  - Format: `{name}|fanIn:{fan_in}|fanOut:{fan_out}`
120
127
  - Order by `fan_in` descending; include only modules with `fan_in ≥ 2`; cap at 15 rows
121
128
  - Omit entire section for tier 1–2 (trivially small graph)
122
129
 
123
130
  **GRAPH:PROTO-MAP** (only when routes are non-empty):
131
+
124
132
  - Query: `scripts/tools/graph-arch.sh --repo . | jq '.routes[]'` (each has `method`, `path`, `handler`)
125
133
  - Format: `{method} {path} → {handler}`
126
134
  - One line per route
127
135
  - Omit entire section if `.routes` is empty — do not write an empty section
128
136
 
129
- #### Step 4: Apply Compression
137
+ ### Step 4: Apply Compression
130
138
 
131
139
  - Remove all prose paragraphs — use structured key-value pairs instead
132
140
  - Remove Mermaid syntax — use text-based graph notation (`├─`, `-->`, `-[proto]->`)
@@ -134,7 +142,7 @@ If `draft/graph/schema.yaml` exists, generate these sections via live engine que
134
142
  - Abbreviate common words: `fn`=function, `ret`=returns, `cfg`=config, `impl`=implementation, `req`=required, `opt`=optional, `dep`=dependency, `auth`=authentication, `authz`=authorization
135
143
  - Use symbols: `@`=at/in file, `->`=calls/leads-to, `|`=column separator, `?`=optional, `!`=required/critical
136
144
 
137
- #### Step 5: Prioritize Content
145
+ ### Step 5: Prioritize Content
138
146
 
139
147
  If the output exceeds the tier maximum, cut sections in this order (bottom = cut first):
140
148
 
@@ -154,7 +162,7 @@ If the output exceeds the tier maximum, cut sections in this order (bottom = cut
154
162
  | 6 | CONFIG | Can abbreviate to `critical:Y` entries only |
155
163
  | 7 (cut first) | VOCAB | Can abbreviate to 10 most important terms |
156
164
 
157
- #### Step 6: Quality Check
165
+ ### Step 6: Quality Check
158
166
 
159
167
  Before writing `draft/.ai-context.md`, verify:
160
168
 
@@ -171,16 +179,16 @@ Before writing `draft/.ai-context.md`, verify:
171
179
  - [ ] GRAPH:PROTO-MAP present when engine reports non-empty routes (omit entirely if no protos)
172
180
  - [ ] YAML frontmatter metadata is present at the top
173
181
 
174
- #### Step 7: Write Output
182
+ ### Step 7: Write Output
175
183
 
176
184
  Write the completed content to `draft/.ai-context.md`.
177
185
 
178
- #### Step 8: Normalise Whitespace
186
+ ### Step 8: Normalise Whitespace
179
187
 
180
188
  After writing both output files, strip trailing whitespace and blank lines at EOF to prevent GitHub upload failures. Resolve the script via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)):
181
189
 
182
190
  ```bash
183
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
191
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
184
192
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
185
193
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
186
194
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -189,9 +197,10 @@ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
189
197
 
190
198
  This is idempotent — run it unconditionally.
191
199
 
192
- ### Example Transformation
200
+ ## Example Transformation
193
201
 
194
202
  **architecture.md input:**
203
+
195
204
  ````markdown
196
205
  ### 4.1 High-Level Topology
197
206
 
@@ -208,7 +217,8 @@ flowchart TD
208
217
  ````
209
218
 
210
219
  **.ai-context.md output:**
211
- ```
220
+
221
+ ```text
212
222
  ## GRAPH:COMPONENTS
213
223
  AuthService
214
224
  ├─API: handles HTTP requests
@@ -219,7 +229,7 @@ AuthService
219
229
  AuthService.Logic -[PostgreSQL]-> UserDB
220
230
  ```
221
231
 
222
- ### Reference for Other Skills
232
+ ## Reference for Other Skills
223
233
 
224
234
  Other skills that mutate `draft/architecture.md` should invoke this subroutine with:
225
235
  > "After updating `draft/architecture.md`, regenerate `draft/.ai-context.md` using the Condensation Subroutine defined in `core/shared/condensation.md`. If `draft/.ai-profile.md` exists, also regenerate it using the Profile Generation Subroutine defined in `skills/init/SKILL.md`."