@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,183 @@
1
+ ---
2
+ name: standup
3
+ description: Generate standup summary from git history, track progress, and Jira/GitHub activity. Read-only — makes no changes to the codebase.
4
+ ---
5
+
6
+ # Standup
7
+
8
+ You are generating a standup summary from recent development activity. This is a **read-only** skill — it makes no changes to the codebase or track files.
9
+
10
+ ## Red Flags — STOP if you're:
11
+
12
+ - Modifying any files (this is read-only)
13
+ - Fabricating activity that didn't happen
14
+ - Including sensitive information (credentials, internal URLs) in standup output
15
+ - Reporting on other people's commits without being asked
16
+
17
+ **Report facts. Fabricate nothing.**
18
+
19
+ ---
20
+
21
+ ## Pre-Check
22
+
23
+ ### 0. Capture Git Context
24
+
25
+ Before starting, capture the current git state:
26
+
27
+ ```bash
28
+ git branch --show-current # Current branch name
29
+ git rev-parse --short HEAD # Current commit hash
30
+ ```
31
+
32
+ Store this for context. The standup reflects activity up to this specific commit.
33
+
34
+ ### 1. Load Draft Context (if available)
35
+
36
+ ```bash
37
+ ls draft/ 2>/dev/null
38
+ ```
39
+
40
+ If `draft/` exists, read and follow `core/shared/draft-context-loading.md`.
41
+
42
+ ## Step 1: Parse Arguments
43
+
44
+ Check for arguments:
45
+ - `/draft:standup` — Default: last 24 hours of activity
46
+ - `/draft:standup <days>` — Activity from last N days
47
+ - `/draft:standup weekly` — Full week summary (Monday-Friday)
48
+ - `/draft:standup --author <name>` — Filter to specific author
49
+
50
+ ## Step 2: Gather Activity
51
+
52
+ ### Source 1: Git History
53
+
54
+ **Preferred:** invoke `parse-git-log.sh` — it parses conventional commits into structured JSONL `{sha,type,scope,track_id,subject,author,timestamp,files_changed}`, eliminating ambiguity in `type(track-id): subject` parsing. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
55
+
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/parse-git-log.sh" ]; then
61
+ bash "$DRAFT_TOOLS/parse-git-log.sh" --since "24 hours ago" --author "$(git config user.name)"
62
+ else
63
+ # Fallback: raw git log
64
+ git log --oneline --since="24 hours ago" --author="$(git config user.name)"
65
+ git log --since="24 hours ago" --author="$(git config user.name)" --format="%h %s" --no-merges
66
+ fi
67
+ ```
68
+
69
+ Parse commit messages for:
70
+ - Track IDs (from `type(track-id): description` convention — already extracted as `track_id` in JSONL)
71
+ - Task completions
72
+ - Bug fixes
73
+ - Feature additions
74
+
75
+ ### Source 2: Track Progress (if draft context exists)
76
+
77
+ Read `draft/tracks.md` for active tracks:
78
+ - Current status and phase
79
+ - Tasks completed since last standup
80
+ - Blockers (tasks marked `[!]`)
81
+ - Scope (`metadata.json:scope_includes` / `scope_excludes`) — mention when
82
+ two active tracks share a scope tag; surfaced by
83
+ `scripts/tools/check-scope-conflicts.sh`. Schema:
84
+ [core/shared/template-contract.md](../../core/shared/template-contract.md).
85
+
86
+ For each active track, read `plan.md` to determine:
87
+ - Tasks completed (count `[x]` with recent commit SHAs)
88
+ - Current task (first `[ ]` or `[~]`)
89
+ - Phase progress
90
+
91
+ ### Source 3: Jira Activity (if MCP available)
92
+
93
+ If Jira MCP is available:
94
+ - Query recent ticket transitions (status changes)
95
+ - Check for new comments or assignments
96
+ - Pull sprint board status
97
+
98
+ ### Source 4: GitHub Activity (if MCP available)
99
+
100
+ If GitHub MCP is available:
101
+ - Query open reviews authored by user
102
+ - Check for new review comments received
103
+ - Query recently merged changes
104
+
105
+ ### Source 5: Skill Metrics (if `~/.draft/metrics.jsonl` exists)
106
+
107
+ ```bash
108
+ tail -50 ~/.draft/metrics.jsonl 2>/dev/null
109
+ ```
110
+
111
+ If the file exists and has records in the standup period, enrich the standup with skill activity:
112
+ - **implement** records: count tasks completed, note TDD pass/fail rate
113
+ - **review** records: note reviews run and their verdicts
114
+ - **bughunt** records: note bug hunts run and critical counts
115
+ - Include a brief "AI-Assisted Activity" line in the standup: `AI tools used: implement (N tasks), review (N times), bughunt (N hunts)`
116
+
117
+ If the file does not exist or has no records in the period, skip silently — this source is always optional.
118
+
119
+ ## Step 3: Generate Standup
120
+
121
+ Format using the standard Yesterday/Today/Blockers structure:
122
+
123
+ ```markdown
124
+ ## Standup — {date}
125
+
126
+ **Author:** {git user.name}
127
+ **Period:** {time range}
128
+
129
+ ### Completed
130
+ - [{track-id}] {task description} ({commit SHA})
131
+ - [{track-id}] {task description} ({commit SHA})
132
+ - Reviewed: {GitHub change ID / PR} (if applicable)
133
+
134
+ ### Planned
135
+ - [{track-id}] Next task: {description} (from plan.md)
136
+ - [{track-id}] Continue: {in-progress task} (from plan.md)
137
+ - Review: {pending reviews} (if applicable)
138
+
139
+ ### Blockers
140
+ - [{track-id}] {blocked task description} — {reason}
141
+ - Waiting on: {external dependency}
142
+
143
+ ### Track Progress
144
+ | Track | Phase | Tasks | Status |
145
+ |-------|-------|-------|--------|
146
+ | {id} | {N}/{total} | {done}/{total} | {status} |
147
+ ```
148
+
149
+ **If no activity found:** "No commits in the last {period}. Working on: {active track description from tracks.md or 'no active tracks'}."
150
+
151
+ ## Step 4: Present Output
152
+
153
+ Present the standup summary directly in the conversation. Do not write to any file unless explicitly requested.
154
+
155
+ If the user asks to save:
156
+ - Save to `draft/standup-<date>.md`
157
+ - Symlink: `draft/standup-latest.md`
158
+
159
+ **If saving, MANDATORY: Include YAML frontmatter with git metadata.** Follow `core/shared/git-report-metadata.md`.
160
+
161
+ Include the report header table immediately after frontmatter:
162
+
163
+ ```markdown
164
+ | Field | Value |
165
+ |-------|-------|
166
+ | **Branch** | `{LOCAL_BRANCH}` → `{REMOTE/BRANCH}` |
167
+ | **Commit** | `{SHORT_SHA}` — {COMMIT_MESSAGE} |
168
+ | **Generated** | {ISO_TIMESTAMP} |
169
+ | **Synced To** | `{FULL_SHA}` |
170
+ ```
171
+
172
+ ## Cross-Skill Dispatch
173
+
174
+ - **References:** `core/agents/ops.md` for operational context awareness
175
+ - **Reads from:** `/draft:status` data (tracks.md, plan.md, metadata.json)
176
+ - **MCP integrations:** Jira MCP (ticket status), GitHub MCP (review activity)
177
+ - **No downstream dispatch** — this is a terminal, read-only skill
178
+
179
+ ## Error Handling
180
+
181
+ **If no git history:** "No git commits found for {period}. Is this the right repository?"
182
+ **If no draft context:** Generate standup from git history only. Note: "Richer standups available after `/draft:init`."
183
+ **If no MCP available:** Skip Jira/GitHub sections, generate from local data only.
@@ -0,0 +1,183 @@
1
+ ---
2
+ name: status
3
+ description: Display current progress of Draft tracks and active tasks. Shows phases, completion percentages, and blocked items.
4
+ ---
5
+
6
+ # Draft Status
7
+
8
+ Display a comprehensive overview of project progress.
9
+
10
+ ## Red Flags - STOP if you're:
11
+
12
+ - Reporting status without actually reading the files
13
+ - Making up progress percentages
14
+ - Skipping blocked items in the report
15
+ - Not checking each active track's actual state
16
+ - Summarizing without evidence from the files
17
+
18
+ **Always read before reporting.**
19
+
20
+ ---
21
+
22
+ ## Gather Data
23
+
24
+ 1. Read `draft/tracks.md` for track list
25
+ 2. For each active track, read:
26
+ - `draft/tracks/<id>/metadata.json` for stats. If `metadata.json` is malformed or unreadable, display `(metadata unavailable)` for that track's statistics instead of failing.
27
+ - `draft/tracks/<id>/plan.md` for task status
28
+ - `draft/tracks/<id>/architecture.md` for module status (if exists)
29
+ - `metadata.json:scope_includes` / `scope_excludes` for the track's
30
+ scope footprint. Surface these in the status output so reviewers can
31
+ spot overlap at a glance. Conflicts are detected by
32
+ `scripts/tools/check-scope-conflicts.sh` (see
33
+ [core/shared/template-contract.md](../../core/shared/template-contract.md)).
34
+ 3. Check for project-wide `draft/.ai-context.md` (or legacy `draft/architecture.md`) for module status
35
+ 4. **Detect orphaned tracks:**
36
+ - Scan `draft/tracks/` for all directories
37
+ - For each directory, check if it has `metadata.json`
38
+ - Cross-reference with `draft/tracks.md` entries
39
+ - If directory has metadata.json but NOT in tracks.md → orphaned track
40
+ - Collect list of orphaned track IDs for warning section
41
+
42
+ ### Optional: report rollup & freshness signals
43
+
44
+ If `parse-reports.sh` and `freshness-check.sh` are available, gather structured signals to enrich the status output (severity counts per track, stale `draft/` docs). Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
45
+
46
+ ```bash
47
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
48
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
49
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
50
+
51
+ # Per-track report severity rollup (bughunt, review, tech-debt, etc.):
52
+ [ -x "$DRAFT_TOOLS/parse-reports.sh" ] && \
53
+ bash "$DRAFT_TOOLS/parse-reports.sh" --root draft/
54
+
55
+ # Stale draft/ docs (sha256 drift since last index):
56
+ [ -x "$DRAFT_TOOLS/freshness-check.sh" ] && [ -f draft/.state/freshness.json ] && \
57
+ bash "$DRAFT_TOOLS/freshness-check.sh" --state draft/.state/freshness.json
58
+ ```
59
+
60
+ Surface non-zero severity counts inline with each track. Surface stale-doc warnings in a "STALE DOCS" section after BLOCKED ITEMS. Both signals are best-effort — skip silently if scripts or state are absent.
61
+
62
+ ## Output Format
63
+
64
+ Check each track's `metadata.json` `type` field to determine display format.
65
+
66
+ ### Standard (multi-phase) tracks
67
+
68
+ ```
69
+ ---
70
+ DRAFT STATUS
71
+ ---
72
+ PROJECT: [from product.md title]
73
+
74
+ ACTIVE TRACKS
75
+ ---
76
+ [track-id-1] Feature Name
77
+ Status: [~] In Progress
78
+ Phase: 2/3 (Phase 2: [Phase Name])
79
+ Tasks: 5/12 complete
80
+ ├─ [x] Task 1.1: Description
81
+ ├─ [x] Task 1.2: Description
82
+ ├─ [~] Task 2.1: Description ← CURRENT
83
+ ├─ [ ] Task 2.2: Description
84
+ └─ [!] Task 2.3: Blocked - [reason]
85
+
86
+ [track-id-2] Another Feature
87
+ Status: [ ] Not Started
88
+ Phase: 0/2
89
+ Tasks: 0/6 complete
90
+
91
+ ```
92
+
93
+ ### Quick-mode tracks (metadata.json `type` is `"quick"`)
94
+
95
+ Quick-mode tracks use flat task numbering (`Task 1:`, `Task 2:`) without phases. Display them with a flat task list instead of the phase-grouped tree:
96
+
97
+ ```
98
+ [track-id-3] Quick Feature
99
+ Status: [~] In Progress
100
+ Type: quick
101
+ Tasks: 2/5 complete
102
+ ├─ [x] Task 1: Description
103
+ ├─ [x] Task 2: Description
104
+ ├─ [~] Task 3: Description ← CURRENT
105
+ ├─ [ ] Task 4: Description
106
+ └─ [ ] Task 5: Description
107
+ ```
108
+
109
+ Do **not** show `Phase: X/Y` for quick-mode tracks — they have no phases.
110
+
111
+ ### Remaining sections (shared by both formats)
112
+
113
+ ```
114
+ MODULES (if architecture.md exists)
115
+ ---
116
+ Module A [x] Complete (Coverage: 96.2%)
117
+ Module B [~] In Progress - 3/5 tasks
118
+ Module C [ ] Not Started
119
+
120
+ BLOCKED ITEMS
121
+ ---
122
+ - [track-id-1] Task 2.3: [blocked reason]
123
+
124
+ ORPHANED TRACKS
125
+ ---
126
+ ⚠ The following tracks have metadata.json but are missing from tracks.md:
127
+ - draft/tracks/orphan-track-id/
128
+
129
+ Recovery options:
130
+ 1. Add to tracks.md manually if track is valid
131
+ 2. Remove orphaned track directory if no longer needed
132
+
133
+ RECENTLY COMPLETED
134
+ ---
135
+ - [track-id-3] - Completed [date]
136
+
137
+ QUICK STATS
138
+ ---
139
+ Active Tracks: 2
140
+ Total Tasks: 18
141
+ Completed: 5 (28%)
142
+ Blocked: 1
143
+ ---
144
+ ```
145
+
146
+ ## Module Reporting
147
+
148
+ When `.ai-context.md` or `architecture.md` exists for a track (track-level or project-level):
149
+
150
+ 1. Read the `.ai-context.md` (or `architecture.md`) module definitions from `## Modules` section
151
+ 2. For each module, determine status from its status marker:
152
+ - `[ ]` Not Started
153
+ - `[~]` In Progress — count completed vs total tasks mapped to this module
154
+ - `[x]` Complete — include coverage percentage if recorded
155
+ - `[!]` Blocked — include reason
156
+ 3. Display in the MODULES section of the track report
157
+ 4. If project-wide `draft/.ai-context.md` (or legacy `draft/architecture.md`) exists, show a project-level module summary after QUICK STATS
158
+
159
+ ---
160
+
161
+ ## If No Tracks
162
+
163
+ ```
164
+ ---
165
+ DRAFT STATUS
166
+ ---
167
+ PROJECT: [from product.md title]
168
+
169
+ No active tracks.
170
+
171
+ Get started:
172
+ /draft:new-track "Your feature description"
173
+
174
+ ---
175
+ ```
176
+
177
+ ## If Not Initialized
178
+
179
+ ```
180
+ Draft not initialized in this project.
181
+
182
+ Run /draft:init to initialize.
183
+ ```
@@ -0,0 +1,318 @@
1
+ ---
2
+ name: tech-debt
3
+ description: Identify, categorize, and prioritize technical debt across seven dimensions. Generates remediation plans with effort estimates. Offered by /draft:new-track for refactor tracks.
4
+ ---
5
+
6
+ # Tech Debt
7
+
8
+ You are conducting a technical debt analysis to catalog, prioritize, and plan remediation of debt across the codebase.
9
+
10
+ ## MANDATORY GRAPH LOOKUP (read before debt scan)
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. Tech-debt prioritization is fundamentally driven by graph data:
13
+
14
+ 1. Load `draft/graph/hotspots.jsonl` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
15
+ 2. Read `draft/graph/architecture.json` (`.packages`) and run `scripts/tools/cycle-detect.sh --repo .` — flag debt in modules involved in cycles as higher priority.
16
+ 3. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
17
+ 4. For each catalogued finding, run `scripts/tools/graph-impact.sh --repo . --file <path>` so the remediation plan includes blast-radius.
18
+
19
+ Filesystem `grep` (e.g. `scan-markers.sh`) is still primary for TODO/FIXME marker discovery — markers are source-text, not graph-derived. The graph governs **prioritization**, the marker scan governs **discovery**.
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.
24
+
25
+ Skill-specific:
26
+ - Flagging intentional design choices as debt (check tech-stack.md accepted patterns first)
27
+ - Cataloging debt without understanding the business context
28
+ - Setting priorities without considering team capacity
29
+ - Recommending "rewrite from scratch" without exhausting incremental options
30
+ - Ignoring the existing guardrails.md conventions
31
+
32
+ **Not all shortcuts are debt. Check accepted patterns before flagging.**
33
+
34
+ ---
35
+
36
+ ## Pre-Check
37
+
38
+ ### 0. Capture Git Context
39
+
40
+ Before starting, capture the current git state:
41
+
42
+ ```bash
43
+ git branch --show-current # Current branch name
44
+ git rev-parse --short HEAD # Current commit hash
45
+ ```
46
+
47
+ Store this for the report header. All findings are relative to this specific branch/commit.
48
+
49
+ ### 1. Verify Draft Context
50
+
51
+ ```bash
52
+ ls draft/ 2>/dev/null
53
+ ```
54
+
55
+ If `draft/` doesn't exist, this skill can still run standalone with reduced context.
56
+
57
+ ### 2. Load Draft Context (if available)
58
+
59
+ Read and follow the base procedure in `core/shared/draft-context-loading.md`.
60
+
61
+ ## Step 1: Parse Arguments
62
+
63
+ - `/draft:tech-debt` — Project-wide scan (default)
64
+ - `/draft:tech-debt module <name>` — Module-scoped scan
65
+ - `/draft:tech-debt category <type>` — Filter by category (code, architecture, test, dependency, documentation, infrastructure)
66
+ - `/draft:tech-debt <path>` — Scan specific directory/file pattern
67
+
68
+ ## Step 2: Load Context
69
+
70
+ 1. Read `draft/tech-stack.md` — **Critical:** "Accepted Patterns" section. Do NOT flag these as debt.
71
+ 2. Read `draft/guardrails.md` — Learned conventions (skip) and anti-patterns (always flag)
72
+ 3. Read `draft/.ai-context.md` — Module boundaries, invariants, known constraints
73
+ 4. Read `draft/product.md` — Business priorities for impact assessment
74
+ 5. Read `draft/workflow.md` — Team conventions and toolchain for feasibility assessment
75
+
76
+ ## Step 3: Scan for Debt
77
+
78
+ Scan the codebase systematically across all seven categories. For each finding, record: location (file:line OR track id for Process Debt), description, evidence, and category.
79
+
80
+ ### Category 1: Code Debt
81
+
82
+ For TODO/FIXME/HACK/XXX/DEPRECATED markers, prefer the deterministic `scan-markers.sh` wrapper — it emits JSON `[{path,line,marker,text,sha,author,introduced,age_days}]` with blame ages already computed. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
83
+
84
+ ```bash
85
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
86
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
87
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
88
+ [ -x "$DRAFT_TOOLS/scan-markers.sh" ] && bash "$DRAFT_TOOLS/scan-markers.sh" --root .
89
+ # Fallback when script unavailable: grep -rn 'TODO\|FIXME\|HACK\|XXX\|DEPRECATED' .
90
+ ```
91
+
92
+ Use the JSON output to prioritise: markers with `age_days > 180` are stale and should be promoted to tracked tech debt.
93
+
94
+ **Marker context gate (Ground-Truth Discipline G1):** `scan-markers.sh` produces *candidates*, not findings. Before promoting a TODO/FIXME/HACK/XXX/DEPRECATED marker to your debt catalog, **Read** the surrounding 10–20 lines at that `file:line`. Many markers are justified (intentional deferrals with ownership) or already addressed (the marker rotted, the work shipped). A debt entry whose Evidence is "marker exists" without a Read is a Ground-Truth Red Flag — produce false positives and reviewer churn.
95
+
96
+ - Complex functions (cyclomatic complexity >10, deep nesting >4 levels)
97
+ - Duplicated code blocks (>20 lines similar across multiple locations)
98
+ - TODO/FIXME/HACK/XXX comments (especially old ones — check git blame age via `scan-markers.sh` above)
99
+ - Dead code (unreachable branches, unused exports, commented-out blocks)
100
+ - Inconsistent naming patterns within the same module
101
+ - Long functions (>100 lines without clear separation of concerns)
102
+ - God classes (>500 lines, >10 public methods, mixed responsibilities)
103
+ - Magic numbers and hardcoded strings that should be constants
104
+ - Deeply nested callbacks or promise chains (callback hell)
105
+
106
+ ### Category 2: Architecture Debt
107
+
108
+ - Dependency cycles between modules (A depends on B depends on A)
109
+ - Tight coupling (modules with >5 direct cross-references)
110
+ - Layer violations (UI calling DB directly, business logic in controllers)
111
+ - Missing abstractions (repeated patterns without shared interface)
112
+ - Monolith tendencies (single module >50% of codebase)
113
+ - Inconsistent data flow patterns (some modules use events, others direct calls)
114
+ - Missing or bypassed API boundaries (internal implementation details exposed)
115
+ - Configuration scattered across multiple locations
116
+
117
+ ### Category 3: Test Debt
118
+
119
+ - Modules with zero test coverage
120
+ - Missing integration tests for service boundaries
121
+ - Brittle tests (frequently failing, time-dependent, order-dependent)
122
+ - Test-code coupling (tests that break on internal refactor, not behavior change)
123
+ - Missing E2E tests for critical user flows (from product.md)
124
+ - Tests with no assertions (tests that only check "doesn't throw")
125
+ - Disabled/skipped tests without justification
126
+ - Missing test fixtures or shared test utilities (repeated setup code)
127
+
128
+ ### Category 4: Dependency Debt
129
+
130
+ - Outdated dependencies (>2 major versions behind)
131
+ - Known security vulnerabilities (check advisories: `npm audit`, `pip audit`, etc.)
132
+ - Deprecated APIs in use (check dependency changelogs)
133
+ - Version conflicts or pinning issues
134
+ - Abandoned dependencies (no updates >2 years, archived repos)
135
+ - Overly broad dependency versions (no pinning in production)
136
+ - Unnecessary dependencies (functionality available in stdlib or already-included packages)
137
+
138
+ ### Category 5: Documentation Debt
139
+
140
+ - Undocumented public APIs (exported functions/classes without docstrings)
141
+ - Stale README (doesn't match current setup steps or architecture)
142
+ - Missing architecture decision records for non-obvious choices
143
+ - Outdated onboarding documentation
144
+ - Missing runbooks for production services
145
+ - API docs out of sync with implementation
146
+ - Missing inline comments for complex algorithms or business rules
147
+
148
+ ### Category 6: Infrastructure Debt
149
+
150
+ - Manual deployment steps (should be automated)
151
+ - Missing or insufficient monitoring (services without health checks or alerts)
152
+ - Hardcoded configuration (should be environment variables)
153
+ - Missing CI checks (linting, security scanning, type checking)
154
+ - No automated backup/restore verification
155
+ - Missing or outdated Dockerfiles / container configs
156
+ - Inconsistent environment parity (dev/staging/prod divergence)
157
+ - Missing rate limiting or resource guards on public endpoints
158
+
159
+ ### Category 7: Process Debt ( HLD/LLD compliance)
160
+
161
+ Scan `draft/tracks/*/` for design-process gaps. For each track:
162
+
163
+ - Read `spec.md` frontmatter `classification.criticality`. Default to `standard` if absent.
164
+ - Check for `hld.md`:
165
+ - Missing for `criticality ∈ {standard, high, mission-critical}` → flag as Process Debt
166
+ - Severity: `critical` for mission-critical, `high` for high, `medium` for standard
167
+ - Remediation: "Run `/draft:decompose <track>` to generate hld.md"
168
+ - Check `hld.md` Approvals table:
169
+ - Required rows unsigned (per `/draft:upload` Step 3.1 logic) and the track has merged commits → flag
170
+ - Severity: `high` if criticality ∈ {high, mission-critical}, `medium` otherwise
171
+ - Remediation: "Re-circulate hld.md to listed approvers; update Date column on sign-off"
172
+ - Check for `lld.md`:
173
+ - Any module in HLD §Detailed Design has `Complexity: High` AND `lld.md` is missing → flag
174
+ - Severity: `medium`
175
+ - Remediation: "Run `/draft:decompose <track> --lld`"
176
+ - Check HLD §Checklist completeness:
177
+ - For criticality ≥ standard: any §Checklist sub-section still showing the placeholder text "<Describe..." or empty bullets → flag as Process Debt
178
+ - Severity: `high` for high/mission-critical, `medium` for standard
179
+ - Remediation: "Author must populate hld.md §Checklist before /draft:deploy-checklist will pass"
180
+ - Check HLD/LLD freshness:
181
+ - If `synced_to_commit` is older than the latest merged commit touching files in HLD §Detailed Design → flag as drift
182
+ - Severity: `medium`
183
+ - Remediation: "Run `/draft:decompose <track>` to refresh graph slots; review structural sections; re-circulate if signed"
184
+
185
+ Process Debt findings carry the same Impact/Effort/Risk scoring as other categories. They surface in the remediation plan alongside code/architecture debt.
186
+
187
+ ## Step 4: Prioritize
188
+
189
+ For each finding, score on three dimensions:
190
+
191
+ - **Impact** (1-5): How much does this hurt development velocity or production reliability?
192
+ - 1: Minor annoyance, cosmetic
193
+ - 2: Slows development occasionally
194
+ - 3: Regular friction, workarounds needed
195
+ - 4: Significant velocity drag or reliability risk
196
+ - 5: Blocking progress or causing incidents
197
+
198
+ - **Risk** (1-5): How likely is this to cause a production incident?
199
+ - 1: Extremely unlikely
200
+ - 2: Unlikely but possible
201
+ - 3: Moderate likelihood
202
+ - 4: Likely under certain conditions
203
+ - 5: Near-certain or already causing issues
204
+
205
+ - **Effort** (1-5): How much work to remediate?
206
+ - 1: Hours (quick fix)
207
+ - 2: A day or two
208
+ - 3: A sprint (1-2 weeks)
209
+ - 4: Multiple sprints
210
+ - 5: Large project (months)
211
+
212
+ **Priority = (Impact + Risk) / (6 - Effort)**
213
+
214
+ Higher score = higher priority. This formula naturally favors high-impact, low-effort items ("quick wins") and deprioritizes low-impact, high-effort items.
215
+
216
+ ## Step 5: Generate Remediation Plan
217
+
218
+ Organize findings into three actionable tiers:
219
+
220
+ ### Tier 1: Quick Wins (Priority > 3, Effort <= 2)
221
+
222
+ Items that can be fixed in a single sprint or less. Do these first — they deliver the best return on investment.
223
+
224
+ For each item:
225
+ - Specific fix description
226
+ - Estimated time (hours)
227
+ - Suggested assignee pattern (e.g., "whoever touches this module next")
228
+
229
+ ### Tier 2: Strategic Improvements (Priority > 2, Effort > 2)
230
+
231
+ Items requiring dedicated effort. Create via `/draft:new-track` or route via `/draft:jira` (or `/draft:plan "tech debt remediation"`).
232
+
233
+ For each item:
234
+ - Scope and approach
235
+ - Estimated effort (sprints)
236
+ - Dependencies and sequencing
237
+ - Risk of deferral (what happens if we wait?)
238
+
239
+ ### Tier 3: Nice-to-Haves (Priority <= 2)
240
+
241
+ Track but don't prioritize. Revisit quarterly. These items are real debt but the cost of remediation exceeds the current pain.
242
+
243
+ ## Step 6: Save Output
244
+
245
+ **MANDATORY: Include YAML frontmatter with git metadata.** Follow `core/shared/git-report-metadata.md`.
246
+
247
+ Include the report header table immediately after frontmatter:
248
+
249
+ ```markdown
250
+ | Field | Value |
251
+ |-------|-------|
252
+ | **Branch** | `{LOCAL_BRANCH}` → `{REMOTE/BRANCH}` |
253
+ | **Commit** | `{SHORT_SHA}` — {COMMIT_MESSAGE} |
254
+ | **Generated** | {ISO_TIMESTAMP} |
255
+ | **Synced To** | `{FULL_SHA}` |
256
+ ```
257
+
258
+ Save to: `draft/tech-debt-report-<timestamp>.md`
259
+ Create symlink: `draft/tech-debt-report-latest.md`
260
+
261
+ ```bash
262
+ TIMESTAMP=$(date +%Y-%m-%dT%H%M)
263
+ # Example: draft/tech-debt-report-2026-03-15T1430.md
264
+ ln -sf tech-debt-report-${TIMESTAMP}.md draft/tech-debt-report-latest.md
265
+ ```
266
+
267
+ Report structure:
268
+ 1. **Executive Summary** — Total findings by category and priority tier, headline stats
269
+ 2. **Priority Matrix** — Table of all findings sorted by priority score
270
+ 3. **Category Details** — Per-category findings with file locations and evidence
271
+ 4. **Remediation Plan** — Three tiers with effort estimates
272
+ 5. **Recommendations** — Strategic advice on debt management practices
273
+
274
+ ## Report Closing: Next Actions (REQUIRED)
275
+
276
+ Every tech-debt report must end with a `## Next Actions` section listing the smallest set of follow-ups in execution order. Use this exact shape:
277
+
278
+ ```markdown
279
+ ## Next Actions
280
+
281
+ | # | Action | Owner | Blocker? | Skill / Command |
282
+ |---|---|---|---|---|
283
+ | 1 | <imperative one-liner> | <team\|TBD> | yes/no | `/draft:<skill> <args>` or `n/a` |
284
+ ```
285
+
286
+ Rules:
287
+ - Tech-debt rarely "blocks" merge; mark `Blocker? = yes` only for items that will cause an outage on next deploy.
288
+ - Suggest `/draft:new-track` for items >1 day of work, `/draft:adr` for design re-decisions, `/draft:implement` for surgical cleanups.
289
+ - Cap at 10 actions; full backlog stays in the report body.
290
+
291
+ ## Mandatory Self-Check (before debt report)
292
+
293
+ Before printing the final debt report, internally verify and report:
294
+
295
+ 1. **Graph files queried** — JSONL files loaded plus any live graph query-tool invocations (especially `cycles` and `impact`).
296
+ 2. **Layer 1 files deliberately skipped** — list any context sections skipped as irrelevant to the categories scanned.
297
+ 3. **Filesystem grep fallback justification** — for every `grep`/`find` run beyond `scan-markers.sh`, name the concept it searched for.
298
+
299
+ If `draft/graph/schema.yaml` does not exist, set `Graph files queried: NONE` and use justification `graph data unavailable`.
300
+
301
+ ## Graph Usage Report (append to debt report)
302
+
303
+ 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.
304
+ ## Cross-Skill Dispatch
305
+
306
+ - **Offered by:** `/draft:new-track` (refactor tracks — scope the debt before planning)
307
+ - **Suggested by:** `/draft:implement` (when TODO/FIXME detected at completion)
308
+ - **Suggested by:** `/draft:deep-review` (architecture debt findings)
309
+ - **Feeds into:** `/draft:jira` (or `/draft:plan` for remediation tracks) (create remediation tickets from Tier 2 items)
310
+ - **Feeds into:** `/draft:testing-strategy` (Test Debt findings inform test planning)
311
+ - **Jira sync:** If ticket linked, attach report and post summary via `core/shared/jira-sync.md`
312
+
313
+ ## Error Handling
314
+
315
+ **If no draft context:** Run with reduced analysis, note: "Run `/draft:init` for better debt detection with accepted-pattern filtering"
316
+ **If tech-stack.md has accepted patterns:** Explicitly skip those patterns, note: "Skipped N accepted patterns from tech-stack.md"
317
+ **If >100 findings:** Group by category, show top 20 by priority in the summary, full list in Category Details section
318
+ **If module scope requested but module not found:** List available modules, ask user to confirm