@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,656 @@
1
+ ---
2
+ name: decompose
3
+ description: Decompose project or track into modules with dependency mapping. Project scope updates architecture.md and derives .ai-context.md. Track scope generates hld.md (always) and lld.md (when --lld or High-complexity module triggers it) — design-mandated artifacts that drive implement, deploy-checklist, and upload sign-off.
4
+ ---
5
+
6
+ # Decompose
7
+
8
+ You are decomposing a project or track into modules with clear responsibilities, dependencies, and implementation order.
9
+
10
+ ## MANDATORY GRAPH LOOKUP (read before any analysis)
11
+
12
+ When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Module identification (Step 3) and dependency mapping (Step 4) **start from the graph**:
13
+
14
+ 1. Load `draft/graph/architecture.json` (`.packages`) for the authoritative module list and fan-in/out.
15
+ 2. Load `draft/graph/hotspots.jsonl` to identify candidate modules to split.
16
+ 3. Use `scripts/tools/graph-callers.sh`/`graph-impact.sh` on demand for symbols/callers inside a candidate module.
17
+ 4. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate existing cycles before proposing new boundaries.
18
+
19
+ Filesystem `grep`/`find` for module discovery is only permitted **after** a documented graph miss, using the fallback sentence `Graph returned no match for <X>; falling back to grep.` and recorded in the Graph Usage Report.
20
+
21
+ ## Red Flags - STOP if you're:
22
+
23
+ See [shared red flags](../../core/shared/red-flags.md) — applies to all code-touching skills. In particular, the **Ground-Truth Red Flags** are load-bearing for decompose: HLD/LLD are design-mandated artifacts and TBD citations on Modified modules fail review.
24
+
25
+ **Template contract:** HLD/LLD/Plan emissions conform to
26
+ [core/shared/template-contract.md](../../core/shared/template-contract.md) and
27
+ [core/shared/template-hygiene.md](../../core/shared/template-hygiene.md). The
28
+ `_TBD_<field>_` sentinel convention replaces `Author1` / `xxx@example.com` /
29
+ `[name]` placeholders. After decompose runs, the verification gate chain in
30
+ [core/shared/verification-gates.md](../../core/shared/verification-gates.md)
31
+ must pass clean on the regenerated set. Plan.md must back-link to
32
+ `./discovery.md` Phase 0 (Hotspots row IDs) per
33
+ [core/shared/discovery-schema.md](../../core/shared/discovery-schema.md).
34
+
35
+ Skill-specific:
36
+ - Defining modules without understanding the codebase
37
+ - Creating modules with circular dependencies
38
+ - Making modules too large (>3 files, excluding test files) or too small (single function)
39
+ - Skipping dependency analysis
40
+ - Not waiting for developer approval at checkpoints
41
+ - Emitting `Citation: TBD` for a module marked `Status: Modified` or `Status: Existing` (see §Step 5 Mandatory Citation Gate below)
42
+ - Leaving HLD §Checklist sections (Performance / Scale / Security / Resiliency / Multi-tenancy / Upgrade / Cost) as raw `-` placeholders instead of structured TBD bullets (see §Step 5a Checklist Scaffolding)
43
+
44
+ ---
45
+
46
+ ## Standard File Metadata
47
+
48
+ **ALL generated files MUST include the standard YAML frontmatter.** This enables refresh tracking, sync verification, and traceability.
49
+
50
+ ### Gathering Git Information
51
+
52
+ Use the deterministic `git-metadata.sh` script (preferred) or the manual commands — both documented in [core/shared/git-report-metadata.md](../../core/shared/git-report-metadata.md), which contains the canonical resolver pattern for locating the script in any install layout. Both produce the same field set used in the YAML template below.
53
+
54
+ For track-scoped decomposition, also derive the human-readable track title used in the `hld.md` / `lld.md` H1:
55
+
56
+ - `{TRACK_TITLE}` — first-level heading text from the active track's `spec.md` (the `# ...` line). If `spec.md` has no H1, fall back to the `{TRACK_ID}`.
57
+
58
+ Also extract from `spec.md` frontmatter:
59
+ - `classification.criticality`, `classification.data_classification`, `classification.deployment_surface` — copy verbatim into hld.md frontmatter.
60
+ - `approvers.*` — pre-fill the HLD Approvals table (tech_leads, arb_leads, cloudops_leads, qa_leads, pm_leads) and LLD Approvals table (team_leads, tech_leads, qa). If a field is empty in spec.md, leave the table cell empty — do not invent names.
61
+
62
+ ### Metadata Template
63
+
64
+ Insert this **stable** YAML frontmatter at the top of every generated file. Git state lives in `tracks/<track_id>/metadata.json` — never in per-file frontmatter (WS-8).
65
+
66
+ ```yaml
67
+ ---
68
+ project: "{PROJECT_NAME}"
69
+ module: "{MODULE_NAME or 'root'}"
70
+ track_id: "{TRACK_ID or null}"
71
+ generated_by: "draft:decompose"
72
+ generated_at: "{ISO_TIMESTAMP}"
73
+ # Stable frontmatter only (WS-8). Ephemeral fields live in metadata.json
74
+ # and render via <!-- META:<key> --> directives.
75
+ links:
76
+ spec: "./spec.md"
77
+ ---
78
+ ```
79
+
80
+ > **Note**: `generated_by` uses `draft:command` format (not `/draft:command`) for cross-platform compatibility.
81
+ > After writing HLD/LLD, update `tracks/<track_id>/metadata.json` with current git state and `synced_to_commit`.
82
+
83
+ ---
84
+
85
+ ## Step 1: Determine Scope
86
+
87
+ Parse `$ARGUMENTS` for flags first, then strip them before interpreting the remaining text as scope:
88
+
89
+ - `--lld` → **LLD mode** — generate Section 6 (Low-Level Design) in addition to HLD. Strip from arguments before scope detection.
90
+
91
+ Scope detection (on stripped arguments):
92
+ - `project` or no argument with no active track → **Project-wide** decomposition → `draft/architecture.md` + `draft/.ai-context.md`
93
+ - Track ID or active track exists → **Track-scoped** decomposition → `draft/tracks/<id>/hld.md` (always) + `draft/tracks/<id>/lld.md` (when triggered)
94
+
95
+ **LLD auto-trigger:** Even without `--lld`, LLD is generated automatically when any module in Step 3 is marked `Complexity: High`. Tell the developer when this triggers: "One or more modules are High complexity — generating LLD automatically."
96
+
97
+ **No legacy `track-architecture.md`:** That artifact has been retired. New tracks always use `hld.md` (and `lld.md` when triggered). Existing tracks that have a `track-architecture.md` are not migrated automatically — leave them alone; new tracks get the new format.
98
+
99
+ ### Pre-Generation Sanity Checks (Track-Scoped Only)
100
+
101
+ Before Step 2, run these checks and prompt the developer when triggered. Do **not** silently proceed.
102
+
103
+ 1. **Spec readiness** — read `draft/tracks/<id>/spec.md` frontmatter and first 20 lines:
104
+ - If `spec.md` is missing → ERROR: "No spec.md for track `<id>`. Run `/draft:new-track` first." Halt.
105
+ - If `spec.md` contains `Status: [ ] Drafting` or `spec-draft.md` still exists → WARN: "Spec for `<id>` is still in draft. HLD generated against a draft spec will need rework. Continue anyway? [y/N]" — default No.
106
+ - If `classification.criticality` is unset or still placeholder (`{...}`) → WARN: "Classification not set in spec.md frontmatter — HLD Approvals gate (`/draft:upload`) will not engage correctly for high-criticality tracks. Continue? [y/N]".
107
+
108
+ 2. **Existing artifacts** — check what already exists:
109
+ - If `hld.md` exists → ASK: "`hld.md` already exists for `<id>`. (1) Overwrite, (2) Skip HLD and only generate LLD, (3) Cancel." Default (3).
110
+ - If `lld.md` exists and LLD will be regenerated → ASK same 3-way choice.
111
+
112
+ Only proceed to Step 2 after the developer resolves each prompt.
113
+
114
+ ## Step 2: Load Context
115
+
116
+ 1. Read `draft/product.md` for product understanding
117
+ 2. Read `draft/tech-stack.md` for technical patterns
118
+ 3. If track-scoped:
119
+ - Read track's `spec.md` for requirements
120
+ - Read track's `plan.md` for existing task breakdown
121
+
122
+ For brownfield projects, scan the existing codebase using these concrete steps:
123
+
124
+ ### Codebase Scanning Patterns
125
+
126
+ **Directory structure** — Map top-level organization:
127
+ ```bash
128
+ ls -d src/*/ lib/*/ app/*/ packages/*/ 2>/dev/null
129
+ ```
130
+
131
+ **Entry points** — Find main files and exports:
132
+ - Look for: `index.ts`, `main.ts`, `app.ts`, `mod.rs`, `__init__.py`, `main.go`
133
+ - Check `package.json` `main`/`exports` fields, `pyproject.toml` entry points, `go.mod` module path
134
+
135
+ **Existing module boundaries** — Identify by:
136
+ - Directory-per-feature patterns (e.g., `src/auth/`, `src/users/`)
137
+ - Package files (`package.json` in subdirs, `__init__.py`, `go` package declarations)
138
+ - Barrel exports (`index.ts` re-exporting from a directory)
139
+
140
+ **Dependency patterns** — Trace imports:
141
+ - Search for `import` / `require` / `from` statements across source files
142
+ - Identify which directories import from which other directories
143
+ - Flag cross-cutting imports (e.g., `utils/` imported everywhere)
144
+
145
+ **File type filters by language:**
146
+ | Language | Source Extensions | Config Files |
147
+ |----------|-------------------|--------------|
148
+ | TypeScript/JS | `*.ts`, `*.tsx`, `*.js`, `*.jsx` | `tsconfig.json`, `package.json` |
149
+ | Python | `*.py` | `pyproject.toml`, `setup.py`, `requirements.txt` |
150
+ | Go | `*.go` | `go.mod`, `go.sum` |
151
+ | Rust | `*.rs` | `Cargo.toml` |
152
+
153
+ **What to ignore:** `node_modules/`, `__pycache__/`, `target/`, `dist/`, `build/`, `.git/`, vendored dependencies. Always respect `.gitignore` and `.claudeignore`.
154
+
155
+ ### Graph-Accelerated Discovery (MANDATORY when `draft/graph/` exists)
156
+
157
+ When graph data is available, the graph is the **primary** (not optional) source for module discovery — manual scanning above is reserved for the graph-miss fallback path:
158
+
159
+ - **Module boundaries**: Read `draft/graph/architecture.json` (`.packages`, `.languages`) — module list with node counts and per-language file counts
160
+ - **Dependency edges**: Weighted inter-module dependencies with exact include counts — replaces manual import tracing
161
+ - **Cycle detection**: Circular dependency paths already computed — use for identifying tight coupling and decomposition candidates
162
+ - **Hotspots**: Load `draft/graph/hotspots.jsonl` — high-complexity files that may need further decomposition
163
+ - **Per-module detail**: query `scripts/tools/graph-callers.sh`/`graph-impact.sh` for symbol/call detail within modules of interest
164
+
165
+ This data is deterministic and exhaustive. The manual scanning recipes above only run **after** the graph misses on the concept the user named — and the miss must be reported in the Graph Usage Report footer. See [core/shared/graph-query.md](../../core/shared/graph-query.md) §Concept-to-Files Recipe.
166
+
167
+ ## Step 3: Module Identification
168
+
169
+ Propose a module breakdown through dialogue:
170
+
171
+ For each module, define:
172
+ - **Name** - Short, descriptive identifier
173
+ - **Responsibility** - One sentence: what this module owns
174
+ - **Files** - Expected source files (existing or to be created)
175
+ - **API Surface** - Public functions, classes, or interfaces
176
+ - **Dependencies** - Which other modules it imports from
177
+ - **Complexity** - Low / Medium / High
178
+
179
+ ### Module Guidelines (see `core/agents/architect.md`)
180
+
181
+ 1. Each module should have a single responsibility
182
+ 2. Target 1-3 files per module
183
+ 3. Every module needs a clear API boundary
184
+ 4. **Minimal Coupling** — communicate through interfaces, not internals
185
+ - Modules should be testable in isolation
186
+ - Each module typically contains: API, control flow, execution state, functions
187
+
188
+ ### CHECKPOINT (MANDATORY)
189
+
190
+ **STOP.** Present the module breakdown to the developer.
191
+
192
+ ```
193
+ ---
194
+ MODULE BREAKDOWN
195
+ ---
196
+ Scope: [Project / Track: <track-id>]
197
+
198
+ MODULE 1: [name]
199
+ Responsibility: [one sentence]
200
+ Files: [file list]
201
+ API: [public interface summary]
202
+ Dependencies: [none / module names]
203
+ Complexity: [Low/Medium/High]
204
+
205
+ MODULE 2: [name]
206
+ ...
207
+
208
+ ---
209
+ ```
210
+
211
+ **Wait for developer approval.** Developer may add, remove, rename, or reorganize modules.
212
+
213
+ ## Step 4: Dependency Mapping
214
+
215
+ After modules are approved:
216
+
217
+ 1. **Map dependencies** - For each module, list what it imports from other modules
218
+ 2. **Detect cycles** - If circular dependencies exist, propose how to break them (extract shared interface into new module)
219
+ 3. **Generate ASCII diagram** - Visual representation of dependency graph
220
+ 4. **Generate dependency table** - Tabular format for reference
221
+ 5. **Determine implementation order** - Topological sort (implement leaves first, then dependents)
222
+
223
+ ### CHECKPOINT (MANDATORY)
224
+
225
+ **STOP.** Present the dependency diagram and implementation order.
226
+
227
+ ```
228
+ ---
229
+ DEPENDENCY ANALYSIS
230
+ ---
231
+ DIAGRAM
232
+ ---
233
+ [auth] ──> [database]
234
+ │ │
235
+ └──> [config] <──┘
236
+
237
+ [logging] (no deps)
238
+
239
+ TABLE
240
+ ---
241
+ Module | Depends On | Depended By
242
+ ---------- | ----------------- | -----------------
243
+ logging | - | auth, database, config
244
+ config | logging | auth, database
245
+ database | config, logging | auth
246
+ auth | database, config | -
247
+
248
+ IMPLEMENTATION ORDER
249
+ ---
250
+ 1. logging (leaf - no dependencies)
251
+ 2. config (depends on: logging)
252
+ 3. database (depends on: config, logging)
253
+ 4. auth (depends on: database, config)
254
+
255
+ Parallel opportunities: config and database can start after logging.
256
+ ---
257
+ ```
258
+
259
+ **Wait for developer approval.**
260
+
261
+ ## Step 5: Generate Design Documents
262
+
263
+ Template selection depends on scope:
264
+
265
+ - **Project-wide** → `core/templates/architecture.md` (full 28-section engineering reference)
266
+ - **Track-scoped** → `core/templates/hld.md` (always) and `core/templates/lld.md` (when triggered)
267
+
268
+ **Output location:**
269
+ - Project-wide: Update `draft/architecture.md` with the module changes, then run the Condensation Subroutine (defined in `core/shared/condensation.md`) to regenerate `draft/.ai-context.md`.
270
+ - Track-scoped: write to `draft/tracks/<id>/hld.md` and (when triggered) `draft/tracks/<id>/lld.md`.
271
+
272
+ > **Context:** HLD and LLD are design-mandated review artifacts. HLD is approved by Technical Leads / Architecture Review Board / Cloud Operations / QA / PM Leads before significant implementation; LLD is approved by Team Leads / Technical Leads / QA before code review begins. `/draft:upload` gates `git upload` for high-criticality tracks on the HLD Approvals table being populated.
273
+
274
+ ### Step 5a: HLD Generation (Track-Scoped, Always)
275
+
276
+ Generate `draft/tracks/<id>/hld.md` from `core/templates/hld.md`. Populate every section that has a directive — do not ship placeholders.
277
+
278
+ **Frontmatter:**
279
+ - Copy git metadata from current repo state.
280
+ - Copy `classification.*` from `spec.md` frontmatter (criticality, data_classification, deployment_surface). The HLD's `links.*` block is statically correct in `core/templates/hld.md` — do not copy it from spec.md.
281
+
282
+ **Approvals table:** Pre-fill from `spec.md` `approvers.*` frontmatter. Empty values stay empty — do not invent names.
283
+
284
+ **§Background:** ½–1 page. Pull from `spec.md` §Problem Statement and §Background & Why Now. Tighten for HLD audience (focus on the "why now" and the system context).
285
+
286
+ **§Requirements:** Do not duplicate `spec.md`. Verify the link references resolve to actual sections in spec.md; if a section is missing, flag it.
287
+
288
+ **§High Level Design / Architecture:**
289
+ - **`<!-- GRAPH:track-component-diagram -->` slot:** Render Mermaid `flowchart TD` with three subgraphs — `Track` (modules in scope from Step 3), `Existing` (existing modules this track touches per integration edges), `External` (DB, queue, 3P APIs). Label edges with transport (HTTP / RPC / queue / direct call) when non-obvious.
290
+ - **Architecture narrative** (≤300 words). Explain how blackbox requirements map to the architecture. Name the architectural style. Justify from observable evidence.
291
+
292
+ **§High Level Design / UI Architecture Changes:** Populate only if the track touches UI; otherwise write `N/A — backend-only track.`
293
+
294
+ **§High Level Design / Key Design Decisions:** 2–5 bullet decisions, each with a one-sentence "Why:" referencing an observable constraint (latency budget, multi-tenant isolation requirement, regulatory compliance), not aesthetics.
295
+
296
+ **§High Level Design / Alternatives Considered:** Table format. Promote any non-trivial rejected alternative to a standalone ADR via `/draft:adr` and link both ways.
297
+
298
+ **§Detailed Design:**
299
+ - **`<!-- GRAPH:track-component-table -->` slot:** Render one row per module from Step 3. Columns: Module, Status (`New`/`Modified`/`Existing`), Files (count + comma list), Public API count, Fan-In, Fan-Out, Complexity (`Low`/`Medium`/`High`), Primary Deps, Citation (`path:line` of entry symbol).
300
+ - **Mandatory Citation Gate:** For every row whose Status is `Modified` or `Existing`, the Citation cell **MUST** resolve to a real `path:line` from a file you Read in this run. `TBD` is only legal for `Status: New` rows, and only when the planned file path is filled (e.g. `Citation: newscribe/server/ops/shuffle_memory_eligibility.h (planned)`). If a Modified-row Citation is unresolved, **halt** — Read the file, locate the entry symbol, and fill the cell before emitting the table. See [graph-query.md](../../core/shared/graph-query.md) §Ground-Truth Discipline rules G1 and G3.
301
+ - **Per-component subsection:** One `#### {Component Name}` block per module. Fill Responsibility, Status, Entry point (resolved `path:line` for Modified/Existing modules), Public API link to LLD, Whitebox requirements addressed (AC IDs from spec.md), Design notes (≤200 words).
302
+
303
+ **§Dependencies:**
304
+ - **`<!-- GRAPH:track-dependencies -->` slot:** Render rows per cross-module integration edge of kind `call`/`import`/`event`/`shared-schema`. Columns: Dependent Component, Edge Kind, Impact Assessment (Small/Medium/Large — graph fan-in heuristic: 1–2 = Small, 3–5 = Medium, 6+ = Large), Description, Citation. The Citation column is bound by the same Mandatory Citation Gate as the component table.
305
+
306
+ **§Intellectual Property, §Checklist, §Deployment, §Observability:** These are author-driven sections that the design author completes before the HLD is presented for approval. Decompose's job is to **scaffold structured TBD bullets**, not to invent claims and not to leave bare `-` placeholders.
307
+
308
+ #### Checklist Scaffolding (mandatory)
309
+
310
+ For `criticality: standard | high | mission-critical` tracks, replace bare `-` placeholders in HLD §Checklist with structured TBD bullets. This turns blank review-gate sections into a concrete punch-list. Bullets vary by section:
311
+
312
+ ```markdown
313
+ ### Performance
314
+ - [ ] **Latency budget (p50/p95/p99):** TBD — fill before HLD review
315
+ - [ ] **Throughput target:** TBD
316
+ - [ ] **Resource budget (CPU / RAM / IO per node):** TBD
317
+ - [ ] **Baseline measurement methodology:** TBD — name benchmark or production dashboard
318
+
319
+ ### Scale
320
+ - [ ] **Per-tenant / per-node limits:** TBD
321
+ - [ ] **Growth assumptions (1y / 3y):** TBD
322
+ - [ ] **Scaling axis (vertical / horizontal / partitioning):** TBD
323
+
324
+ ### Security
325
+ - [ ] **Threat model reference:** TBD — link STRIDE doc or write inline
326
+ - [ ] **Auth / authz changes:** TBD (none / list)
327
+ - [ ] **Data classification touched:** TBD
328
+ - [ ] **Secrets / credentials surface:** TBD (none / list)
329
+
330
+ ### Resiliency
331
+ - [ ] **Failure modes considered:** TBD
332
+ - [ ] **Crash / restart semantics:** TBD
333
+ - [ ] **Backpressure / circuit-breaker:** TBD
334
+ - [ ] **Rollback path:** TBD
335
+
336
+ ### Multi-tenancy
337
+ - [ ] **Tenant isolation invariants preserved:** TBD (or N/A — single-tenant)
338
+ - [ ] **Noisy-neighbor risks:** TBD
339
+
340
+ ### Upgrade
341
+ - [ ] **Forward compatibility (old reading new):** TBD
342
+ - [ ] **Backward compatibility (new reading old):** TBD
343
+ - [ ] **Mixed-version cluster behavior:** TBD
344
+ - [ ] **Migration / backfill required:** TBD
345
+
346
+ ### Flags and Controlled Rollout of Features
347
+ - [ ] **Master flag name (default value):** TBD
348
+ - [ ] **Cluster feature gate (if any):** TBD
349
+ - [ ] **Rollout phases:** TBD
350
+ - [ ] **Kill switch:** TBD
351
+
352
+ ### Cost Implications
353
+ - [ ] **Incremental CPU / RAM / IO / storage:** TBD
354
+ - [ ] **Cloud cost delta (if SaaS):** TBD or N/A
355
+ ```
356
+
357
+ For `criticality: low` quick tracks, the bare `-` placeholder is acceptable — these sections are not gated by `/draft:upload` for low criticality.
358
+
359
+ The TBD bullets are **not** claims. They are reviewable gaps. A reviewer can ask "is the latency budget defined yet?" and the author can fill it. Bare `-` placeholders give the reviewer nothing to ask about.
360
+
361
+ > **TPT/IDF automation deferred** — when MCP integration to Jira ships, decompose will pre-fill the §IP TPT table from existing TPT JIRA issues. Today: section stays empty for the author.
362
+
363
+ ### Step 5b: LLD Generation (Gated)
364
+
365
+ **Trigger:** `--lld` flag was passed in Step 1 **OR** any module in Step 3 has `Complexity: High`.
366
+
367
+ **Skip condition:** No `--lld` flag and no High-complexity module. Do not create `lld.md`. Note in completion announcement: _"LLD not generated. Run `/draft:decompose --lld` to expand."_
368
+
369
+ When triggered, generate `draft/tracks/<id>/lld.md` from `core/templates/lld.md`. Refer to `core/agents/architect.md` for contract-design conventions.
370
+
371
+ **Frontmatter:** Copy git metadata + `links.*` (point `hld` link at `./hld.md`).
372
+
373
+ **Approvals table:** Pre-fill from `spec.md` `approvers.{team_leads, tech_leads, qa}` (flat keys, no `lld_` prefix).
374
+
375
+ **§Background:** Single sentence linking to HLD §Background. Add component-internal context only if HLD doesn't cover it.
376
+
377
+ **§Requirements:** Link-only to `spec.md`; list AC IDs covered by this LLD.
378
+
379
+ **§Low Level Design / Classes and Interfaces:**
380
+ - **`<!-- GRAPH:track-class-table -->` slot:** Render per-module table from graph public-API index. One row per public symbol. Columns: Symbol, Kind (class/iface/func/method), Signature, Visibility, Citation (`path:line`), Concurrency Notes.
381
+ - **Mandatory Citation Gate (LLD):** Same rule as HLD §Detailed Design. For every symbol whose owning module has Status `Modified` or `Existing`, Citation must resolve to a real `path:line` from a file Read in this run. For `Status: New` symbols, Citation may be `<planned path>:<planned line or TBD>` provided the file path is concrete. A bare `TBD` cell is a halt — fix before emitting.
382
+ - **Per-component subsection:** Public API table with full signatures, params, returns, errors, citation. Document Preconditions, Postconditions, Invariants (thread safety, idempotency, ordering).
383
+
384
+ **§Low Level Design / Data Model:**
385
+ - **`<!-- GRAPH:track-data-models -->` slot:** Render one block per new/modified entity. Pull proto/struct/class declarations and field metadata from the graph data-model index.
386
+ - **Per-model subsection:** Field table (type, nullable, default, validation), Storage, Indexes/Keys, Migration path.
387
+
388
+ **§Low Level Design / Key Algorithms and Workflows:** Sequence diagram per AC that crosses more than one module — happy path + at least one error path. Annotate gates with `Note over`. For genuinely non-trivial logic: pseudocode with declared inputs, outputs, time/space complexity, edge cases. Skip for straightforward CRUD.
389
+
390
+ **§Low Level Design / Error Handling & Retry Semantics:** One row per operation with non-trivial error handling. Classify each error, specify retry policy, backoff, max attempts, fallback. Document circuit-breaker thresholds and idempotency keys.
391
+
392
+ **§Low Level Design / Refactoring of Existing Code:** Populate when the track refactors existing code; otherwise leave empty.
393
+
394
+ **§Low Level Design / Programming Language Choice and Unit Testing:** Author-driven. Reference `/draft:testing-strategy` for project-level test strategy; LLD section covers only what is component-specific.
395
+
396
+ **§Low Level Design / PaaS Choices:** Author-driven. Decompose does not infer Data Store / Workflow Engine / Checkpointing choices.
397
+
398
+ **§Observability / Metrics + Alerting Thresholds:** Author-driven. `/draft:deploy-checklist` validates this table is populated before deploy.
399
+
400
+ ### Step 5c: Normalise Whitespace
401
+
402
+ After writing all generated files, strip trailing whitespace and blank lines at EOF. GitHub rejects commits containing either.
403
+
404
+ Resolve the script via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
405
+
406
+ ```bash
407
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
408
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
409
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
410
+ # Fix all generated markdown for this track:
411
+ [ -x "$DRAFT_TOOLS/fix-whitespace.sh" ] && bash "$DRAFT_TOOLS/fix-whitespace.sh" --track <id>
412
+ # Also fix project-level files if architecture.md was touched:
413
+ [ -x "$DRAFT_TOOLS/fix-whitespace.sh" ] && bash "$DRAFT_TOOLS/fix-whitespace.sh" draft/architecture.md draft/.ai-context.md 2>/dev/null || true
414
+ ```
415
+
416
+ Run unconditionally — idempotent if files are already clean.
417
+
418
+ ### CHECKPOINT (MANDATORY)
419
+
420
+ **STOP.** Present the generated `hld.md` (and `lld.md` if generated) to the developer. Call out:
421
+ - Which graph slots were populated vs. unpopulated (and why — e.g., "no proto definitions found, GRAPH:track-data-models slot empty").
422
+ - Whether LLD was generated, and the trigger (`--lld` flag or auto-triggered by High-complexity module X).
423
+ - Author-driven sections that still need manual content: §IP, §Checklist (HLD), §PaaS/§UT (LLD), §Observability metrics/thresholds.
424
+ - Reminder: HLD must be circulated to the approvers in the Approvals table before significant implementation begins; `/draft:upload` will block `git upload` for high-criticality tracks until the table is signed.
425
+
426
+ **Wait for developer approval before proceeding to Step 6.**
427
+
428
+ ## Step 6: Update Plan (Track-Scoped Only)
429
+
430
+ If this is a track-scoped decomposition and a `plan.md` exists:
431
+
432
+ 1. Review existing phases against the module implementation order
433
+ 2. Propose restructuring phases to align with module boundaries
434
+ 3. Each module becomes a phase or maps to existing phases
435
+
436
+ ### Bracketed-region rewriting (WS-6)
437
+
438
+ `core/templates/plan.md` (and tracks generated from it at template_version
439
+ ≥ 2.0.0) wraps phase tables in:
440
+
441
+ ```
442
+ <!-- DECOMPOSE:REGENERATE START -->
443
+ ... phase tables ...
444
+ <!-- DECOMPOSE:REGENERATE END -->
445
+ ```
446
+
447
+ Decompose **only** rewrites content between these markers. Manual notes the
448
+ author added above or below the markers (overview prose, design notes,
449
+ references, sunset criteria) survive every regenerate. After rewriting:
450
+
451
+ 1. Update plan.md `generated_by:` to `draft:decompose`.
452
+ 2. Update plan.md `generated_at:` to the current ISO-8601 timestamp.
453
+ 3. Ensure plan.md `generated_at` ≥ sibling hld.md / lld.md `generated_at`
454
+ (the hygiene validator fails on stale plan).
455
+ 4. Run `scripts/tools/check-track-hygiene.sh <track_dir>` and resolve any
456
+ findings before promoting status past `draft`.
457
+
458
+ If the plan does not yet have the bracket markers (pre-2.0 track), insert
459
+ them around the phase region during this first decompose run, then rewrite.
460
+
461
+ ### Plan Merge Rules
462
+
463
+ When restructuring plan.md around modules, follow these rules for existing tasks:
464
+
465
+ **Completed tasks `[x]`:** Preserve exactly as-is. Map them to the appropriate module phase. Do not rename, reorder, or modify. Add a note: `(preserved from original plan)`.
466
+
467
+ **In-progress tasks `[~]`:** Map to the appropriate module phase. Flag for developer review if the task spans multiple modules:
468
+ ```markdown
469
+ - [~] **Task 2.1:** Original task description
470
+ - ⚠ REVIEW: This task may need splitting across modules [auth] and [database]
471
+ ```
472
+
473
+ **Pending tasks `[ ]`:** Remap freely to module phases. Split tasks that span module boundaries into per-module tasks. Preserve the original task description in the new task.
474
+
475
+ **Blocked tasks `[!]`:** Preserve the blocked status and reason. Map to appropriate module. If the blocker is in a different module, add a cross-module dependency note.
476
+
477
+ **Conflict handling:** If a task doesn't map cleanly to any module:
478
+ 1. List it under a `### Unmapped Tasks` section at the end
479
+ 2. Flag it for developer decision
480
+ 3. Never silently drop tasks
481
+
482
+ ### CHECKPOINT (MANDATORY)
483
+
484
+ **STOP.** Present the updated plan structure.
485
+
486
+ ```
487
+ PROPOSED PLAN RESTRUCTURE
488
+ ---
489
+ Phase 1: [Module A] (Foundation)
490
+ - Task 1.1: [existing or new task]
491
+ - Task 1.2: ...
492
+
493
+ Phase 2: [Module B] (depends on Module A)
494
+ - Task 2.1: ...
495
+ ...
496
+ ```
497
+
498
+ **Wait for developer approval before writing changes to plan.md.**
499
+
500
+ ### Step 6b: Sync Metadata After Restructuring
501
+
502
+ After applying the approved plan changes:
503
+
504
+ 1. **Update `tracks/<track_id>/metadata.json`:** Set `phases.total` to match the new number of phases. Also update `git.commit`, `git.commit_message`, `git.dirty`, and `synced_to_commit` to current HEAD — this is the single source of truth for the track's git state.
505
+ 2. **Update `draft/tracks.md`:** Update the phase count for this track's entry to reflect the new total (e.g., `Phase: 0/4` → `Phase: 0/5` if a phase was added).
506
+
507
+ ## Completion
508
+
509
+ **Track-scoped announcement:**
510
+ ```
511
+ Track decomposition complete.
512
+
513
+ Created: draft/tracks/<id>/hld.md
514
+ [if LLD generated:] draft/tracks/<id>/lld.md
515
+ [else:] (LLD not generated — run /draft:decompose --lld to expand)
516
+
517
+ Modules: [count]
518
+ Implementation order: [module names in order]
519
+
520
+ Author-driven sections still empty (fill before HLD review):
521
+ - HLD §Intellectual Property (Inventions, IDFs, TPT)
522
+ - HLD §Checklist (Performance, Scale, Security, Resiliency, Multi-tenancy, Upgrade, Cost)
523
+ - HLD §Deployment, §Observability
524
+ [if LLD generated:]
525
+ - LLD §Programming Language Choice, §PaaS Choices, §Observability metrics/thresholds
526
+
527
+ Next steps:
528
+ - Fill the author-driven sections in hld.md (and lld.md if present)
529
+ - Circulate hld.md to approvers listed in §Approvals
530
+ - Run /draft:implement to start building once HLD is approved
531
+ - /draft:upload will block git upload on HLD Approvals being signed
532
+ for criticality ∈ {high, mission-critical}
533
+ ```
534
+
535
+ **Project-wide announcement** (when scope = project):
536
+ ```
537
+ Project architecture refresh complete.
538
+
539
+ Updated: draft/architecture.md
540
+ Derived: draft/.ai-context.md
541
+
542
+ Next steps:
543
+ - Review architecture.md and edit as needed
544
+ - For new feature work: /draft:new-track then /draft:decompose
545
+ ```
546
+
547
+ ## Mutation Protocol for architecture.md and .ai-context.md (Project-Wide)
548
+
549
+ > `draft/architecture.md` is the source of truth. `draft/.ai-context.md` is derived from it via the Condensation Subroutine (defined in `core/shared/condensation.md`). Always update `architecture.md` first, then regenerate `.ai-context.md`.
550
+
551
+ When adding new modules to the project-wide architecture:
552
+
553
+ 1. Update `draft/architecture.md`: append module definitions, update dependency diagram and table
554
+ 2. Do NOT remove/modify `[x] Existing` modules
555
+ 3. Update `draft/metadata.json` with current HEAD (use `git-metadata.sh --project-metadata --generated-by "draft:decompose"` or update `git.commit`, `git.commit_message`, and `synced_to_commit` manually)
556
+ 4. Run the Condensation Subroutine (defined in `core/shared/condensation.md`) to regenerate `draft/.ai-context.md`
557
+
558
+ **Safe write pattern for architecture.md:**
559
+ 1. Backup `architecture.md` → `architecture.md.backup`
560
+ 2. Write changes to `architecture.md.new`
561
+ 3. Present diff for review
562
+ 4. On approval: replace `architecture.md` with `architecture.md.new`, run Condensation Subroutine, then delete `architecture.md.backup`
563
+ 5. On rejection: delete `architecture.md.new` and rename `architecture.md.backup` back to `architecture.md`
564
+
565
+ ## Updating design context
566
+
567
+ **Project-wide rerun** (running `/draft:decompose` on existing `.ai-context.md` / `architecture.md`):
568
+ 1. Read the existing context file
569
+ 2. Ask developer what changed (new modules, removed modules, restructured boundaries)
570
+ 3. Follow the same checkpoint process for changes
571
+ 4. Update `draft/architecture.md`, preserving completed module statuses and stories, then regenerate `.ai-context.md`
572
+
573
+ **Track-scoped rerun** (running `/draft:decompose <track>` on existing `hld.md` / `lld.md`):
574
+ 1. Read the existing HLD (and LLD if present)
575
+ 2. If the track's `spec.md` has materially changed, prefer `/draft:change` first to amend spec/plan and flag HLD/LLD impact
576
+ 3. Otherwise, regenerate the graph-fenced slots only (component diagram, component table, dependencies table, class table, data models). Author-driven sections (§IP, §Checklist, §PaaS, §UT, §Observability) and the §Approvals table are preserved verbatim
577
+ 4. If the Approvals table had signatures and the HLD's structural sections changed, surface a warning: "HLD modified after sign-off — re-circulate to approvers."
578
+
579
+ ---
580
+
581
+ ## Cross-Skill Dispatch
582
+
583
+ ### After Module Decomposition
584
+
585
+ After defining module boundaries and interfaces:
586
+
587
+ ```
588
+ "Decomposition complete. Consider:
589
+
590
+ Testing:
591
+ → /draft:testing-strategy — Define per-module test boundaries and integration test strategy
592
+
593
+ Documentation:
594
+ → /draft:documentation api <module> — Document public module interfaces
595
+
596
+ Architecture:
597
+ → /draft:adr "Module boundary decisions for {project}" — Record decomposition rationale"
598
+ ```
599
+
600
+ ### Dependency Cycle Detection
601
+
602
+ If dependency analysis (Step 4) detects cycles or high coupling:
603
+ ```
604
+ "Detected dependency cycles / high coupling. Consider:
605
+ → /draft:tech-debt — Catalog architecture debt and prioritize remediation"
606
+ ```
607
+
608
+ ### ADR Auto-Invocation
609
+
610
+ When decomposition involves breaking a monolith, choosing module boundaries, or extracting services:
611
+ - Auto-invoke: "This decomposition is a significant architectural decision. Creating ADR to document rationale."
612
+ - Invoke `/draft:adr "Module boundary decisions for {project}"`
613
+
614
+ ## Mandatory Self-Check (before completion announcement)
615
+
616
+ Before printing the completion announcement, internally verify and report:
617
+
618
+ 1. **Graph files queried** — which JSONL files were loaded (e.g. `architecture.json, hotspots.jsonl` and tools like `cycle-detect.sh`).
619
+ 2. **Layer 1 files deliberately skipped** — list any `.ai-context.md` sections, `tech-stack.md`, `product.md`, `workflow.md` you skipped as irrelevant to this decomposition. Be explicit; do not silently skip.
620
+ 3. **Filesystem grep fallback justification** — for every `grep`/`find` run, state the concept it searched for and quote the graph-miss sentence.
621
+ 4. **Citation Gate audit** — scan every Citation column in the generated component table, dependencies table, and LLD class table. Report:
622
+ - Modified/Existing rows with resolved citations: count
623
+ - Modified/Existing rows with `TBD` citations: must be **0** (halt and fix if non-zero)
624
+ - New rows with `(planned)` paths: count
625
+ 5. **Files actually Read** — list each source file opened during this run. Cross-reference: every Modified/Existing row in the component table must trace to at least one file in this list.
626
+ 6. **HLD Checklist scaffolding** — confirm Performance / Scale / Security / Resiliency / Multi-tenancy / Upgrade / Flags / Cost are populated with structured TBD bullets (for `criticality: standard | high | mission-critical`), not bare `-` placeholders.
627
+
628
+ If `draft/graph/schema.yaml` does not exist, set `Graph files queried: NONE` and use justification `graph data unavailable`. Decompose must still propose modules from `.ai-context.md` / source files in that case **and must still Read those files** to satisfy the Citation Gate.
629
+
630
+ ## Graph Usage Report (append to output)
631
+
632
+ Emit the canonical footer from [core/shared/graph-usage-report.md](../../core/shared/graph-usage-report.md) §Canonical footer. The lint hook `scripts/tools/check-graph-usage-report.sh` validates the section on save.
633
+ ## Skill Telemetry
634
+
635
+ As the last step after the completion announcement, emit a metrics record. Best-effort — never block.
636
+
637
+ **Payload fields:**
638
+ ```json
639
+ {
640
+ "skill": "decompose",
641
+ "scope": "track|project",
642
+ "track_id": "<track_id or null>",
643
+ "modules_count": <N>,
644
+ "lld_generated": true|false,
645
+ "high_complexity_modules": <N>
646
+ }
647
+ ```
648
+
649
+ **Emit call:**
650
+ ```bash
651
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
652
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
653
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
654
+ [ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
655
+ '{"skill":"decompose","scope":"<scope>","track_id":"<id_or_null>","modules_count":<N>,"lld_generated":<bool>,"high_complexity_modules":<N>}'
656
+ ```