@drafthq/draft 3.5.3 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/README.md +28 -49
  5. package/bin/README.md +47 -1
  6. package/cli/src/hosts/cursor.js +3 -0
  7. package/cli/src/installer.js +8 -4
  8. package/cli/src/lib/cursor-registry.js +10 -0
  9. package/cli/src/lib/fsx.js +3 -0
  10. package/cli/src/lib/marker.js +8 -3
  11. package/core/agents/architect.md +21 -9
  12. package/core/agents/debugger.md +5 -0
  13. package/core/agents/ops.md +7 -2
  14. package/core/agents/planner.md +7 -0
  15. package/core/agents/rca.md +14 -3
  16. package/core/agents/reviewer.md +1 -0
  17. package/core/agents/writer.md +6 -0
  18. package/core/knowledge-base.md +22 -3
  19. package/core/methodology.md +30 -5
  20. package/core/shared/condensation.md +28 -18
  21. package/core/shared/context-verify.md +3 -1
  22. package/core/shared/cross-skill-dispatch.md +7 -3
  23. package/core/shared/draft-context-loading.md +3 -0
  24. package/core/shared/git-report-metadata.md +2 -1
  25. package/core/shared/graph-query.md +24 -26
  26. package/core/shared/graph-usage-report.md +1 -1
  27. package/core/shared/jira-sync.md +10 -6
  28. package/core/shared/okf-retrieval.md +1 -1
  29. package/core/shared/parallel-analysis.md +14 -7
  30. package/core/shared/pattern-learning.md +2 -0
  31. package/core/shared/template-contract.md +1 -1
  32. package/core/shared/tool-resolver.md +20 -15
  33. package/core/shared/vcs-commands.md +5 -2
  34. package/core/templates/ai-context.md +3 -2
  35. package/core/templates/ai-profile.md +7 -0
  36. package/core/templates/architecture.md +6 -2
  37. package/core/templates/discovery.md +1 -1
  38. package/core/templates/guardrails.md +9 -0
  39. package/core/templates/hld.md +5 -4
  40. package/core/templates/intake-questions.md +45 -0
  41. package/core/templates/jira.md +11 -2
  42. package/core/templates/lld.md +8 -5
  43. package/core/templates/okf/concept.md +0 -1
  44. package/core/templates/plan.md +1 -1
  45. package/core/templates/product.md +11 -2
  46. package/core/templates/rca.md +6 -0
  47. package/core/templates/service-index.md +1 -0
  48. package/core/templates/spec.md +15 -0
  49. package/core/templates/tech-stack.md +12 -0
  50. package/core/templates/workflow.md +20 -0
  51. package/integrations/agents/AGENTS.md +1449 -817
  52. package/integrations/copilot/.github/copilot-instructions.md +1449 -817
  53. package/package.json +1 -1
  54. package/scripts/fetch-memory-engine.sh +25 -7
  55. package/scripts/lib.sh +90 -6
  56. package/scripts/tools/_graph_queries.sh +22 -8
  57. package/scripts/tools/_lib.sh +81 -11
  58. package/scripts/tools/adr-index.sh +1 -1
  59. package/scripts/tools/check-repo-size.sh +125 -0
  60. package/scripts/tools/check-skill-line-caps.sh +3 -4
  61. package/scripts/tools/check-template-noop.sh +0 -1
  62. package/scripts/tools/check-track-hygiene.sh +41 -21
  63. package/scripts/tools/classify-files.sh +3 -3
  64. package/scripts/tools/cycle-detect.sh +18 -17
  65. package/scripts/tools/detect-test-framework.sh +1 -1
  66. package/scripts/tools/emit-skill-metrics.sh +7 -2
  67. package/scripts/tools/fix-whitespace.sh +3 -0
  68. package/scripts/tools/freshness-check.sh +2 -2
  69. package/scripts/tools/git-metadata.sh +12 -6
  70. package/scripts/tools/graph-arch.sh +5 -11
  71. package/scripts/tools/graph-callers.sh +10 -15
  72. package/scripts/tools/graph-deps.sh +3 -10
  73. package/scripts/tools/graph-errors.sh +4 -11
  74. package/scripts/tools/graph-hierarchy.sh +4 -11
  75. package/scripts/tools/graph-impact.sh +21 -19
  76. package/scripts/tools/graph-init.sh +13 -9
  77. package/scripts/tools/graph-preflight.sh +4 -1
  78. package/scripts/tools/graph-query.sh +74 -18
  79. package/scripts/tools/graph-risk.sh +3 -10
  80. package/scripts/tools/graph-search.sh +4 -11
  81. package/scripts/tools/graph-snapshot.sh +38 -9
  82. package/scripts/tools/graph-snippet.sh +3 -10
  83. package/scripts/tools/graph-tests.sh +3 -10
  84. package/scripts/tools/graph-traces.sh +3 -10
  85. package/scripts/tools/hotspot-rank.sh +6 -12
  86. package/scripts/tools/install-smoke-test.sh +223 -0
  87. package/scripts/tools/mermaid-from-graph.sh +5 -11
  88. package/scripts/tools/migrate-track-frontmatter.sh +11 -10
  89. package/scripts/tools/okf-coverage-check.sh +8 -7
  90. package/scripts/tools/okf-emit-catalog.sh +256 -0
  91. package/scripts/tools/okf-fix-links.sh +251 -0
  92. package/scripts/tools/okf-plan-concepts.sh +242 -14
  93. package/scripts/tools/okf-render-views.sh +63 -21
  94. package/scripts/tools/okf-validate-all.sh +20 -9
  95. package/scripts/tools/okf-validate-quality.sh +15 -10
  96. package/scripts/tools/okf-validate.sh +20 -6
  97. package/scripts/tools/parse-git-log.sh +23 -5
  98. package/scripts/tools/parse-reports.sh +1 -1
  99. package/scripts/tools/render-track.sh +1 -1
  100. package/scripts/tools/resolve-tools.sh +24 -8
  101. package/scripts/tools/run-coverage.sh +1 -1
  102. package/scripts/tools/scan-markers.sh +4 -4
  103. package/scripts/tools/validate-frontmatter.sh +2 -2
  104. package/scripts/tools/verify-citations.sh +3 -4
  105. package/scripts/tools/verify-doc-anchors.sh +14 -34
  106. package/scripts/tools/verify-graph-binary.sh +15 -5
  107. package/skills/GRAPH.md +21 -10
  108. package/skills/adr/SKILL.md +25 -7
  109. package/skills/assist-review/SKILL.md +2 -1
  110. package/skills/bughunt/SKILL.md +55 -12
  111. package/skills/bughunt/references/regression-tests.md +14 -4
  112. package/skills/change/SKILL.md +19 -9
  113. package/skills/coverage/SKILL.md +28 -12
  114. package/skills/debug/SKILL.md +13 -3
  115. package/skills/decompose/SKILL.md +42 -12
  116. package/skills/deep-review/SKILL.md +19 -6
  117. package/skills/deploy-checklist/SKILL.md +10 -3
  118. package/skills/documentation/SKILL.md +12 -1
  119. package/skills/draft/SKILL.md +40 -29
  120. package/skills/draft/context-files.md +8 -1
  121. package/skills/draft/quality-guide.md +10 -2
  122. package/skills/graph/SKILL.md +2 -2
  123. package/skills/impact/SKILL.md +4 -2
  124. package/skills/implement/SKILL.md +62 -20
  125. package/skills/incident-response/SKILL.md +5 -2
  126. package/skills/init/SKILL.md +112 -30
  127. package/skills/init/references/architecture-spec.md +32 -8
  128. package/skills/init/references/okf-emitter.md +42 -78
  129. package/skills/jira/SKILL.md +33 -13
  130. package/skills/jira/references/review.md +61 -19
  131. package/skills/learn/SKILL.md +30 -7
  132. package/skills/new-track/SKILL.md +73 -18
  133. package/skills/quick-review/SKILL.md +8 -3
  134. package/skills/revert/SKILL.md +11 -5
  135. package/skills/review/SKILL.md +126 -27
  136. package/skills/review/references/zero-setup-mode.md +117 -0
  137. package/skills/standup/SKILL.md +10 -2
  138. package/skills/status/SKILL.md +7 -7
  139. package/skills/tech-debt/SKILL.md +9 -3
  140. package/skills/testing-strategy/SKILL.md +10 -2
  141. package/skills/tour/SKILL.md +2 -1
  142. package/skills/upload/SKILL.md +4 -3
  143. package/core/templates/track-architecture.md +0 -311
@@ -7,7 +7,7 @@ description: "Lists Draft's canonical workflow commands, explains the Context-Dr
7
7
 
8
8
  Draft is a methodology for structured software development: **Context → Spec & Plan → Implement → Verify**
9
9
 
10
- ## Red Flags - STOP if you're:
10
+ ## Red Flags - STOP if you're
11
11
 
12
12
  - Jumping straight to implementation without reading existing Draft context
13
13
  - Suggesting `/draft:implement` before a track has an approved spec and plan
@@ -22,16 +22,19 @@ Draft is a methodology for structured software development: **Context → Spec &
22
22
  ## Workflow Commands
23
23
 
24
24
  ### Canonical Workflow
25
- ```
25
+
26
+ ```text
26
27
  init → plan → implement → review → upload
27
28
  ↑ |
28
29
  └────────────┘ (review auto-invoked at phase boundaries)
29
30
  ```
30
31
 
31
32
  ### Primary Workflow (Parent) Commands
33
+
32
34
  These 7 canonical parent commands coordinate and orchestrate the entire development lifecycle, automatically routing to specialist subcommands when appropriate.
33
35
 
34
36
  ### Routed Core Workflows (5 routers)
37
+
35
38
  The 5 router commands provide intent-based dispatch into the 20+ specialist commands. Use the router form for discoverability; leaf commands remain supported for compatibility.
36
39
 
37
40
  | Router | Scope | Dispatches To (examples) |
@@ -47,39 +50,45 @@ The 5 router commands provide intent-based dispatch into the 20+ specialist comm
47
50
  ---
48
51
 
49
52
  ### Specialist & Subcommands
53
+
50
54
  These commands remain available for targeted, specialist execution outside parent command orchestration. **Every command below appears exactly once in this reference.**
51
55
 
52
56
  #### 1. Planning & Architecture
53
- * `/draft:new-track` - Create a new feature/bug track with structured `spec.md` and `plan.md`
54
- * `/draft:decompose` - Perform module-level decomposition with dependency mapping
55
- * `/draft:change` - Safely manage and document mid-track requirement changes and plan updates
56
- * `/draft:adr` - Write Architecture Decision Records to capture permanent technical choices
57
+
58
+ - `/draft:new-track` - Create a new feature/bug track with structured `spec.md` and `plan.md`
59
+ - `/draft:decompose` - Perform module-level decomposition with dependency mapping
60
+ - `/draft:change` - Safely manage and document mid-track requirement changes and plan updates
61
+ - `/draft:adr` - Write Architecture Decision Records to capture permanent technical choices
57
62
 
58
63
  #### 2. Quality & Testing
59
- * `/draft:quick-review` - Fast, lightweight 4-dimension code review for staged changes or diffs
60
- * `/draft:bughunt` - Exhaustive 14-dimension codebase-wide bug hunt with verification protocol
61
- * `/draft:deep-review` - Rigorous module-scoped lifecycle audit (ACID compliance, resilience)
62
- * `/draft:coverage` - Measure and report code coverage (targeting 95%+ for changed code)
63
- * `/draft:testing-strategy` - Design testing plan and identify coverage/mocking strategies
64
- * `/draft:learn` - Discover coding patterns from recent Git diffs and update `draft/guardrails.md`
64
+
65
+ - `/draft:quick-review` - Fast, lightweight 4-dimension code review for staged changes or diffs
66
+ - `/draft:bughunt` - Exhaustive 14-dimension codebase-wide bug hunt with verification protocol
67
+ - `/draft:deep-review` - Rigorous module-scoped lifecycle audit (ACID compliance, resilience)
68
+ - `/draft:coverage` - Measure and report code coverage (targeting 95%+ for changed code)
69
+ - `/draft:testing-strategy` - Design testing plan and identify coverage/mocking strategies
70
+ - `/draft:learn` - Discover coding patterns from recent Git diffs and update `draft/guardrails.md`
65
71
 
66
72
  #### 3. Operations & Debugging
67
- * `/draft:status` - Display a comprehensive overview of active track phases, tasks, and modules
68
- * `/draft:revert` - Safely roll back active tasks or commits using Git-aware tracking
69
- * `/draft:debug` - Structured 4-stage debugging flow (reproduce isolate diagnose → fix)
70
- * `/draft:standup` - Summarize git activity and file changes for standup reporting
71
- * `/draft:deploy-checklist` - Pre-deployment checklist verification with automated rollback triggers
72
- * `/draft:upload` - Pre-upload gate: review, HLD approvals, validator chain, then git upload/PR
73
- * `/draft:incident-response` - Coordinate incident lifecycle (triage mitigate postmortem)
73
+
74
+ - `/draft:status` - Display a comprehensive overview of active track phases, tasks, and modules
75
+ - `/draft:revert` - Safely roll back active tasks or commits using Git-aware tracking
76
+ - `/draft:debug` - Structured 4-stage debugging flow (reproduce isolate diagnose → fix)
77
+ - `/draft:standup` - Summarize git activity and file changes for standup reporting
78
+ - `/draft:deploy-checklist` - Pre-deployment checklist verification with automated rollback triggers
79
+ - `/draft:upload` - Pre-upload gate: review, HLD approvals, validator chain, then git upload/PR
80
+ - `/draft:incident-response` - Coordinate incident lifecycle (triage → mitigate → postmortem)
74
81
 
75
82
  #### 4. Setup & Documentation
76
- * `/draft` - Display this command overview and help reference
77
- * `/draft:init` - Single scope-aware entry point: builds the root-first code graph (`draft/graph/`) and project context; run at the repo root or inside any sub-module (monorepo context comes from running it at root)
78
- * `/draft:discover` - Phase 0 code-spike report (hotspots, mode flags, open questions) before spec freeze
79
- * `/draft:documentation` - Generate structured codebase documentation (API, Onboarding, Runbooks)
80
- * `/draft:tech-debt` - Audit technical debt across 6 key dimensions
83
+
84
+ - `/draft` - Display this command overview and help reference
85
+ - `/draft:init` - Single scope-aware entry point: builds the root-first code graph (`draft/graph/`) and project context; run at the repo root or inside any sub-module (monorepo context comes from running it at root)
86
+ - `/draft:discover` - Phase 0 code-spike report (hotspots, mode flags, open questions) before spec freeze
87
+ - `/draft:documentation` - Generate structured codebase documentation (API, Onboarding, Runbooks)
88
+ - `/draft:tech-debt` - Audit technical debt across 6 key dimensions
81
89
 
82
90
  **Integration:**
91
+
83
92
  | Command | Purpose |
84
93
  |---------|---------|
85
94
  | `/draft:jira` | Unified Jira workflows (preview / create / review) |
@@ -123,9 +132,10 @@ flowchart TD
123
132
  ## Actionability: Command Invocation Examples
124
133
 
125
134
  ### Example 1: `/draft:status`
135
+
126
136
  Parses active tracks, phases, tasks, and module mappings:
127
137
 
128
- ```
138
+ ```yaml
129
139
  PROJECT: Bookshelf API Service
130
140
 
131
141
  [track-042] OAuth2 Integration — [~] In Progress (Phase 2/3, 4/9 tasks)
@@ -137,9 +147,10 @@ PROJECT: Bookshelf API Service
137
147
  ```
138
148
 
139
149
  ### Example 2: `/draft:implement`
150
+
140
151
  Reads `plan.md`, picks the current incomplete task, and continues it (TDD-aware):
141
152
 
142
- ```
153
+ ```text
143
154
  Active track: [track-042] OAuth2 Integration
144
155
  Current task: [~] 2.1 Implement token generation endpoint
145
156
  TDD: on → writing tests/auth/token_generation_test.go (Red stage)
@@ -163,9 +174,9 @@ Used throughout `plan.md` files and referenced by the validation checkpoints abo
163
174
 
164
175
  You can also use natural language. Prefer the 5 router commands (`/draft:plan`, `/draft:ops`, `/draft:docs`, `/draft:discover`, `/draft:jira`) for grouped access; they analyze intent and dispatch.
165
176
 
166
- * **[quality-guide.md](./quality-guide.md)** — Quality Audit Spectrum, command choices, and coordination with external bug-hunting tools.
167
- * **[context-files.md](./context-files.md)** — Schema, role, and usage of each file inside the `draft/` context directory.
168
- * **[intent-mapping.md](./intent-mapping.md)** — Maps natural language phrasing to precise Draft commands for conversational AI usage.
177
+ - **[quality-guide.md](./quality-guide.md)** — Quality Audit Spectrum, command choices, and coordination with external bug-hunting tools.
178
+ - **[context-files.md](./context-files.md)** — Schema, role, and usage of each file inside the `draft/` context directory.
179
+ - **[intent-mapping.md](./intent-mapping.md)** — Maps natural language phrasing to precise Draft commands for conversational AI usage.
169
180
 
170
181
  ---
171
182
 
@@ -6,7 +6,7 @@ When the `draft/` directory exists at the root of a project, the files within it
6
6
 
7
7
  All context files reside in `draft/` at your project root:
8
8
 
9
- ```
9
+ ```text
10
10
  draft/
11
11
  ├── architecture.md # Full human engineering reference (Source of Truth)
12
12
  ├── .ai-context.md # Token-optimized AI context (derived automatically)
@@ -22,36 +22,43 @@ draft/
22
22
  ## Detailed File Reference
23
23
 
24
24
  ### 1. `draft/architecture.md` (Engineering Source of Truth)
25
+
25
26
  * **Purpose:** Comprehensive, human-readable reference detailing the system's design, domain model, services, module diagrams, and key data flows.
26
27
  * **When to read:** When designing new components, onboarding, or reviewing module boundaries.
27
28
  * **When to update:** After running decomposition, making major architectural changes, or completing an epic.
28
29
 
29
30
  ### 2. `draft/.ai-context.md` (Token-Optimized AI Context)
31
+
30
32
  * **Purpose:** A derived, lightweight (200-400 lines) copy of the architecture file designed specifically to maximize AI model efficiency. It omits verbose descriptions and captures essential system definitions, directory structures, and module APIs.
31
33
  * **When to read:** AI models read this automatically on every invocation to orient themselves.
32
34
  * **When to update:** Generated automatically whenever `draft/architecture.md` changes. Do not edit this file manually.
33
35
 
34
36
  ### 3. `draft/product.md` (Product & Business Vision)
37
+
35
38
  * **Purpose:** Defines the high-level business goals, core user personas, key workflows, success metrics, and long-term vision.
36
39
  * **When to read:** Before proposing features or starting plans, to verify alignment with business goals.
37
40
  * **When to update:** When product strategy changes or a new epic is initiated.
38
41
 
39
42
  ### 4. `draft/tech-stack.md` (Constraints & Stack Decisions)
43
+
40
44
  * **Purpose:** Records explicit details of the languages, frameworks, databases, libraries, deployment environment, and testing tools used. Contains absolute constraints (e.g., "No external ORMs allowed").
41
45
  * **When to read:** Before proposing libraries or deciding how to implement tasks.
42
46
  * **When to update:** When upgrading dependencies or making team-wide tech stack decisions.
43
47
 
44
48
  ### 5. `draft/workflow.md` (Work & Style Preferences)
49
+
45
50
  * **Purpose:** Outlines coding style conventions, test-driven development (TDD) rules, commit message guidelines, git branch naming schemes, and build scripts.
46
51
  * **When to read:** During implementation and review cycles to ensure compliance.
47
52
  * **When to update:** When adjusting developer processes, lint rules, or build tooling.
48
53
 
49
54
  ### 6. `draft/guardrails.md` (Learned Patterns & Anti-Patterns)
55
+
50
56
  * **Purpose:** Stores positive code conventions and negative anti-patterns discovered during development. This serves as an automated memory for the AI.
51
57
  * **When to read:** Before coding to avoid repeating common codebase-specific mistakes.
52
58
  * **When to update:** Run `/draft:learn` to automatically extract rules from your Git diffs or write them manually when discovering a repeated bug.
53
59
 
54
60
  ### 7. `draft/tracks.md` (Track Registry)
61
+
55
62
  * **Purpose:** Registers all active, completed, and blocked tracks (feature or bug fixes). Contains IDs, descriptions, and current status markers.
56
63
  * **When to read:** Before planning new work to prevent duplication, or when generating status reports.
57
64
  * **When to update:** Automatically updated by `/draft:plan` and `/draft:status`.
@@ -16,26 +16,34 @@ This guide helps you choose the most effective quality control and review comman
16
16
  ## Command Decision Guide
17
17
 
18
18
  ### 1. Fast Feedback / Pre-Commit Sanity Check
19
+ >
19
20
  > [!TIP]
20
21
  > Use **`/draft:quick-review`** when you want a fast, lightweight sanity check of your modified files before opening a PR or running full reviews.
22
+
21
23
  - **When to run:** Before staging changes, during local development loops.
22
24
  - **Why:** Zero setup, rapid turnaround, checks standard dimensions (security, performance, styling).
23
25
 
24
26
  ### 2. Track Completion & Pull Request Quality Gate
27
+ >
25
28
  > [!IMPORTANT]
26
29
  > Use **`/draft:review`** (the canonical review command) when you finish a development phase or an entire track.
30
+
27
31
  - **When to run:** Before submitting work for final PR approval.
28
32
  - **Why:** It validates the implementation directly against the active track's `spec.md` and `plan.md` to ensure all acceptance criteria and quality gates are met. It also auto-invokes coverage checks when TDD is active.
29
33
 
30
34
  ### 3. Debugging Hard-to-Find Defects or Refactoring
35
+ >
31
36
  > [!WARNING]
32
37
  > Use **`/draft:bughunt`** if you are encountering elusive bugs, regression errors, or before refactoring a legacy module.
38
+
33
39
  - **When to run:** Prior to refactoring complex areas, or when users report intermittent production bugs.
34
40
  - **Why:** Conducts a deep, 14-dimension sweep specifically designed to surface edge cases, race conditions, memory leaks, and logic flaws.
35
41
 
36
42
  ### 4. Shipping Core Infrastructure to Production
43
+ >
37
44
  > [!CAUTION]
38
45
  > Use **`/draft:deep-review`** before launching a critical service, API, database layer, or high-throughput component.
46
+
39
47
  - **When to run:** Before major deployments or architectural sign-offs.
40
48
  - **Why:** Audits the architecture for ACID compliance, concurrency safety, fault tolerance, rate limiting, and telemetry, providing a formal readiness score.
41
49
 
@@ -45,7 +53,7 @@ This guide helps you choose the most effective quality control and review comman
45
53
 
46
54
  Many AI tools and editors provide built-in bug-hunting agents (such as Claude Code's native `bughunt` or other automated scanners). Draft's quality commands are designed to be **complementary**:
47
55
 
48
- * **Built-in Agents:** Typically focus on fast, generic static analysis, automated linting, and rapid parallel auto-fixes.
49
- * **Draft Quality Commands:** Leverage project-specific context (including `draft/architecture.md`, `draft/product.md`, `draft/tech-stack.md`, and `draft/guardrails.md`). This eliminates false positives and ensures findings align with your specific domain constraints, team conventions, and technical stack choices.
56
+ - **Built-in Agents:** Typically focus on fast, generic static analysis, automated linting, and rapid parallel auto-fixes.
57
+ - **Draft Quality Commands:** Leverage project-specific context (including `draft/architecture.md`, `draft/product.md`, `draft/tech-stack.md`, and `draft/guardrails.md`). This eliminates false positives and ensures findings align with your specific domain constraints, team conventions, and technical stack choices.
50
58
 
51
59
  For maximum quality assurance, run built-in scanners in parallel with Draft commands!
@@ -7,7 +7,7 @@ description: Initialize or refresh the knowledge-graph snapshot for a repository
7
7
 
8
8
  Initialize or refresh the `draft/graph/` knowledge-graph snapshot for a single repository. This is the narrow "give me a fresh structural graph" command — it does **not** generate `architecture.md`/`.ai-context.md` and does **not** re-inject doc diagram slots (both are `/draft:init`). For scope-aware, root-first graph memory across a monorepo (root spine + module→root links), use `/draft:init --graph-only`.
9
9
 
10
- ## Red Flags - STOP if you're:
10
+ ## Red Flags - STOP if you're
11
11
 
12
12
  - Reporting counts without actually running `graph-snapshot.sh`
13
13
  - Claiming the graph is built when the engine was unavailable
@@ -37,7 +37,7 @@ echo "Target repo: $REPO_ABS"
37
37
  # Locate Draft's bundled helpers. Skills run with cwd = the user's project and
38
38
  # ${CLAUDE_PLUGIN_ROOT} is not exported into skill Bash, so resolve DRAFT_TOOLS here
39
39
  # and call helpers as "$DRAFT_TOOLS/<tool>.sh". See core/shared/tool-resolver.md.
40
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
40
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
41
41
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
42
42
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
43
43
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -7,7 +7,8 @@ description: Generate a project-wide impact report on Draft track delivery — p
7
7
 
8
8
  Generate a project-wide impact report measuring Context-Driven Development effectiveness across all tracks.
9
9
 
10
- ## Red Flags - STOP if you're:
10
+ ## Red Flags - STOP if you're
11
+
11
12
  - Profiling code coverage instead of measuring track-level impact.
12
13
  - Rewriting tracker logic when local state objects are available for inspection.
13
14
  - Generating reports without reading existing track metadata first.
@@ -21,7 +22,7 @@ First resolve the bundled helpers:
21
22
  ```bash
22
23
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
23
24
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
24
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
25
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
25
26
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
26
27
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
27
28
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -92,6 +93,7 @@ Every impact/telemetry report must end with a `## Next Actions` section listing
92
93
  ```
93
94
 
94
95
  Rules:
96
+
95
97
  - Impact reports are advisory — `Blocker? = no` is the default; mark `yes` only when a metric breach demands immediate process change.
96
98
  - Suggest `/draft:tech-debt` for systemic friction, `/draft:adr` for methodology adjustments, `/draft:tour` for onboarding gaps.
97
99
  - Cap at 7 actions.
@@ -15,7 +15,7 @@ It owns the common execution loop and absorbs three adjacent commands when appro
15
15
  - `/draft:coverage`
16
16
  - `/draft:revert`
17
17
 
18
- ## Red Flags - STOP if you're:
18
+ ## Red Flags - STOP if you're
19
19
 
20
20
  - Implementing without an approved spec and plan
21
21
  - Skipping TDD cycle when workflow.md has TDD enabled
@@ -139,7 +139,7 @@ If one of these applies, route directly to the specialist workflow and stop this
139
139
  ```bash
140
140
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
141
141
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
142
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
142
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
143
143
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
144
144
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
145
145
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -152,9 +152,11 @@ If one of these applies, route directly to the specialist workflow and stop this
152
152
  10. Update the track's entry in `draft/tracks.md` from `[ ]` to `[~]` In Progress
153
153
 
154
154
  If no active track found:
155
+
155
156
  - Tell user: "No active track found. Run `/draft:plan` to create or resume planned work."
156
157
 
157
158
  **Architecture / Design Mode Activation:**
159
+
158
160
  - Automatically enabled when `.ai-context.md`, graph-primary `architecture.md`, or track `hld.md`/`lld.md` exists.
159
161
  - Project-level context from `/draft:init`.
160
162
  - Track-level design docs from `/draft:decompose`.
@@ -168,21 +170,25 @@ Run once, before the first task of a new track:
168
170
  ### AC Coverage Check
169
171
 
170
172
  For each acceptance criterion in `spec.md`:
173
+
171
174
  - Verify at least one task in `plan.md` references or addresses it
172
175
  - If an AC has no corresponding task, flag it: "⚠️ AC: '[criterion]' has no task in plan.md"
173
176
 
174
177
  ### Sync Check (if `.ai-context.md` exists)
175
178
 
176
179
  Compare the `synced_to_commit` values in the YAML frontmatter of `spec.md` and `plan.md`.
180
+
177
181
  - **Skip if** either file has no YAML frontmatter or no `synced_to_commit` field (quick-mode tracks omit it).
178
182
  - If they differ: "⚠️ Spec and plan were synced to different commits — verify they are still aligned."
179
183
 
180
184
  ### Result
181
185
 
182
186
  **Issues found:** List them, then ask:
183
- ```
187
+
188
+ ```text
184
189
  Readiness issues found (see above). Proceed anyway or update first? [proceed/update]
185
190
  ```
191
+
186
192
  - `proceed` → add a `## Notes` entry in `plan.md` listing the issues, then continue to Step 2
187
193
  - `update` → stop here and let the user refine spec or plan before re-running
188
194
 
@@ -201,7 +207,8 @@ Before starting TDD cycle for the first task:
201
207
  ### Bug Track Test Guardrail
202
208
 
203
209
  If track type is `bugfix` (from metadata.json):
204
- ```
210
+
211
+ ```text
205
212
  BEFORE writing any test file:
206
213
  ASK: "This is a bug fix track. Want me to write tests as part of the fix? [Y/n]"
207
214
  If declined: skip TDD cycle, note in plan.md: "Tests: developer-handled"
@@ -210,12 +217,14 @@ BEFORE writing any test file:
210
217
  ## Step 2: Find Next Task
211
218
 
212
219
  Scan `plan.md` for the first uncompleted task:
220
+
213
221
  - `[ ]` = Pending (pick this one)
214
222
  - `[~]` = In Progress (resume this one)
215
223
  - `[x]` = Completed (skip)
216
224
  - `[!]` = Blocked (skip - requires manual intervention)
217
225
 
218
226
  **IMPORTANT:** If blocked task found, notify user:
227
+
219
228
  - "Task [task description] is marked `[!]` Blocked"
220
229
  - Show the blocked task details and recovery message
221
230
  - "Resolve the blockage manually before continuing implementation"
@@ -274,7 +283,7 @@ When the next task involves creating or substantially modifying a code file:
274
283
 
275
284
  ### Story Format
276
285
 
277
- ```
286
+ ```text
278
287
  // Story: [Module/File Name]
279
288
  //
280
289
  // Input: [what this module/function receives]
@@ -320,7 +329,8 @@ Study the control flow for the task and propose intermediate state variables:
320
329
  5. Propose execution state: input state, intermediate state, output state, error state
321
330
 
322
331
  Present in this format:
323
- ```
332
+
333
+ ```text
324
334
  EXECUTION STATE: [Task/Module Name]
325
335
  ─────────────────────────────────────────────────────────
326
336
  Input State:
@@ -435,12 +445,13 @@ For each task, follow this workflow based on `workflow.md`. If skeletons were ge
435
445
 
436
446
  When refactoring code that lacks tests, write characterization tests first to capture current behavior as a baseline. Identify seams (interfaces for test doubles, swappable imports), record actual outputs for representative inputs, then proceed with the TDD cycle for new behavior.
437
447
 
438
- ### If TDD Enabled:
448
+ ### If TDD Enabled
439
449
 
440
450
  **Iron Law:** No production code without a failing test first.
441
451
 
442
452
  **3a. RED - Write Failing Test**
443
- ```
453
+
454
+ ```text
444
455
  1. Create/update test file as specified in task
445
456
  2. Write test that captures the requirement
446
457
  3. RUN test - VERIFY it FAILS (not syntax error, actual assertion failure)
@@ -449,6 +460,7 @@ When refactoring code that lacks tests, write characterization tests first to ca
449
460
  ```
450
461
 
451
462
  **Test Quality Checklist (REQUIRED for every test):**
463
+
452
464
  - No shared mutable state between test cases — each test sets up its own state
453
465
  - Assertion density: every test must have at least one meaningful assertion (not just `assertTrue(true)`)
454
466
  - No logic in tests: no conditionals, loops, or try/catch in test code — tests should be trivially readable
@@ -461,7 +473,8 @@ When refactoring code that lacks tests, write characterization tests first to ca
461
473
  After writing example-based tests, consider property-based tests for pure functions (algebraic properties, round-trip serialization, sort invariants). Not mandatory — skip if properties are not obvious.
462
474
 
463
475
  **3b. GREEN - Implement Minimum Code**
464
- ```
476
+
477
+ ```text
465
478
  1. Write MINIMUM code to make test pass (no extras)
466
479
  2. RUN test - VERIFY it PASSES
467
480
  3. Show test output with pass
@@ -475,7 +488,8 @@ Structured logging at decision points, metrics for latency-sensitive ops, tracin
475
488
  For new API endpoints or service-to-service interfaces, suggest consumer-driven contract tests. Skip for purely internal modules.
476
489
 
477
490
  **3c. REFACTOR - Clean with Tests Green**
478
- ```
491
+
492
+ ```text
479
493
  1. Review code for improvements
480
494
  2. Refactor while keeping tests green
481
495
  3. RUN all related tests after each change
@@ -484,15 +498,17 @@ For new API endpoints or service-to-service interfaces, suggest consumer-driven
484
498
  ```
485
499
 
486
500
  **Red Flags - STOP and restart the cycle if:**
501
+
487
502
  - About to write code before test exists
488
503
  - Test passes immediately (testing wrong thing)
489
504
  - Thinking "just this once" or "too simple to test"
490
505
  - Running tests mentally instead of actually executing
491
506
 
492
- ### If TDD Not Enabled:
507
+ ### If TDD Not Enabled
493
508
 
494
509
  **3a. Implement**
495
- ```
510
+
511
+ ```text
496
512
  1. Implement the task as specified
497
513
  2. Test manually or run existing tests
498
514
  3. Announce: "Implementation complete"
@@ -571,6 +587,7 @@ Before marking ANY task/phase/track complete:
571
587
  - If **YES**: Show evidence, then mark `[x]`
572
588
 
573
589
  **Red Flags - STOP if you're thinking:**
590
+
574
591
  - "Should pass", "probably works"
575
592
  - Satisfaction before running verification
576
593
  - About to mark `[x]` without fresh evidence from this session
@@ -588,16 +605,19 @@ When all tasks in a phase are `[x]`:
588
605
  ### Three-Stage Review (REQUIRED)
589
606
 
590
607
  **Stage 1: Automated Validation**
608
+
591
609
  - Fast static checks: architecture conformance, dead code, circular dependencies, performance anti-patterns. Review for common security anti-patterns (OWASP top 10). For automated checks, use language-specific tools (e.g., `npm audit` for JS, `bandit` for Python, `cargo audit` for Rust).
592
610
  - **If critical issues found:** List them, return to implementation
593
611
 
594
612
  **Stage 2: Spec Compliance** (only if Stage 1 passes)
613
+
595
614
  - Load track's `spec.md`
596
615
  - Verify all requirements for this phase are implemented
597
616
  - Check acceptance criteria coverage
598
617
  - **If gaps found:** List them, return to implementation
599
618
 
600
619
  **Stage 3: Code Quality** (only if Stage 2 passes)
620
+
601
621
  - Verify code follows project patterns (tech-stack.md)
602
622
  - Check error handling is appropriate
603
623
  - Verify tests cover real logic
@@ -608,12 +628,14 @@ See `core/agents/reviewer.md` for detailed review process.
608
628
  ### Quick Review Alternative
609
629
 
610
630
  At phase boundaries, offer the lightweight alternative:
611
- ```
631
+
632
+ ```text
612
633
  "Phase {N} complete. Review options:
613
634
  1. Full three-stage review (recommended) — spec compliance + security + quality
614
635
  2. /draft:quick-review — lightweight 4-dimension check (faster)
615
636
  Choose [1/2, default: 1]:"
616
637
  ```
638
+
617
639
  If quick-review chosen, invoke `/draft:quick-review` with the phase's changed files.
618
640
 
619
641
  2. Run verification steps from plan (tests, builds)
@@ -632,19 +654,23 @@ If quick-review chosen, invoke `/draft:quick-review` with the phase's changed fi
632
654
  After a phase passes review, refresh `metadata.json.impact` so future tracks can detect overlap with this work.
633
655
 
634
656
  1. **Compute touched files:** From `plan.md`, find the first commit SHA recorded for this track (earliest `[x]` line with `(<sha>)`). Run:
657
+
635
658
  ```bash
636
659
  git diff --name-only <first_sha>^..HEAD
637
660
  ```
661
+
638
662
  That is the `files_touched` list. Derive `modules_touched` as the unique top-level path segments (e.g. `auth/login.go` → `auth`).
639
663
 
640
664
  2. **Compute downstream blast radius (graph-aware, optional):** If `draft/graph/schema.yaml` exists, for each file in `files_touched` query (this runs in its own Bash session — re-resolve the helpers):
665
+
641
666
  ```bash
642
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
667
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
643
668
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
644
669
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
645
670
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
646
671
  "$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>
647
672
  ```
673
+
648
674
  Aggregate across all files: `downstream_files` = total unique downstream files (deduped), `downstream_modules` = union of `affected_modules`, `max_depth` = max across queries, `by_category` = sum of each query's `by_category`. If the graph is absent, leave these fields as zeros / empty arrays — the snapshot still records the directly-touched files.
649
675
 
650
676
  3. **Write metadata.json** with the populated `impact` block and `computed_at` set to the current timestamp.
@@ -658,10 +684,12 @@ When all phases complete:
658
684
  1. **Run review (if enabled):**
659
685
  - Read `draft/workflow.md` review configuration
660
686
  - Check if auto-review enabled:
687
+
661
688
  ```markdown
662
689
  ## Review Settings
663
690
  - [x] Auto-review at track completion
664
691
  ```
692
+
665
693
  - If enabled, run `/draft:review track <track_id>`
666
694
  - Check review results:
667
695
  - If block-on-failure enabled AND critical issues found → HALT, require fixes
@@ -687,6 +715,7 @@ When all phases complete:
687
715
  "Track <track_id> completed!
688
716
 
689
717
  Summary:
718
+
690
719
  - Phases: N/N
691
720
  - Tasks: M/M
692
721
  - Duration: [if tracked]
@@ -702,6 +731,7 @@ Next: Run `/draft:status` to see project overview."
702
731
  ## Error Handling
703
732
 
704
733
  **If blocked:**
734
+
705
735
  - Mark task as `[!]` Blocked
706
736
  - Add reason in plan.md
707
737
  - **REQUIRED:** Follow systematic debugging process (see `core/agents/debugger.md`)
@@ -713,18 +743,22 @@ Next: Run `/draft:status` to see project overview."
713
743
  - Document root cause when found
714
744
 
715
745
  **Recommended:** Instead of inline debugging, invoke `/draft:debug` skill for a structured session:
716
- ```
746
+
747
+ ```text
717
748
  "Task blocked: {description}. Run /draft:debug for structured investigation? [Y/n]"
718
749
  ```
750
+
719
751
  The debug skill provides: Reproduce → Isolate → Diagnose → Fix methodology with debug report output.
720
752
 
721
753
  **If test fails unexpectedly:**
754
+
722
755
  - Don't mark complete
723
756
  - Follow systematic debugging process above
724
757
  - Announce failure details with root cause analysis
725
758
  - Show evidence when resolved
726
759
 
727
760
  **If unsure about implementation:**
761
+
728
762
  - Ask clarifying questions
729
763
  - Reference spec.md for requirements
730
764
  - Don't proceed with assumptions
@@ -748,6 +782,7 @@ When you encounter a shortcut, workaround, or known-imperfect solution during im
748
782
  ```
749
783
 
750
784
  **Severity levels:**
785
+
751
786
  - **Low** — Cosmetic or minor maintainability issue
752
787
  - **Medium** — Will cause problems at scale or in specific scenarios
753
788
  - **High** — Actively impeding development or risking production issues
@@ -761,7 +796,8 @@ Only log genuine debt — intentional shortcuts with known consequences. Not eve
761
796
  ## Progress Reporting
762
797
 
763
798
  After each task, report:
764
- ```
799
+
800
+ ```yaml
765
801
  Task: [description]
766
802
  Status: Complete
767
803
  Phase Progress: N/M tasks
@@ -777,34 +813,40 @@ Overall: X% complete
777
813
  After announcing track completion, suggest relevant follow-ups based on context:
778
814
 
779
815
  **If track modifies production code:**
780
- ```
816
+
817
+ ```text
781
818
  "Track complete! Consider:
782
819
  → /draft:deploy-checklist — Pre-deployment verification"
783
820
  ```
784
821
 
785
822
  **If track added new APIs/services/components:**
786
- ```
823
+
824
+ ```text
787
825
  → /draft:documentation — Update documentation for new components"
788
826
  ```
789
827
 
790
828
  **If implementation contains TODO/FIXME/HACK comments:**
791
- ```
829
+
830
+ ```text
792
831
  → /draft:tech-debt — Catalog any new technical debt introduced"
793
832
  ```
794
833
 
795
834
  **If new patterns or dependencies not in tech-stack.md:**
796
- ```
835
+
836
+ ```text
797
837
  → /draft:adr — Document this design decision"
798
838
  ```
799
839
 
800
840
  ### Jira Sync at Completion
801
841
 
802
842
  If Jira ticket linked, sync via `core/shared/jira-sync.md`:
843
+
803
844
  - Post comment: "[draft] implementation-complete: All {n} tasks done. Ready for review."
804
845
 
805
846
  ### Bug Track with rca.md
806
847
 
807
848
  If implementing a bug track and `draft/tracks/<id>/rca.md` exists:
849
+
808
850
  - Load rca.md as context for the implementation
809
851
  - Reference root cause, blast radius, and prevention items during fix
810
852
  - After fix: update rca.md "Proposed Fix" section with actual fix details