@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,42 @@
1
+ ---
2
+ name: docs
3
+ description: "Primary router for authoring and documentation workflows. Analyzes intent and dispatches primarily to documentation (technical docs, readme, runbook, api, onboarding). Use when the user needs to generate or update project documentation."
4
+ ---
5
+
6
+ # Docs - Authoring & Documentation Router
7
+
8
+ `/draft:docs` provides a single namespace for all documentation generation and maintenance tasks.
9
+
10
+ ## When to Use
11
+
12
+ - Generating or refreshing README, API docs, runbooks, or onboarding guides
13
+ - Producing technical documentation from existing architecture and code context
14
+ - Keeping documentation in sync after implementation or review phases
15
+
16
+ ## Routing Logic
17
+
18
+ Currently focused on the documentation specialist. Future expansion may include additional authoring helpers under the same router.
19
+
20
+ | User Intent Keywords | Dispatches To | Purpose |
21
+ |---------------------------------------------|-----------------------|---------|
22
+ | write docs, documentation, readme, runbook, api docs, onboarding guide, generate docs | `/draft:documentation` | Technical documentation authoring (readme, runbook, api, onboarding) |
23
+
24
+ ## Dispatch Examples
25
+
26
+ User: "write a README for the new service"
27
+
28
+ → dispatches to `/draft:documentation readme`
29
+
30
+ User: "generate an API reference and runbook for the billing module"
31
+
32
+ → dispatches to `/draft:documentation api runbook`
33
+
34
+ User: "create onboarding guide for new engineers"
35
+
36
+ → dispatches to `/draft:documentation onboarding`
37
+
38
+ ## Notes
39
+
40
+ The documentation command reads heavily from `draft/architecture.md`, `draft/.ai-context.md`, `draft/product.md`, and `draft/tech-stack.md` (plus graph artifacts when present).
41
+
42
+ Prefer `/draft:docs` going forward for all authoring requests. The legacy direct form remains for compatibility (see migration guidance).
@@ -0,0 +1,197 @@
1
+ ---
2
+ name: documentation
3
+ description: Technical documentation writing and maintenance. Modes — readme, runbook, api, onboarding. Uses writer agent principles for audience-appropriate, maintainable docs.
4
+ ---
5
+
6
+ # Documentation
7
+
8
+ You are generating or updating technical documentation for this project using structured writing principles.
9
+
10
+ ## Red Flags — STOP if you're:
11
+
12
+ - Writing docs without reading the code first
13
+ - Duplicating information that exists elsewhere (link instead)
14
+ - Writing docs for internal implementation details (only public interfaces)
15
+ - Ignoring the target audience (developer vs operator vs new hire)
16
+ - Generating a wall of text without structure or examples
17
+
18
+ **Write for the reader. Link don't duplicate. Show don't tell.**
19
+
20
+ ---
21
+
22
+ ## Pre-Check
23
+
24
+ 1. Check for Draft context:
25
+ ```bash
26
+ ls draft/ 2>/dev/null
27
+ ```
28
+
29
+ If `draft/` doesn't exist, this skill works standalone — generate docs from code analysis.
30
+
31
+ 2. Follow the base procedure in `core/shared/draft-context-loading.md`.
32
+
33
+ ## Step 1: Parse Arguments
34
+
35
+ - `/draft:documentation readme` — Generate or update project README
36
+ - `/draft:documentation runbook <service>` — Operations runbook for a service
37
+ - `/draft:documentation api <module>` — API documentation for a module
38
+ - `/draft:documentation onboarding` — New developer onboarding guide
39
+ - `/draft:documentation` (no args) — Interactive: ask what type of documentation
40
+
41
+ ## Step 2: Gather Source Material
42
+
43
+ ### README Mode
44
+ - Read existing `README.md` (if any)
45
+ - Read `draft/product.md` — Product vision, users, goals
46
+ - Read `draft/tech-stack.md` — Technologies, setup requirements
47
+ - Read `draft/workflow.md` — Development workflow, commands
48
+ - Scan for `Makefile`, `package.json`, `pyproject.toml` — Build/run commands
49
+
50
+ ### Runbook Mode
51
+ - Read `draft/architecture.md` or `draft/.ai-context.md` — Service topology, dependencies
52
+ - Read `draft/workflow.md` — Deployment conventions
53
+ - Read `draft/tech-stack.md` — Infrastructure details
54
+ - If GitHub MCP available: check recent deployment changes
55
+ - If Jira MCP available: check recent incident tickets for the service
56
+
57
+ ### API Mode
58
+ - Read source code for public interfaces, exported functions, API routes
59
+ - Read existing API docs (Swagger, OpenAPI, JSDoc, docstrings)
60
+ - Read `draft/architecture.md` — API conventions, data models
61
+ - Read `draft/tech-stack.md` — API framework details
62
+
63
+ ### Onboarding Mode
64
+ - Read ALL draft context files in order:
65
+ 1. `draft/product.md` — What is this project?
66
+ 2. `draft/tech-stack.md` — What technologies?
67
+ 3. `draft/architecture.md` or `draft/.ai-context.md` — How is it structured?
68
+ 4. `draft/workflow.md` — How do I develop?
69
+ 5. `draft/guardrails.md` — What to watch out for?
70
+ - Scan for setup scripts, Docker configs, environment templates
71
+
72
+ ## Step 3: Apply Writing Principles
73
+
74
+ Follow these principles (from `core/agents/writer.md`):
75
+
76
+ 1. **Write for the reader** — Identify the audience (developer, operator, new hire) and tailor language, depth, and examples accordingly
77
+ 2. **Start with the most useful information** — Lead with what the reader needs most (setup for README, troubleshooting for runbook, endpoints for API)
78
+ 3. **Show don't tell** — Use code examples, command snippets, and diagrams over prose descriptions
79
+ 4. **Progressive disclosure** — Start simple, add detail progressively. Don't front-load every edge case
80
+ 5. **Link don't duplicate** — Reference existing docs, don't copy them. Single source of truth
81
+ 6. **Keep current** — Reference source of truth files. Note: "Generated from draft context on {date}"
82
+
83
+ ## Step 4: Generate Document
84
+
85
+ ### README Structure
86
+ ```markdown
87
+ # {Project Name}
88
+
89
+ {One-line description from product.md}
90
+
91
+ ## Quick Start
92
+ {Setup commands from Makefile/package.json}
93
+
94
+ ## Architecture
95
+ {High-level diagram from .ai-context.md}
96
+
97
+ ## Development
98
+ {Commands from workflow.md}
99
+
100
+ ## Testing
101
+ {Test commands and conventions}
102
+
103
+ ## Contributing
104
+ {Workflow conventions}
105
+ ```
106
+
107
+ ### Runbook Structure
108
+ ```markdown
109
+ # Runbook: {Service Name}
110
+
111
+ ## Overview
112
+ {Service purpose, dependencies, SLOs}
113
+
114
+ ## Health Checks
115
+ {Endpoints, expected responses}
116
+
117
+ ## Common Issues
118
+ {Symptoms → diagnosis → resolution}
119
+
120
+ ## Deployment
121
+ {Steps, rollback procedure}
122
+
123
+ ## Monitoring
124
+ {Dashboard URLs, alert descriptions}
125
+
126
+ ## Escalation
127
+ {On-call contacts, escalation paths}
128
+ ```
129
+
130
+ ### API Documentation Structure
131
+ ```markdown
132
+ # API: {Module Name}
133
+
134
+ ## Overview
135
+ {Purpose, authentication, base URL}
136
+
137
+ ## Endpoints
138
+
139
+ ### {METHOD} {path}
140
+ {Description}
141
+ **Request:** {body/params with examples}
142
+ **Response:** {status codes with examples}
143
+ **Errors:** {error codes and meanings}
144
+ ```
145
+
146
+ ### Onboarding Structure
147
+ ```markdown
148
+ # Welcome to {Project Name}
149
+
150
+ ## What is this?
151
+ {From product.md — 2-3 sentences}
152
+
153
+ ## Architecture at a Glance
154
+ {Simplified from .ai-context.md}
155
+
156
+ ## Getting Started
157
+ {Setup steps, first 15 minutes}
158
+
159
+ ## Key Concepts
160
+ {Domain terms, important patterns}
161
+
162
+ ## Development Workflow
163
+ {From workflow.md}
164
+
165
+ ## Where to Find Things
166
+ {File structure guide}
167
+
168
+ ## Common Pitfalls
169
+ {From guardrails.md}
170
+ ```
171
+
172
+ ## Step 5: Output
173
+
174
+ Save to:
175
+ - README: `README.md` in project root
176
+ - Runbook: `draft/docs/runbook-<service>.md`
177
+ - API: `draft/docs/api-<module>.md`
178
+ - Onboarding: `draft/docs/onboarding.md`
179
+
180
+ Create `draft/docs/` directory if needed.
181
+
182
+ **Pre-save validation:**
183
+ - Every file path referenced in the doc resolves to a real file (broken links are a common LLM failure mode here).
184
+ - Every relative link in the doc resolves under the project root.
185
+ - Code blocks copied from sources match the current commit (no stale snippets).
186
+
187
+ Present generated doc to user for review before final save.
188
+
189
+ ## Cross-Skill Dispatch
190
+
191
+ - **Suggested by:** `/draft:init` (after context generation), `/draft:implement` (track completion with new APIs), `/draft:upload` (pre-upload for new APIs), `/draft:decompose` (module API docs)
192
+ - **Jira sync:** If ticket linked, attach doc and post comment via `core/shared/jira-sync.md`
193
+
194
+ ## Error Handling
195
+
196
+ **If no draft context:** Generate from code analysis alone, note: "Run `/draft:init` for richer documentation"
197
+ **If existing doc found:** Show diff between existing and generated, ask: "Update existing doc or create new? [update/new]"
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: draft
3
+ description: "Lists Draft's canonical workflow commands, explains the Context-Driven Development flow (init, plan, implement, review), and recommends the appropriate next step. Use when the user asks about available Draft commands, needs help choosing a workflow step, or says 'what can Draft do', 'help', or 'show commands'."
4
+ ---
5
+
6
+ # Draft - Context-Driven Development
7
+
8
+ Draft is a methodology for structured software development: **Context → Spec & Plan → Implement → Verify**
9
+
10
+ ## Red Flags - STOP if you're:
11
+
12
+ - Jumping straight to implementation without reading existing Draft context
13
+ - Suggesting `/draft:implement` before a track has an approved spec and plan
14
+ - Not checking `draft/tracks.md` for existing active tracks before creating new ones
15
+ - Skipping the recommended command and going freeform
16
+ - Ignoring existing `.ai-context.md`, `product.md`, `tech-stack.md`, or `workflow.md` context
17
+
18
+ **Read context first. Follow the workflow.**
19
+
20
+ ---
21
+
22
+ ## Workflow Commands
23
+
24
+ ### Canonical Workflow
25
+ ```
26
+ init → plan → implement → review → upload
27
+ ↑ |
28
+ └────────────┘ (review auto-invoked at phase boundaries)
29
+ ```
30
+
31
+ ### Primary Workflow (Parent) Commands
32
+ These 7 canonical parent commands coordinate and orchestrate the entire development lifecycle, automatically routing to specialist subcommands when appropriate.
33
+
34
+ ### Routed Core Workflows (5 routers)
35
+ 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
+
37
+ | Router | Scope | Dispatches To (examples) |
38
+ |--------|-------|--------------------------|
39
+ | `/draft:plan` | Planning & architecture | new-track, decompose, adr, tech-debt, change |
40
+ | `/draft:ops` | Operations & lifecycle | deploy-checklist, incident-response, standup, status, revert |
41
+ | `/draft:docs` | Authoring | documentation |
42
+ | `/draft:discover` | Investigation & quality | debug, bughunt, quick/deep-review, coverage, testing-strategy, learn, index, tour, impact, assist-review |
43
+ | `/draft:jira` | Jira integration (preview, create, review) | - |
44
+
45
+ ### Specialist Commands (leaf skills, invoked via routers or directly)
46
+
47
+ ---
48
+
49
+ ### Specialist & Subcommands
50
+ These commands remain available for targeted, specialist execution outside parent command orchestration. **Every command below appears exactly once in this reference.**
51
+
52
+ #### 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
+ #### 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`
65
+
66
+ #### 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)
74
+
75
+ #### 4. Setup & Documentation
76
+ * `/draft` - Display this command overview and help reference
77
+ * `/draft:index` - Aggregate multi-service context in monorepo structures
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
81
+
82
+ **Integration:**
83
+ | Command | Purpose |
84
+ |---------|---------|
85
+ | `/draft:jira` | Unified Jira workflows (preview / create / review) |
86
+
87
+ ---
88
+
89
+ ## Core Workflow: Validation & Recovery Loop
90
+
91
+ To maintain code quality and delivery velocity, the Core Workflow operates as a closed-loop feedback system with explicit validation checkpoints and recovery actions.
92
+
93
+ ```mermaid
94
+ flowchart TD
95
+ A[Start: /draft:init] --> B[Plan: /draft:plan /new-track]
96
+ B --> C{Plan Valid?}
97
+ C -- "No (Revise Plan)" --> B
98
+ C -- "Yes (Approve Spec)" --> D[Implement: /draft:implement]
99
+
100
+ D --> E{Tests Pass & Spec Met?}
101
+ E -- "No (Debug/Fix)" --> D
102
+ E -- "Yes (Verify)" --> F[Review: /draft:review]
103
+
104
+ F --> G{Quality Gates Passed?}
105
+ G -- "No (Reject)" --> H[Analyze Feedback & Recover]
106
+ H -- "If Blocked" --> I[Mark Blocked [!] / ADR / Decompose]
107
+ H -- "If Scope Drifted" --> J[Run /draft:change]
108
+ H -- "If Code Defects" --> D
109
+
110
+ G -- "Yes (Ship)" --> K[Ops: /draft:ops /deploy-checklist]
111
+ ```
112
+
113
+ ### Validation Checkpoints & Recovery Actions
114
+
115
+ | Checkpoint | Criteria | Recovery |
116
+ |---|---|---|
117
+ | **1. Planning** | Track ID in `draft/tracks.md`; `scope_includes`/`scope_excludes` set; acceptance criteria stated; task checklist in `plan.md` with `[ ]` markers. | Requirements or design drifted → `/draft:change`. |
118
+ | **2. Implementation / TDD** | Code compiles; unit + integration tests pass; coverage ≥95% for changed lines. | Blocked by external/architectural constraints → mark task `[!]`, then `/draft:adr` or `/draft:decompose`. Build/test failure → `/draft:debug` (do not bypass). |
119
+ | **3. Quality Gate / Review** | All change-scoped gates in `/draft:review` pass; when TDD is on, coverage gate auto-runs. | Review failed → fix flagged items, run `/draft:bughunt` if structural issues suspected, then re-run `/draft:review`. |
120
+
121
+ ---
122
+
123
+ ## Actionability: Command Invocation Examples
124
+
125
+ ### Example 1: `/draft:status`
126
+ Parses active tracks, phases, tasks, and module mappings:
127
+
128
+ ```
129
+ PROJECT: Bookshelf API Service
130
+
131
+ [track-042] OAuth2 Integration — [~] In Progress (Phase 2/3, 4/9 tasks)
132
+ [x] 1.1 Design OAuth database schema
133
+ [x] 1.2 Generate migration files
134
+ [~] 2.1 Implement token generation endpoint ← CURRENT
135
+ [ ] 2.2 Add authorization middleware
136
+ [!] 2.3 Integrate third-party providers (Blocked: API key pending)
137
+ ```
138
+
139
+ ### Example 2: `/draft:implement`
140
+ Reads `plan.md`, picks the current incomplete task, and continues it (TDD-aware):
141
+
142
+ ```
143
+ Active track: [track-042] OAuth2 Integration
144
+ Current task: [~] 2.1 Implement token generation endpoint
145
+ TDD: on → writing tests/auth/token_generation_test.go (Red stage)
146
+ Test failed as expected → proceeding to implementation.
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Status Markers
152
+
153
+ Used throughout `plan.md` files and referenced by the validation checkpoints above:
154
+
155
+ | Marker | Meaning |
156
+ |--------|---------|
157
+ | `[ ]` | Pending |
158
+ | `[~]` | In Progress |
159
+ | `[x]` | Completed |
160
+ | `[!]` | Blocked |
161
+
162
+ ---
163
+
164
+ 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
+
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.
169
+
170
+ ---
171
+
172
+ ## Need Help?
173
+
174
+ - Run `/draft` (this command) for a high-level overview.
175
+ - Run `/draft:status` to inspect current tracks and task completion rates.
176
+ - Check `draft/tracks/<track_id>/spec.md` for functional requirements.
177
+ - Check `draft/tracks/<track_id>/plan.md` for technical task details.
@@ -0,0 +1,57 @@
1
+ # Draft Context Files Reference
2
+
3
+ When the `draft/` directory exists at the root of a project, the files within it serve as the codebase's central nervous system. These context files establish shared understanding, guardrails, and track progress between the developer, the team, and AI agents.
4
+
5
+ ## The Core Context Directory
6
+
7
+ All context files reside in `draft/` at your project root:
8
+
9
+ ```
10
+ draft/
11
+ ├── architecture.md # Full human engineering reference (Source of Truth)
12
+ ├── .ai-context.md # Token-optimized AI context (derived automatically)
13
+ ├── product.md # Product vision, goals, and business requirements
14
+ ├── tech-stack.md # Technical stack, constraints, and dependencies
15
+ ├── workflow.md # TDD instructions, commit styles, and workflows
16
+ ├── guardrails.md # Team conventions, rules, and discovered anti-patterns
17
+ └── tracks.md # Active feature and bug track registry
18
+ ```
19
+
20
+ ---
21
+
22
+ ## Detailed File Reference
23
+
24
+ ### 1. `draft/architecture.md` (Engineering Source of Truth)
25
+ * **Purpose:** Comprehensive, human-readable reference detailing the system's design, domain model, services, module diagrams, and key data flows.
26
+ * **When to read:** When designing new components, onboarding, or reviewing module boundaries.
27
+ * **When to update:** After running decomposition, making major architectural changes, or completing an epic.
28
+
29
+ ### 2. `draft/.ai-context.md` (Token-Optimized AI Context)
30
+ * **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
+ * **When to read:** AI models read this automatically on every invocation to orient themselves.
32
+ * **When to update:** Generated automatically whenever `draft/architecture.md` changes. Do not edit this file manually.
33
+
34
+ ### 3. `draft/product.md` (Product & Business Vision)
35
+ * **Purpose:** Defines the high-level business goals, core user personas, key workflows, success metrics, and long-term vision.
36
+ * **When to read:** Before proposing features or starting plans, to verify alignment with business goals.
37
+ * **When to update:** When product strategy changes or a new epic is initiated.
38
+
39
+ ### 4. `draft/tech-stack.md` (Constraints & Stack Decisions)
40
+ * **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
+ * **When to read:** Before proposing libraries or deciding how to implement tasks.
42
+ * **When to update:** When upgrading dependencies or making team-wide tech stack decisions.
43
+
44
+ ### 5. `draft/workflow.md` (Work & Style Preferences)
45
+ * **Purpose:** Outlines coding style conventions, test-driven development (TDD) rules, commit message guidelines, git branch naming schemes, and build scripts.
46
+ * **When to read:** During implementation and review cycles to ensure compliance.
47
+ * **When to update:** When adjusting developer processes, lint rules, or build tooling.
48
+
49
+ ### 6. `draft/guardrails.md` (Learned Patterns & Anti-Patterns)
50
+ * **Purpose:** Stores positive code conventions and negative anti-patterns discovered during development. This serves as an automated memory for the AI.
51
+ * **When to read:** Before coding to avoid repeating common codebase-specific mistakes.
52
+ * **When to update:** Run `/draft:learn` to automatically extract rules from your Git diffs or write them manually when discovering a repeated bug.
53
+
54
+ ### 7. `draft/tracks.md` (Track Registry)
55
+ * **Purpose:** Registers all active, completed, and blocked tracks (feature or bug fixes). Contains IDs, descriptions, and current status markers.
56
+ * **When to read:** Before planning new work to prevent duplication, or when generating status reports.
57
+ * **When to update:** Automatically updated by `/draft:plan` and `/draft:status`.
@@ -0,0 +1,37 @@
1
+ # Draft Intent Mapping Guide
2
+
3
+ Draft commands can be invoked using natural language. If you describe your goal or ask a question, Draft will map your intent to the correct canonical or specialist command.
4
+
5
+ ## Natural Language Intent Mapping
6
+
7
+ | What you say or want to do... | Resolved Draft Command | Primary Purpose |
8
+ |:---|:---|:---|
9
+ | "set up the project", "initialize draft", "start setup" | `/draft:init` | Bootstrap Draft in a new project |
10
+ | "plan this feature", "scope this work", "start a track" | `/draft:plan` | Planning coordinator (routes to new-track/change) |
11
+ | "new feature", "add search", "create new task list" | `/draft:plan` | Parent intent routing to `/draft:new-track` |
12
+ | "decompose this", "break into modules", "split service" | `/draft:decompose` | Model decomposition with dependency mapping |
13
+ | "requirements changed", "scope drift", "update spec" | `/draft:change` | Safely update active plan and spec |
14
+ | "document decision", "create ADR", "architectural choice" | `/draft:adr` | Record permanent engineering decisions |
15
+ | "continue planning", "next planning step" | `/draft:plan` | Keep planning in an active session |
16
+ | "start implementing", "begin coding", "write some code" | `/draft:implement` | Canonical implementation workflow |
17
+ | "continue task", "implement next step", "keep coding" | `/draft:implement` | Continue work on the active task checklist |
18
+ | "what is the progress", "track status", "show task list" | `/draft:status` | View progress, active phases, and blocked items |
19
+ | "check coverage", "coverage report", "test coverage" | `/draft:coverage` | Measure code coverage (target 95%+) |
20
+ | "undo changes", "revert commit", "rollback implementation" | `/draft:revert` | Git-aware safety rollback for active tasks |
21
+ | "review my code", "check quality", "run review" | `/draft:review` | Canonical change-scoped review |
22
+ | "quick review", "fast check", "sanity check" | `/draft:quick-review` | Parent-routed lightweight review for files/diffs |
23
+ | "hunt bugs", "find defects", "check for crashes" | `/draft:bughunt` | Exhaustive codebase-wide bug sweep |
24
+ | "deep review", "production readiness audit", "acid audit" | `/draft:deep-review` | Module-scoped ACID compliance and resilience audit |
25
+ | "review handoff", "prepare for PR", "create review handoff" | `/draft:review assist` | Generate detailed review context for humans/agents |
26
+ | "learn patterns", "update guardrails", "discover conventions" | `/draft:learn` | Discover coding conventions and update guardrails |
27
+ | "debug this issue", "investigate test failure", "fix crash" | `/draft:debug` | Structured 4-stage debugging workflow |
28
+ | "deploy checklist", "release checks", "pre-flight checks" | `/draft:deploy-checklist` | Pre-deployment verification checklist |
29
+ | "test strategy", "design test suite", "testing targets" | `/draft:testing-strategy` | Design standard testing plan |
30
+ | "tech debt analysis", "catalog debt", "code debt" | `/draft:tech-debt` | Technical debt audit across 6 dimensions |
31
+ | "weekly standup", "what did I do today", "activity summary" | `/draft:standup` | Summarize recent Git and file contributions |
32
+ | "incident", "production outage", "mitigate bug" | `/draft:incident-response` | Triage, mitigation, and postmortem incident flow |
33
+ | "write docs", "create readme", "api documentation" | `/draft:documentation` | Generate professional, structured docs |
34
+ | "preview jira", "export jira issues", "jira draft" | `/draft:jira-preview` | Generate Jira markdown export from plan |
35
+ | "create jira", "push to jira board" | `/draft:jira-create` | Create actual Jira issues via MCP integrations |
36
+ | "index services", "aggregate context", "monorepo setup" | `/draft:index` | Aggregate multi-service context at the root |
37
+ | "build graph", "refresh graph", "rebuild the knowledge graph", "index this repo's structure" | `/draft:graph` | Initialize/refresh the `draft/graph/` snapshot (optionally `draft graph <path>`) |
@@ -0,0 +1,51 @@
1
+ # Draft Quality Gate & Review Decision Guide
2
+
3
+ This guide helps you choose the most effective quality control and review commands for your codebase. Draft provides an **audit spectrum** that scales from quick, change-scoped checks to deep, service-wide production readiness reviews.
4
+
5
+ ## The Quality Audit Spectrum
6
+
7
+ | Command | Scope | Analysis Time | Primary Objective | Key Outputs |
8
+ |:---|:---|:---|:---|:---|
9
+ | `/draft:quick-review` | File / PR / Diff | ~2 min | "Are there any obvious issues or regressions in this change?" | 4-dimension findings (Style, Bugs, Security, Performance) with severity rankings. |
10
+ | `/draft:review` | Change-scoped (Track, Diff, Commits) | ~10 min | "Does this track implementation meet the spec, coverage targets, and quality gates?" | Three-stage review report with verification verdict, automatic coverage verification, and quality gate sign-off. |
11
+ | `/draft:bughunt` | Codebase-scoped (Repo, paths, or active track) | ~20 min | "What deep, hidden, or structural bugs exist in this code?" | Exhaustive 14-dimension bug report, verification protocol, and automated regression tests (when a framework exists). |
12
+ | `/draft:deep-review` | Module-scoped (Single service or component) | ~30 min | "Is this component resilient, secure, observable, and fully ready for production?" | Production-grade audit across ACID compliance, reliability, observability, and concrete implementation specifications. |
13
+
14
+ ---
15
+
16
+ ## Command Decision Guide
17
+
18
+ ### 1. Fast Feedback / Pre-Commit Sanity Check
19
+ > [!TIP]
20
+ > Use **`/draft:quick-review`** when you want a fast, lightweight sanity check of your modified files before opening a PR or running full reviews.
21
+ - **When to run:** Before staging changes, during local development loops.
22
+ - **Why:** Zero setup, rapid turnaround, checks standard dimensions (security, performance, styling).
23
+
24
+ ### 2. Track Completion & Pull Request Quality Gate
25
+ > [!IMPORTANT]
26
+ > Use **`/draft:review`** (the canonical review command) when you finish a development phase or an entire track.
27
+ - **When to run:** Before submitting work for final PR approval.
28
+ - **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
+
30
+ ### 3. Debugging Hard-to-Find Defects or Refactoring
31
+ > [!WARNING]
32
+ > Use **`/draft:bughunt`** if you are encountering elusive bugs, regression errors, or before refactoring a legacy module.
33
+ - **When to run:** Prior to refactoring complex areas, or when users report intermittent production bugs.
34
+ - **Why:** Conducts a deep, 14-dimension sweep specifically designed to surface edge cases, race conditions, memory leaks, and logic flaws.
35
+
36
+ ### 4. Shipping Core Infrastructure to Production
37
+ > [!CAUTION]
38
+ > Use **`/draft:deep-review`** before launching a critical service, API, database layer, or high-throughput component.
39
+ - **When to run:** Before major deployments or architectural sign-offs.
40
+ - **Why:** Audits the architecture for ACID compliance, concurrency safety, fault tolerance, rate limiting, and telemetry, providing a formal readiness score.
41
+
42
+ ---
43
+
44
+ ## Relationship to Built-in Bug Hunt Agents
45
+
46
+ 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
+
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.
50
+
51
+ For maximum quality assurance, run built-in scanners in parallel with Draft commands!