@drafthq/draft 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/.claude-plugin/marketplace.json +38 -0
  2. package/.claude-plugin/plugin.json +26 -0
  3. package/LICENSE +21 -0
  4. package/README.md +272 -0
  5. package/bin/README.md +49 -0
  6. package/cli/bin/draft.js +13 -0
  7. package/cli/src/cli.js +113 -0
  8. package/cli/src/hosts/claude-code.js +46 -0
  9. package/cli/src/hosts/codex.js +33 -0
  10. package/cli/src/hosts/cursor.js +50 -0
  11. package/cli/src/hosts/index.js +24 -0
  12. package/cli/src/hosts/opencode.js +39 -0
  13. package/cli/src/installer.js +61 -0
  14. package/cli/src/lib/fsx.js +34 -0
  15. package/cli/src/lib/graph.js +23 -0
  16. package/cli/src/lib/log.js +32 -0
  17. package/cli/src/lib/paths.js +14 -0
  18. package/core/agents/architect.md +338 -0
  19. package/core/agents/debugger.md +193 -0
  20. package/core/agents/ops.md +104 -0
  21. package/core/agents/planner.md +158 -0
  22. package/core/agents/rca.md +314 -0
  23. package/core/agents/reviewer.md +256 -0
  24. package/core/agents/writer.md +110 -0
  25. package/core/guardrails/README.md +4 -0
  26. package/core/guardrails/code-quality.md +4 -0
  27. package/core/guardrails/dependency-triage.md +4 -0
  28. package/core/guardrails/design-norms.md +4 -0
  29. package/core/guardrails/language-standards.md +4 -0
  30. package/core/guardrails/review-checks.md +4 -0
  31. package/core/guardrails/secure-patterns.md +4 -0
  32. package/core/guardrails/security.md +4 -0
  33. package/core/guardrails.md +22 -0
  34. package/core/knowledge-base.md +127 -0
  35. package/core/methodology.md +1221 -0
  36. package/core/shared/condensation.md +224 -0
  37. package/core/shared/context-verify.md +44 -0
  38. package/core/shared/cross-skill-dispatch.md +127 -0
  39. package/core/shared/discovery-schema.md +75 -0
  40. package/core/shared/draft-context-loading.md +282 -0
  41. package/core/shared/git-report-metadata.md +106 -0
  42. package/core/shared/graph-query.md +239 -0
  43. package/core/shared/graph-usage-report.md +22 -0
  44. package/core/shared/jira-sync.md +170 -0
  45. package/core/shared/parallel-analysis.md +386 -0
  46. package/core/shared/parallel-fanout.md +10 -0
  47. package/core/shared/pattern-learning.md +146 -0
  48. package/core/shared/red-flags.md +58 -0
  49. package/core/shared/template-contract.md +22 -0
  50. package/core/shared/template-hygiene.md +10 -0
  51. package/core/shared/tool-resolver.md +10 -0
  52. package/core/shared/vcs-commands.md +97 -0
  53. package/core/shared/verification-gates.md +47 -0
  54. package/core/templates/CHANGELOG.md +70 -0
  55. package/core/templates/ai-context-export.md +8 -0
  56. package/core/templates/ai-context.md +270 -0
  57. package/core/templates/ai-profile.md +41 -0
  58. package/core/templates/architecture.md +203 -0
  59. package/core/templates/dependency-graph.md +103 -0
  60. package/core/templates/discovery.md +79 -0
  61. package/core/templates/guardrails.md +143 -0
  62. package/core/templates/hld.md +327 -0
  63. package/core/templates/intake-questions.md +403 -0
  64. package/core/templates/jira.md +119 -0
  65. package/core/templates/lld.md +283 -0
  66. package/core/templates/metadata.json +66 -0
  67. package/core/templates/plan.md +130 -0
  68. package/core/templates/product.md +110 -0
  69. package/core/templates/rca.md +86 -0
  70. package/core/templates/root-architecture.md +127 -0
  71. package/core/templates/root-product.md +53 -0
  72. package/core/templates/root-tech-stack.md +117 -0
  73. package/core/templates/service-index.md +55 -0
  74. package/core/templates/session-summary.md +8 -0
  75. package/core/templates/spec.md +165 -0
  76. package/core/templates/tech-matrix.md +101 -0
  77. package/core/templates/tech-stack.md +169 -0
  78. package/core/templates/track-architecture.md +311 -0
  79. package/core/templates/workflow.md +187 -0
  80. package/integrations/agents/AGENTS.md +24384 -0
  81. package/integrations/copilot/.github/copilot-instructions.md +24384 -0
  82. package/integrations/gemini/.gemini.md +26 -0
  83. package/package.json +53 -0
  84. package/scripts/fetch-memory-engine.sh +116 -0
  85. package/scripts/lib.sh +256 -0
  86. package/scripts/tools/_lib.sh +220 -0
  87. package/scripts/tools/adr-index.sh +117 -0
  88. package/scripts/tools/check-graph-usage-report.sh +95 -0
  89. package/scripts/tools/check-scope-conflicts.sh +139 -0
  90. package/scripts/tools/check-skill-line-caps.sh +115 -0
  91. package/scripts/tools/check-template-noop.sh +87 -0
  92. package/scripts/tools/check-track-hygiene.sh +230 -0
  93. package/scripts/tools/classify-files.sh +231 -0
  94. package/scripts/tools/cycle-detect.sh +75 -0
  95. package/scripts/tools/detect-test-framework.sh +135 -0
  96. package/scripts/tools/diff-templates-vs-tracks.sh +176 -0
  97. package/scripts/tools/emit-skill-metrics.sh +71 -0
  98. package/scripts/tools/fix-whitespace.sh +192 -0
  99. package/scripts/tools/freshness-check.sh +143 -0
  100. package/scripts/tools/git-metadata.sh +203 -0
  101. package/scripts/tools/graph-callers.sh +74 -0
  102. package/scripts/tools/graph-impact.sh +93 -0
  103. package/scripts/tools/graph-snapshot.sh +102 -0
  104. package/scripts/tools/hotspot-rank.sh +75 -0
  105. package/scripts/tools/manage-symlinks.sh +85 -0
  106. package/scripts/tools/mermaid-from-graph.sh +92 -0
  107. package/scripts/tools/migrate-track-frontmatter.sh +241 -0
  108. package/scripts/tools/parse-git-log.sh +135 -0
  109. package/scripts/tools/parse-reports.sh +114 -0
  110. package/scripts/tools/render-track.sh +145 -0
  111. package/scripts/tools/run-coverage.sh +153 -0
  112. package/scripts/tools/scan-markers.sh +144 -0
  113. package/scripts/tools/skill-caps.conf +24 -0
  114. package/scripts/tools/validate-frontmatter.sh +125 -0
  115. package/scripts/tools/verify-citations.sh +250 -0
  116. package/scripts/tools/verify-doc-anchors.sh +204 -0
  117. package/scripts/tools/verify-graph-binary.sh +154 -0
  118. package/skills/GRAPH.md +332 -0
  119. package/skills/adr/SKILL.md +374 -0
  120. package/skills/assist-review/SKILL.md +49 -0
  121. package/skills/bughunt/SKILL.md +668 -0
  122. package/skills/bughunt/references/regression-tests.md +399 -0
  123. package/skills/change/SKILL.md +267 -0
  124. package/skills/coverage/SKILL.md +336 -0
  125. package/skills/debug/SKILL.md +201 -0
  126. package/skills/decompose/SKILL.md +656 -0
  127. package/skills/deep-review/SKILL.md +326 -0
  128. package/skills/deploy-checklist/SKILL.md +254 -0
  129. package/skills/discover/SKILL.md +66 -0
  130. package/skills/docs/SKILL.md +42 -0
  131. package/skills/documentation/SKILL.md +197 -0
  132. package/skills/draft/SKILL.md +177 -0
  133. package/skills/draft/context-files.md +57 -0
  134. package/skills/draft/intent-mapping.md +37 -0
  135. package/skills/draft/quality-guide.md +51 -0
  136. package/skills/graph/SKILL.md +107 -0
  137. package/skills/impact/SKILL.md +86 -0
  138. package/skills/implement/SKILL.md +794 -0
  139. package/skills/incident-response/SKILL.md +245 -0
  140. package/skills/index/SKILL.md +848 -0
  141. package/skills/init/SKILL.md +1784 -0
  142. package/skills/init/references/architecture-spec.md +1259 -0
  143. package/skills/integrations/SKILL.md +53 -0
  144. package/skills/jira/SKILL.md +577 -0
  145. package/skills/jira/references/review.md +1322 -0
  146. package/skills/learn/SKILL.md +478 -0
  147. package/skills/new-track/SKILL.md +841 -0
  148. package/skills/ops/SKILL.md +57 -0
  149. package/skills/plan/SKILL.md +60 -0
  150. package/skills/quick-review/SKILL.md +216 -0
  151. package/skills/revert/SKILL.md +178 -0
  152. package/skills/review/SKILL.md +1114 -0
  153. package/skills/standup/SKILL.md +183 -0
  154. package/skills/status/SKILL.md +183 -0
  155. package/skills/tech-debt/SKILL.md +318 -0
  156. package/skills/testing-strategy/SKILL.md +195 -0
  157. package/skills/tour/SKILL.md +38 -0
  158. package/skills/upload/SKILL.md +117 -0
@@ -0,0 +1,332 @@
1
+ # Skill Dependency Graph
2
+
3
+ > Reference artifact mapping relationships between all Draft skills. Not a skill itself.
4
+ > Regenerate after adding/removing skills or changing cross-skill references.
5
+
6
+ ---
7
+
8
+ ## Two-Tier Architecture
9
+
10
+ ### Primary Workflow (4 commands)
11
+ ```
12
+ init → new-track → implement → review
13
+ ↑ |
14
+ └───────────┘ (auto-invoked at phase boundaries)
15
+ ```
16
+
17
+ ### Routed Core Workflows (5 routers)
18
+ The 5 routers (`/draft:plan`, `/draft:ops`, `/draft:docs`, `/draft:discover`, `/draft:jira`) provide intent analysis and dispatch to the leaf specialist skills. Primary commands and routers are the public surface; leaves remain for compatibility and direct scripting.
19
+
20
+ ### Specialist Leaf Commands
21
+ Grouped into subsystems dispatched by the routers (or primary commands).
22
+
23
+ ---
24
+
25
+ ## System Topology
26
+
27
+ ```mermaid
28
+ graph TD
29
+ subgraph "Foundation"
30
+ init["/draft:init"]
31
+ end
32
+
33
+ subgraph "Track Lifecycle"
34
+ new-track["/draft:new-track"]
35
+ implement["/draft:implement"]
36
+ change["/draft:change"]
37
+ revert["/draft:revert"]
38
+ status["/draft:status"]
39
+ end
40
+
41
+ subgraph "Code Quality"
42
+ quick-review["/draft:quick-review"]
43
+ review["/draft:review"]
44
+ deep-review["/draft:deep-review"]
45
+ bughunt["/draft:bughunt"]
46
+ coverage["/draft:coverage"]
47
+ testing-strategy["/draft:testing-strategy"]
48
+ learn["/draft:learn"]
49
+ end
50
+
51
+ subgraph "Debugging"
52
+ debug["/draft:debug"]
53
+ end
54
+
55
+ subgraph "Architecture"
56
+ decompose["/draft:decompose"]
57
+ adr["/draft:adr"]
58
+ index["/draft:index"]
59
+ tech-debt["/draft:tech-debt"]
60
+ impact["/draft:impact"]
61
+ end
62
+
63
+ subgraph "Operations"
64
+ deploy-checklist["/draft:deploy-checklist"]
65
+ incident-response["/draft:incident-response"]
66
+ standup["/draft:standup"]
67
+ end
68
+
69
+ subgraph "Authoring"
70
+ documentation["/draft:documentation"]
71
+ end
72
+
73
+ subgraph "Integration"
74
+ jira["/draft:jira"]
75
+ end
76
+
77
+ subgraph "DX"
78
+ assist-review["/draft:assist-review"]
79
+ tour["/draft:tour"]
80
+ end
81
+
82
+ subgraph "Navigation"
83
+ draft["/draft"]
84
+ end
85
+
86
+ subgraph "Routed Core Workflows"
87
+ plan["/draft:plan"]
88
+ ops["/draft:ops"]
89
+ docs["/draft:docs"]
90
+ discover["/draft:discover"]
91
+ jira["/draft:jira"]
92
+ end
93
+
94
+ %% Foundation dependencies
95
+ init --> new-track
96
+ init --> learn
97
+ init --> adr
98
+ init --> bughunt
99
+ init --> index
100
+ init --> status
101
+ init --> deep-review
102
+ init --> debug
103
+ init --> tech-debt
104
+ init --> incident-response
105
+ init --> documentation
106
+ init --> standup
107
+
108
+ %% Router dispatch (primary entry for specialists)
109
+ plan --> new-track
110
+ plan --> decompose
111
+ plan --> adr
112
+ plan --> "tech-debt"
113
+ plan --> change
114
+ ops --> deploy-checklist
115
+ ops --> incident-response
116
+ ops --> standup
117
+ ops --> status
118
+ ops --> revert
119
+ docs --> documentation
120
+ discover --> debug
121
+ discover --> bughunt
122
+ discover --> quick-review
123
+ discover --> deep-review
124
+ discover --> coverage
125
+ discover --> testing-strategy
126
+ discover --> learn
127
+ discover --> index
128
+ discover --> tour
129
+ discover --> impact
130
+ discover --> assist-review
131
+ %% jira router handles preview/create/review internally
132
+
133
+ %% Track lifecycle
134
+ new-track --> implement
135
+ new-track --> change
136
+ new-track --> revert
137
+ new-track --> review
138
+ new-track --> coverage
139
+ new-track --> decompose
140
+ new-track --> jira %% via router
141
+ new-track --> status
142
+ new-track --> debug
143
+
144
+ %% Implementation flow
145
+ implement -.->|auto-invokes at phase boundary| review
146
+ implement --> debug
147
+ implement -.->|calls Condensation Subroutine| init
148
+
149
+ %% Quality chain
150
+ review -.->|with-bughunt flag| bughunt
151
+ review -.->|fast alternative| quick-review
152
+ coverage -.->|calls Condensation Subroutine| init
153
+ testing-strategy -.->|informs| coverage
154
+ testing-strategy -.->|informs| bughunt
155
+
156
+ %% Cross-skill dispatch (quality → specialists)
157
+ bughunt -.->|suggests| debug
158
+ deep-review -.->|suggests| tech-debt
159
+ deep-review -.->|suggests| adr
160
+ deep-review -.->|suggests| documentation
161
+
162
+ %% Integration chain
163
+ %% preview/create/review are now subcommands of the jira router
164
+ bughunt -.->|report feeds| jira
165
+ review -.->|report feeds| jira
166
+
167
+ %% Operations chain
168
+ incident-response -.->|post-incident| debug
169
+ incident-response -.->|timeline feeds| documentation
170
+ standup -.->|reads| status
171
+ deploy-checklist -.->|reads| testing-strategy
172
+
173
+ %% Authoring chain
174
+ documentation -.->|reads| deep-review
175
+
176
+ %% Architecture chain
177
+ tech-debt -.->|prioritized items feed| new-track
178
+ impact -.->|reads graph| new-track
179
+ impact -.->|reads graph| implement
180
+
181
+ %% Monorepo chain
182
+ init -.->|per-service| index
183
+ ```
184
+
185
+ ## Dependency Matrix
186
+
187
+ > Routers (`plan`, `ops`, `docs`, `discover`, `jira`) depend on their dispatched leaves and are the recommended public interface. Leaves list their direct deps.
188
+
189
+ | Skill | Requires | Required By | Shared Artifacts |
190
+ |-------|----------|-------------|-----------------|
191
+ | `init` | -- | all others | architecture.md, .ai-context.md, .ai-profile.md, product.md, tech-stack.md, guardrails.md, .state/* |
192
+ | `new-track` | init | implement, review, change, revert, coverage, decompose, jira, status, debug | spec.md, plan.md, metadata.json |
193
+ | `implement` | init, new-track | review (triggers at phase boundaries) | Modifies source code; regenerates .ai-context.md |
194
+ | `review` | init, new-track | implement (called at phase boundaries) | review-report-latest.md |
195
+ | `quick-review` | init | review (fast alternative) | quick-review-report.md |
196
+ | `bughunt` | init | review (optional), index (optional), jira (optional) | bughunt-report-latest.md |
197
+ | `deep-review` | init | -- | deep-review audit report |
198
+ | `coverage` | init, new-track | -- | Regenerates .ai-context.md |
199
+ | `testing-strategy` | init | coverage (informs), bughunt (informs) | testing-strategy.md |
200
+ | `debug` | init, new-track | implement (fix feeds back) | debug-report.md |
201
+ | `decompose` | init, new-track | implement (optional) | Updates architecture.md; regenerates .ai-context.md |
202
+ | `change` | init, new-track | -- | Modifies spec.md, plan.md |
203
+ | `revert` | init, new-track | -- | Updates tracks.md, git state |
204
+ | `status` | init | standup (reads) | Read-only (tracks.md, plan.md, metadata.json) |
205
+ | `learn` | init | -- | Updates guardrails.md (conventions, anti-patterns) |
206
+ | `adr` | init | deep-review (suggests) | Creates ADR files in draft/adrs/ |
207
+ | `tech-debt` | init | deep-review (suggests), new-track (feeds prioritized items) | draft/tech-debt-report-latest.md |
208
+ | `impact` | init, graph | new-track, implement | Reads graph; emits blast-radius reports |
209
+ | `deploy-checklist` | init | -- | deploy-checklist.md |
210
+ | `incident-response` | init | -- | incident-<timestamp>.md, postmortem-<timestamp>.md |
211
+ | `standup` | init | -- | standup summary (reads status, git log) |
212
+ | `documentation` | init | deep-review (suggests), incident-response (feeds) | Generated docs, runbooks |
213
+ | `index` | init (per-service) | -- | service-index.md, dependency-graph.md, tech-matrix.md |
214
+ | `jira` | new-track | -- | jira-export-latest.md (internal) |
215
+ | `assist-review` | init | -- | Inline PR review assistance |
216
+ | `tour` | init | -- | Read-only architecture walk |
217
+ | `draft` | -- | -- | Navigation only -- references all skills |
218
+
219
+ ## Execution Chains
220
+
221
+ ### Standard Development Flow
222
+ ```
223
+ init → new-track → implement → review → (git push + PR)
224
+ ↑ |
225
+ └───────────┘
226
+ (iterate at phase boundaries)
227
+ ```
228
+
229
+ ### Bug Fix Flow
230
+ ```
231
+ new-track (bug) → debug → implement → review
232
+ ↑ |
233
+ └──────────────────────┘ (iterate if fix incomplete)
234
+ ```
235
+
236
+ ### Incident Response Flow
237
+ ```
238
+ incident-response → debug → implement → review
239
+ |
240
+ └→ documentation (post-incident report)
241
+ ```
242
+
243
+ ### Operations Flow
244
+ ```
245
+ standup ←── status (reads tracks + git log)
246
+ deep-review ──→ tech-debt ──→ new-track (prioritized items)
247
+ ```
248
+
249
+ ### Monorepo Flow
250
+ ```
251
+ init (per-service) → index (at root) → aggregated context
252
+ ```
253
+
254
+ ### Quality Audit Flow
255
+ ```
256
+ init → quick-review (fast sanity check)
257
+ init → review (full three-stage)
258
+ init → bughunt (14-dimension sweep)
259
+ init → deep-review (module audit)
260
+ init → testing-strategy → coverage
261
+ init → decompose (optional pre-step for large modules)
262
+ ```
263
+
264
+ ### Jira Integration Flow
265
+ ```
266
+ new-track → jira (preview / create / review subcommands)
267
+
268
+ bughunt + review reports (optional enrichment)
269
+ ```
270
+
271
+ ### Learning Flow
272
+ ```
273
+ init → learn → (updates guardrails.md)
274
+
275
+ All quality skills read guardrails.md
276
+ (bughunt, review, deep-review, coverage, quick-review)
277
+ ```
278
+
279
+ ## Shared Subroutines
280
+
281
+ | Subroutine | Defined In | Called By |
282
+ |------------|-----------|----------|
283
+ | Condensation Subroutine (.ai-context.md regeneration) | `core/shared/condensation.md` | implement, decompose, coverage, index |
284
+ | Standard File Metadata (YAML frontmatter) | `init` | All skills that generate draft/ files |
285
+ | Three-Stage Review | `review` | implement (at phase boundaries) |
286
+ | Signal Classification | `init` | init refresh, index (future) |
287
+ | Pattern Learning | `core/shared/pattern-learning.md` | learn, bughunt, review, deep-review (updates guardrails.md) |
288
+ | Context Loading | `core/shared/draft-context-loading.md` | All skills requiring draft/ context |
289
+ | Cross-Skill Dispatch | `core/shared/cross-skill-dispatch.md` | bughunt, deep-review, implement, review |
290
+ | Jira Sync | `core/shared/jira-sync.md` | bughunt, review, implement (when ticket linked) |
291
+ | Graph Query | `core/shared/graph-query.md` | init, implement, bughunt, review, debug, decompose, index, impact |
292
+ | Graph Mermaid | `scripts/tools/mermaid-from-graph.sh` | init (injects module-deps + proto-map into architecture.md) |
293
+
294
+ ## Artifact Flow
295
+
296
+ ```
297
+ ┌─────────────────────────────────────────────┐
298
+ │ draft/.state/ │
299
+ │ freshness.json signals.json run-memory │
300
+ └──────────────────┬──────────────────────────┘
301
+ │ read by refresh
302
+ ┌──────────────────▼──────────────────────────┐
303
+ │ draft/ │
304
+ init ──────────► │ architecture.md ──► .ai-context.md │
305
+ │ product.md tech-stack.md guardrails.md │
306
+ │ workflow.md tracks.md tech-debt.md │
307
+ │ graph/ (module-graph, hotspots, proto, │
308
+ │ module-deps.mermaid, proto-map..) │
309
+ └──────────────────┬──────────────────────────┘
310
+ │ read by all skills
311
+ ┌───────────────────────────┼───────────────────────┐
312
+ ▼ ▼ ▼
313
+ new-track bughunt learn
314
+ ┌──────────┐ ┌────────────┐ ┌──────────┐
315
+ │ spec.md │ │ report.md │ │guardrails│
316
+ │ plan.md │ └─────┬──────┘ │ update │
317
+ │metadata │ │ └──────────┘
318
+ └────┬─────┘ │
319
+ │ ┌────┴─────┐
320
+ ▼ ▼ ▼
321
+ implement jira debug
322
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
323
+ │ code │ │export.md │ │report.md │
324
+ │ changes │ └────┬─────┘ └──────────┘
325
+ └────┬─────┘ │
326
+ │ ▼
327
+ ▼ (preview/create/review)
328
+ review ┌──────────┐
329
+ ┌──────────┐ │Jira API │
330
+ │report.md │ └──────────┘
331
+ └──────────┘
332
+ ```
@@ -0,0 +1,374 @@
1
+ ---
2
+ name: adr
3
+ description: Create and manage Architecture Decision Records. Documents significant technical decisions with context, alternatives, and consequences. Also supports evaluate (assess proposals) and design (system design) modes.
4
+ ---
5
+
6
+ # Architecture Decision Records
7
+
8
+ You are creating or managing Architecture Decision Records (ADRs) for this project.
9
+
10
+ ## Red Flags - STOP if you're:
11
+
12
+ - Creating an ADR without understanding the decision context
13
+ - Documenting trivial decisions that don't warrant an ADR (e.g., variable naming)
14
+ - Writing an ADR after the fact without capturing the original reasoning
15
+ - Listing alternatives without genuine pros/cons analysis
16
+ - Skipping the "Consequences" section (the most valuable part)
17
+ - Not checking existing ADRs for conflicts or superseded decisions
18
+
19
+ **ADRs capture WHY, not just WHAT. Every decision needs alternatives considered.**
20
+
21
+ ---
22
+
23
+ ## Pre-Check
24
+
25
+ 1. Verify Draft is initialized:
26
+ ```bash
27
+ ls draft/ 2>/dev/null
28
+ ```
29
+
30
+ If `draft/` doesn't exist:
31
+ - Tell user: "Project not initialized. Run `/draft:init` first."
32
+ - Stop here.
33
+
34
+ 2. Check for existing ADR directory:
35
+ ```bash
36
+ ls draft/adrs/ 2>/dev/null
37
+ ```
38
+
39
+ If `draft/adrs/` doesn't exist, create it:
40
+ ```bash
41
+ mkdir -p draft/adrs
42
+ ```
43
+
44
+ ## Step 1: Parse Arguments
45
+
46
+ Check for arguments:
47
+ - `/draft:adr` — Interactive mode: ask about the decision
48
+ - `/draft:adr "decision title"` — Create ADR with given title
49
+ - `/draft:adr list` — List all existing ADRs
50
+ - `/draft:adr supersede <number>` — Mark an ADR as superseded
51
+
52
+ ### List Mode
53
+
54
+ If argument is `list`:
55
+ 1. Prefer the deterministic `adr-index.sh` wrapper for the listing — it returns a structured JSON `{adrs:[{id,title,date,status,path,related_tracks}]}` derived from each ADR's frontmatter. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
56
+ ```bash
57
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
58
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
59
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
60
+ if [ -x "$DRAFT_TOOLS/adr-index.sh" ]; then
61
+ bash "$DRAFT_TOOLS/adr-index.sh" --root draft/adrs
62
+ else
63
+ ls draft/adrs/ # fallback: enumerate files manually
64
+ fi
65
+ ```
66
+ 2. Display summary table:
67
+
68
+ ```
69
+ Architecture Decision Records
70
+
71
+ | # | Title | Status | Date |
72
+ |---|-------|--------|------|
73
+ | 001 | Use PostgreSQL for primary storage | Accepted | 2026-01-15 |
74
+ | 002 | Adopt event-driven architecture | Proposed | 2026-02-01 |
75
+ | 003 | Replace REST with GraphQL | Superseded by #005 | 2026-02-03 |
76
+ ```
77
+
78
+ Stop here after listing.
79
+
80
+ ### Supersede Mode
81
+
82
+ If argument is `supersede <number>`:
83
+ 1. Read the ADR file `draft/adrs/<number>-*.md`
84
+ 2. Change status from `Accepted` to `Superseded by ADR-<new_number>`
85
+ 3. In the OLD ADR's References section, add: "Superseded by ADR-<new_number>"
86
+ 4. Ask what new ADR supersedes it, or create the new one
87
+ 5. In the NEW ADR's References section, add: "Supersedes ADR-<old_number>"
88
+ 6. Stop here after updating.
89
+
90
+ ### Evaluate Mode
91
+
92
+ If argument starts with `evaluate`:
93
+ - `/draft:adr evaluate <proposal or description>` — Evaluate a design proposal
94
+
95
+ 1. Read the proposal (from arguments, pasted text, file path, or ask user to describe)
96
+ 2. Load project context: `draft/tech-stack.md`, `draft/.ai-context.md`, `draft/architecture.md`
97
+ 3. Check existing ADRs in `draft/adrs/` for related decisions
98
+ 4. Evaluate against six dimensions:
99
+ - **Architecture alignment:** Does it fit current patterns?
100
+ - **Tech stack consistency:** Does it introduce technology not in tech-stack.md?
101
+ - **Invariant impact:** Does it affect critical invariants from .ai-context.md?
102
+ - **Scalability:** How does it scale with data/users/team growth?
103
+ - **Operational complexity:** What new operational burden does it add?
104
+ - **Team familiarity:** Does the team have experience with this approach?
105
+
106
+ 5. Output evaluation report (do not save to file — display directly):
107
+
108
+ ```
109
+ # Design Evaluation: <Title>
110
+
111
+ ## Summary
112
+ [1-2 sentence assessment]
113
+
114
+ ## Alignment Analysis
115
+ | Dimension | Assessment | Notes |
116
+ |-----------|------------|-------|
117
+ | Architecture alignment | ✅ Aligned / ⚠️ Partial / ❌ Conflict | [detail] |
118
+ | Tech stack consistency | ✅/⚠️/❌ | [detail] |
119
+ | Invariant impact | ✅/⚠️/❌ | [detail] |
120
+ | Scalability | ✅/⚠️/❌ | [detail] |
121
+ | Operational complexity | ✅/⚠️/❌ | [detail] |
122
+ | Team familiarity | ✅/⚠️/❌ | [detail] |
123
+
124
+ ## Risks
125
+ - [Risk and mitigation strategy]
126
+
127
+ ## Recommendation
128
+ [Accept as-is / Accept with modifications / Reconsider approach / Reject — with reasoning]
129
+
130
+ ## Next Steps
131
+ If this leads to a decision: `/draft:adr "<decision title>"` to document it
132
+ If this needs a full design: `/draft:adr design "<system>"` to design it
133
+ ```
134
+
135
+ Stop here after evaluation.
136
+
137
+ ### Design Mode
138
+
139
+ If argument starts with `design`:
140
+ - `/draft:adr design <system or component>` — Full system/component design
141
+
142
+ 1. Gather requirements:
143
+ - Ask user or extract from arguments: What does it need to do?
144
+ - **Functional requirements** — Features and behaviors
145
+ - **Non-functional requirements** — Scale, latency, availability, cost targets
146
+ - **Constraints** — Team size, timeline, existing tech stack (from `draft/tech-stack.md`)
147
+
148
+ 2. Load project context: same as ADR creation (Step 3 of main flow)
149
+
150
+ 3. Design using 5-section framework:
151
+
152
+ **Section 1: Requirements**
153
+ - Functional requirements (bulleted list)
154
+ - Non-functional requirements (table: dimension, target, rationale)
155
+ - Constraints and assumptions
156
+
157
+ **Section 2: High-Level Design**
158
+ - Component diagram (ASCII)
159
+ - Data flow description
160
+ - API contracts (key endpoints/interfaces)
161
+ - Storage choices with rationale
162
+
163
+ **Section 3: Deep Dive**
164
+ - Data model design (key entities and relationships)
165
+ - API endpoint design (REST/GraphQL/gRPC with examples)
166
+ - Caching strategy (what, where, TTL, invalidation)
167
+ - Queue/event design (if applicable)
168
+ - Error handling and retry logic
169
+
170
+ **Section 4: Scale & Reliability**
171
+ - Load estimation (requests/sec, data growth)
172
+ - Scaling strategy (horizontal vs vertical)
173
+ - Failover and redundancy
174
+ - Monitoring and alerting requirements
175
+
176
+ **Section 5: Trade-off Analysis**
177
+ - Key trade-offs made (table: decision, alternative, why this choice)
178
+ - What to revisit as the system grows
179
+ - Risks and mitigations
180
+
181
+ 4. Determine design document number using same ADR numbering (Step 4 of main flow)
182
+ 5. Save to `draft/adrs/<number>-design-<kebab-case-title>.md` with YAML frontmatter and git metadata (same format as ADR creation, Step 5)
183
+ 6. Present for review (same as Step 6 of main flow)
184
+
185
+ Stop here after design.
186
+
187
+ ## Step 2: Gather Decision Context
188
+
189
+ If in interactive mode (no title provided), ask:
190
+
191
+ 1. "What technical decision needs to be documented?"
192
+ 2. "What's the context? What forces are driving this decision?"
193
+ 3. "What alternatives did you consider?"
194
+
195
+ If title provided, proceed directly with the title.
196
+
197
+ ### 2.1 HLD Handoff (when invoked from a track context)
198
+
199
+ If an active track exists and `draft/tracks/<id>/hld.md` is present:
200
+
201
+ 1. Read HLD §Alternatives Considered table.
202
+ 2. If any row is marked `Promote to ADR? yes` and has not been promoted yet (no matching ADR exists), offer:
203
+ ```
204
+ Found 1 unpromoted alternative in <track>/hld.md:
205
+ - {alternative} — rejected because: {reason}
206
+ Promote to ADR? [Y/n]
207
+ ```
208
+ 3. When promoting:
209
+ - Pre-fill ADR §Context from HLD §Background and the §High-Level Design / Key Design Decisions row that drove this rejection.
210
+ - Pre-fill ADR §Decision from the HLD §Key Design Decision that was selected over this alternative.
211
+ - Pre-fill ADR §Alternatives Considered with the rejected alternative.
212
+ - Set frontmatter `originating_hld: draft/tracks/<id>/hld.md`.
213
+ 4. After ADR creation, edit HLD §Alternatives Considered table: change the `Promote to ADR?` cell to `ADR-<number>` (linking back). Surface the diff to the user for confirmation.
214
+
215
+ If invoked outside a track context, skip 2.1 and proceed with normal interactive flow.
216
+
217
+ ## Step 3: Load Project Context
218
+
219
+ Follow the base procedure in `core/shared/draft-context-loading.md`.
220
+
221
+ Read relevant Draft context:
222
+ - `draft/.ai-context.md` — Current architecture patterns, invariants, data paths, and constraints. Falls back to `draft/architecture.md` for legacy projects.
223
+ - `draft/tech-stack.md` — Current technology choices
224
+ - `draft/product.md` — Product requirements that influence the decision
225
+
226
+ Cross-reference the decision against existing context:
227
+ - Does it align with documented architecture patterns?
228
+ - Does it introduce a new technology not in tech-stack.md?
229
+ - Does it affect product requirements?
230
+
231
+ ## Step 4: Determine ADR Number
232
+
233
+ ```bash
234
+ # Extract the highest existing ADR number from filenames
235
+ ls draft/adrs/*.md 2>/dev/null | sed 's/.*\/\([0-9]*\)-.*/\1/' | sort -n | tail -1
236
+ ```
237
+
238
+ Next number = highest existing ADR number + 1, zero-padded to 3 digits (001, 002, ...). If no ADRs exist, start at 001.
239
+
240
+ Verify the target filename `draft/adrs/<number>-<kebab-case-title>.md` does not already exist. If collision, increment the number until a free slot is found.
241
+
242
+ ## Step 5: Create ADR File
243
+
244
+ **MANDATORY: Include YAML frontmatter with git metadata.** Gather git info first:
245
+
246
+ ```bash
247
+ git branch --show-current # LOCAL_BRANCH
248
+ git rev-parse --abbrev-ref @{upstream} 2>/dev/null || echo "none" # REMOTE/BRANCH
249
+ git rev-parse HEAD # FULL_SHA
250
+ git rev-parse --short HEAD # SHORT_SHA
251
+ git log -1 --format=%ci HEAD # COMMIT_DATE
252
+ git log -1 --format=%s HEAD # COMMIT_MESSAGE
253
+ git status --porcelain | head -1 | wc -l # 0 = clean, >0 = dirty
254
+ ```
255
+
256
+ Create `draft/adrs/<number>-<kebab-case-title>.md`:
257
+
258
+ ```markdown
259
+ ---
260
+ project: "{PROJECT_NAME}"
261
+ module: "root"
262
+ adr_number: <number>
263
+ generated_by: "draft:adr"
264
+ generated_at: "{ISO_TIMESTAMP}"
265
+ git:
266
+ branch: "{LOCAL_BRANCH}"
267
+ remote: "{REMOTE/BRANCH}"
268
+ commit: "{FULL_SHA}"
269
+ commit_short: "{SHORT_SHA}"
270
+ commit_date: "{COMMIT_DATE}"
271
+ commit_message: "{COMMIT_MESSAGE}"
272
+ dirty: {true|false}
273
+ synced_to_commit: "{FULL_SHA}"
274
+ # Optional — populated when ADR is promoted from a track HLD §Alternatives Considered row.
275
+ originating_hld: "{path/to/draft/tracks/<id>/hld.md or null}"
276
+ originating_track: "{<track_id> or null}"
277
+ ---
278
+
279
+ # ADR-<number>: <Title>
280
+
281
+ | Field | Value |
282
+ |-------|-------|
283
+ | **Branch** | `{LOCAL_BRANCH}` → `{REMOTE/BRANCH}` |
284
+ | **Commit** | `{SHORT_SHA}` — {COMMIT_MESSAGE} |
285
+ | **Generated** | {ISO_TIMESTAMP} |
286
+ | **Synced To** | `{FULL_SHA}` |
287
+
288
+ **Status:** Proposed
289
+ **Deciders:** [names or roles]
290
+
291
+ ## Context
292
+
293
+ [What is the issue that we're seeing that is motivating this decision or change?]
294
+ [What forces are at play (technical, business, organizational)?]
295
+
296
+ ## Decision
297
+
298
+ [What is the change that we're proposing and/or doing?]
299
+ [State the decision in active voice: "We will..."]
300
+
301
+ ## Alternatives Considered
302
+
303
+ ### Alternative 1: <name>
304
+ - **Pros:** [advantages]
305
+ - **Cons:** [disadvantages]
306
+ - **Why rejected:** [specific reason]
307
+
308
+ ### Alternative 2: <name>
309
+ - **Pros:** [advantages]
310
+ - **Cons:** [disadvantages]
311
+ - **Why rejected:** [specific reason]
312
+
313
+ ## Consequences
314
+
315
+ ### Positive
316
+ - [Benefit 1]
317
+ - [Benefit 2]
318
+
319
+ ### Negative
320
+ - [Trade-off 1]
321
+ - [Trade-off 2]
322
+
323
+ ### Risks
324
+ - [Risk and mitigation]
325
+
326
+ ## References
327
+
328
+ - [Link to relevant discussion, RFC, or documentation]
329
+ - [Related ADRs: ADR-xxx]
330
+ - [Originating HLD: draft/tracks/<id>/hld.md §Alternatives Considered] (only when promoted from a track)
331
+ ```
332
+
333
+ ## Step 6: Present for Review
334
+
335
+ Present the ADR to the user for review:
336
+
337
+ ```
338
+ ADR-<number> created: <title>
339
+ File: draft/adrs/<number>-<kebab-case-title>.md
340
+ Status: Proposed
341
+
342
+ Review the ADR and update status to "Accepted" when approved.
343
+ ```
344
+
345
+ ## Step 7: Update References (if applicable)
346
+
347
+ If the decision affects existing Draft context:
348
+
349
+ 1. **tech-stack.md** — If introducing or removing technology, note: "Consider updating draft/tech-stack.md to reflect this decision."
350
+ 2. **architecture.md** — If changing architectural patterns, note: "Consider updating `draft/architecture.md` to reflect this decision (`.ai-context.md` will be auto-refreshed via Condensation Subroutine)."
351
+ 3. **Superseded ADRs** — If this decision replaces a previous one, update the old ADR's status.
352
+
353
+ ## ADR Status Lifecycle
354
+
355
+ ```
356
+ Proposed → Accepted → [Deprecated | Superseded by ADR-xxx]
357
+ ```
358
+
359
+ - **Proposed** — Decision documented, awaiting review
360
+ - **Accepted** — Decision approved and in effect
361
+ - **Deprecated** — Decision no longer relevant (context changed)
362
+ - **Superseded** — Replaced by a newer decision (link to replacement)
363
+
364
+ ## Error Handling
365
+
366
+ **If no draft/ directory:**
367
+ - Tell user to run `/draft:init` first
368
+
369
+ **If ADR number conflict:**
370
+ - Increment to next available number
371
+ - Warn: "ADR-<number> already exists. Using ADR-<next>."
372
+
373
+ **If superseding non-existent ADR:**
374
+ - Warn: "ADR-<number> not found. Check `draft/adrs/` for valid ADR numbers."