@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.
- package/.claude-plugin/marketplace.json +38 -0
- package/.claude-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +272 -0
- package/bin/README.md +49 -0
- package/cli/bin/draft.js +13 -0
- package/cli/src/cli.js +113 -0
- package/cli/src/hosts/claude-code.js +46 -0
- package/cli/src/hosts/codex.js +33 -0
- package/cli/src/hosts/cursor.js +50 -0
- package/cli/src/hosts/index.js +24 -0
- package/cli/src/hosts/opencode.js +39 -0
- package/cli/src/installer.js +61 -0
- package/cli/src/lib/fsx.js +34 -0
- package/cli/src/lib/graph.js +23 -0
- package/cli/src/lib/log.js +32 -0
- package/cli/src/lib/paths.js +14 -0
- package/core/agents/architect.md +338 -0
- package/core/agents/debugger.md +193 -0
- package/core/agents/ops.md +104 -0
- package/core/agents/planner.md +158 -0
- package/core/agents/rca.md +314 -0
- package/core/agents/reviewer.md +256 -0
- package/core/agents/writer.md +110 -0
- package/core/guardrails/README.md +4 -0
- package/core/guardrails/code-quality.md +4 -0
- package/core/guardrails/dependency-triage.md +4 -0
- package/core/guardrails/design-norms.md +4 -0
- package/core/guardrails/language-standards.md +4 -0
- package/core/guardrails/review-checks.md +4 -0
- package/core/guardrails/secure-patterns.md +4 -0
- package/core/guardrails/security.md +4 -0
- package/core/guardrails.md +22 -0
- package/core/knowledge-base.md +127 -0
- package/core/methodology.md +1221 -0
- package/core/shared/condensation.md +224 -0
- package/core/shared/context-verify.md +44 -0
- package/core/shared/cross-skill-dispatch.md +127 -0
- package/core/shared/discovery-schema.md +75 -0
- package/core/shared/draft-context-loading.md +282 -0
- package/core/shared/git-report-metadata.md +106 -0
- package/core/shared/graph-query.md +239 -0
- package/core/shared/graph-usage-report.md +22 -0
- package/core/shared/jira-sync.md +170 -0
- package/core/shared/parallel-analysis.md +386 -0
- package/core/shared/parallel-fanout.md +10 -0
- package/core/shared/pattern-learning.md +146 -0
- package/core/shared/red-flags.md +58 -0
- package/core/shared/template-contract.md +22 -0
- package/core/shared/template-hygiene.md +10 -0
- package/core/shared/tool-resolver.md +10 -0
- package/core/shared/vcs-commands.md +97 -0
- package/core/shared/verification-gates.md +47 -0
- package/core/templates/CHANGELOG.md +70 -0
- package/core/templates/ai-context-export.md +8 -0
- package/core/templates/ai-context.md +270 -0
- package/core/templates/ai-profile.md +41 -0
- package/core/templates/architecture.md +203 -0
- package/core/templates/dependency-graph.md +103 -0
- package/core/templates/discovery.md +79 -0
- package/core/templates/guardrails.md +143 -0
- package/core/templates/hld.md +327 -0
- package/core/templates/intake-questions.md +403 -0
- package/core/templates/jira.md +119 -0
- package/core/templates/lld.md +283 -0
- package/core/templates/metadata.json +66 -0
- package/core/templates/plan.md +130 -0
- package/core/templates/product.md +110 -0
- package/core/templates/rca.md +86 -0
- package/core/templates/root-architecture.md +127 -0
- package/core/templates/root-product.md +53 -0
- package/core/templates/root-tech-stack.md +117 -0
- package/core/templates/service-index.md +55 -0
- package/core/templates/session-summary.md +8 -0
- package/core/templates/spec.md +165 -0
- package/core/templates/tech-matrix.md +101 -0
- package/core/templates/tech-stack.md +169 -0
- package/core/templates/track-architecture.md +311 -0
- package/core/templates/workflow.md +187 -0
- package/integrations/agents/AGENTS.md +24384 -0
- package/integrations/copilot/.github/copilot-instructions.md +24384 -0
- package/integrations/gemini/.gemini.md +26 -0
- package/package.json +53 -0
- package/scripts/fetch-memory-engine.sh +116 -0
- package/scripts/lib.sh +256 -0
- package/scripts/tools/_lib.sh +220 -0
- package/scripts/tools/adr-index.sh +117 -0
- package/scripts/tools/check-graph-usage-report.sh +95 -0
- package/scripts/tools/check-scope-conflicts.sh +139 -0
- package/scripts/tools/check-skill-line-caps.sh +115 -0
- package/scripts/tools/check-template-noop.sh +87 -0
- package/scripts/tools/check-track-hygiene.sh +230 -0
- package/scripts/tools/classify-files.sh +231 -0
- package/scripts/tools/cycle-detect.sh +75 -0
- package/scripts/tools/detect-test-framework.sh +135 -0
- package/scripts/tools/diff-templates-vs-tracks.sh +176 -0
- package/scripts/tools/emit-skill-metrics.sh +71 -0
- package/scripts/tools/fix-whitespace.sh +192 -0
- package/scripts/tools/freshness-check.sh +143 -0
- package/scripts/tools/git-metadata.sh +203 -0
- package/scripts/tools/graph-callers.sh +74 -0
- package/scripts/tools/graph-impact.sh +93 -0
- package/scripts/tools/graph-snapshot.sh +102 -0
- package/scripts/tools/hotspot-rank.sh +75 -0
- package/scripts/tools/manage-symlinks.sh +85 -0
- package/scripts/tools/mermaid-from-graph.sh +92 -0
- package/scripts/tools/migrate-track-frontmatter.sh +241 -0
- package/scripts/tools/parse-git-log.sh +135 -0
- package/scripts/tools/parse-reports.sh +114 -0
- package/scripts/tools/render-track.sh +145 -0
- package/scripts/tools/run-coverage.sh +153 -0
- package/scripts/tools/scan-markers.sh +144 -0
- package/scripts/tools/skill-caps.conf +24 -0
- package/scripts/tools/validate-frontmatter.sh +125 -0
- package/scripts/tools/verify-citations.sh +250 -0
- package/scripts/tools/verify-doc-anchors.sh +204 -0
- package/scripts/tools/verify-graph-binary.sh +154 -0
- package/skills/GRAPH.md +332 -0
- package/skills/adr/SKILL.md +374 -0
- package/skills/assist-review/SKILL.md +49 -0
- package/skills/bughunt/SKILL.md +668 -0
- package/skills/bughunt/references/regression-tests.md +399 -0
- package/skills/change/SKILL.md +267 -0
- package/skills/coverage/SKILL.md +336 -0
- package/skills/debug/SKILL.md +201 -0
- package/skills/decompose/SKILL.md +656 -0
- package/skills/deep-review/SKILL.md +326 -0
- package/skills/deploy-checklist/SKILL.md +254 -0
- package/skills/discover/SKILL.md +66 -0
- package/skills/docs/SKILL.md +42 -0
- package/skills/documentation/SKILL.md +197 -0
- package/skills/draft/SKILL.md +177 -0
- package/skills/draft/context-files.md +57 -0
- package/skills/draft/intent-mapping.md +37 -0
- package/skills/draft/quality-guide.md +51 -0
- package/skills/graph/SKILL.md +107 -0
- package/skills/impact/SKILL.md +86 -0
- package/skills/implement/SKILL.md +794 -0
- package/skills/incident-response/SKILL.md +245 -0
- package/skills/index/SKILL.md +848 -0
- package/skills/init/SKILL.md +1784 -0
- package/skills/init/references/architecture-spec.md +1259 -0
- package/skills/integrations/SKILL.md +53 -0
- package/skills/jira/SKILL.md +577 -0
- package/skills/jira/references/review.md +1322 -0
- package/skills/learn/SKILL.md +478 -0
- package/skills/new-track/SKILL.md +841 -0
- package/skills/ops/SKILL.md +57 -0
- package/skills/plan/SKILL.md +60 -0
- package/skills/quick-review/SKILL.md +216 -0
- package/skills/revert/SKILL.md +178 -0
- package/skills/review/SKILL.md +1114 -0
- package/skills/standup/SKILL.md +183 -0
- package/skills/status/SKILL.md +183 -0
- package/skills/tech-debt/SKILL.md +318 -0
- package/skills/testing-strategy/SKILL.md +195 -0
- package/skills/tour/SKILL.md +38 -0
- package/skills/upload/SKILL.md +117 -0
|
@@ -0,0 +1,1221 @@
|
|
|
1
|
+
# Draft Methodology
|
|
2
|
+
|
|
3
|
+
**Measure twice, code once.**
|
|
4
|
+
|
|
5
|
+
Draft is a methodology for Context-Driven Development that ensures consistent, high-quality delivery through: **Context → Spec & Plan → Implement**.
|
|
6
|
+
|
|
7
|
+
## Philosophy
|
|
8
|
+
|
|
9
|
+
### The Core Problem
|
|
10
|
+
|
|
11
|
+
AI coding assistants are powerful but undirected. Without structure, they:
|
|
12
|
+
- Make assumptions about requirements
|
|
13
|
+
- Choose arbitrary technical approaches
|
|
14
|
+
- Produce code that doesn't fit the existing codebase
|
|
15
|
+
- Lack accountability checkpoints
|
|
16
|
+
|
|
17
|
+
Draft solves this through **Context-Driven Development**: structured documents that constrain and guide AI behavior. By treating context as a managed artifact alongside code, your repository becomes a single source of truth that drives every agent interaction with deep, persistent project awareness.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Table of Contents
|
|
22
|
+
|
|
23
|
+
- [Philosophy](#philosophy)
|
|
24
|
+
- [Installation & Getting Started](#installation--getting-started)
|
|
25
|
+
- [Core Workflow](#core-workflow)
|
|
26
|
+
- [Tracks](#tracks)
|
|
27
|
+
- [Project Context Files](#project-context-files)
|
|
28
|
+
- [Status Markers](#status-markers)
|
|
29
|
+
- [Plan Structure](#plan-structure)
|
|
30
|
+
- [Command Workflows](#command-workflows)
|
|
31
|
+
- [/draft:init](#draftinit--initialize-project)
|
|
32
|
+
- [/draft:plan](#draftplan--planning-orchestrator)
|
|
33
|
+
- [/draft:index](#draftindex--monorepo-service-index)
|
|
34
|
+
- [/draft:new-track](#draftnew-track--create-feature-track)
|
|
35
|
+
- [/draft:implement](#draftimplement--execute-tasks)
|
|
36
|
+
- [/draft:status](#draftstatus--show-progress)
|
|
37
|
+
- [/draft:revert](#draftrevert--git-aware-rollback)
|
|
38
|
+
- [/draft:decompose](#draftdecompose--module-decomposition)
|
|
39
|
+
- [/draft:coverage](#draftcoverage--code-coverage-report)
|
|
40
|
+
- [/draft:jira](#draftjira--unified-jira-integration)
|
|
41
|
+
- [/draft:adr](#draftadr--architecture-decision-records)
|
|
42
|
+
- [/draft:deep-review](#draftdeep-review--module-lifecycle-audit)
|
|
43
|
+
- [/draft:bughunt](#draftbughunt--exhaustive-bug-discovery)
|
|
44
|
+
- [/draft:review](#draftreview--code-review-orchestrator)
|
|
45
|
+
- [/draft:learn](#draftlearn--pattern-discovery--guardrails-update)
|
|
46
|
+
- [/draft:change](#draftchange--course-correction)
|
|
47
|
+
- [Architecture Mode](#architecture-mode)
|
|
48
|
+
- [Code Coverage](#code-coverage)
|
|
49
|
+
- [Concurrency](#concurrency)
|
|
50
|
+
- [Jira Integration (Optional)](#jira-integration-optional)
|
|
51
|
+
- [TDD Workflow (Optional)](#tdd-workflow-optional)
|
|
52
|
+
- [Intent Mapping](#intent-mapping)
|
|
53
|
+
- [Quality Disciplines](#quality-disciplines)
|
|
54
|
+
- [Agents](#agents)
|
|
55
|
+
- [Communication Style](#communication-style)
|
|
56
|
+
- [Principles](#principles)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Why Each Document Exists
|
|
61
|
+
|
|
62
|
+
| Document | Purpose | Prevents |
|
|
63
|
+
|----------|---------|----------|
|
|
64
|
+
| `product.md` | Defines users, goals, success criteria, guidelines | AI building features nobody asked for |
|
|
65
|
+
| `tech-stack.md` | Languages, frameworks, patterns, accepted patterns | AI introducing random dependencies |
|
|
66
|
+
| `architecture.md` | **Graph-primary source of truth.** Focused high-signal engineering reference (Graph Health & Fidelity Dashboard first, then 9 critical sections with explicit provenance/fidelity tags, coverage gaps, and relationship to existing high-quality docs). | Engineers needing onboarding documentation |
|
|
67
|
+
| `.ai-profile.md` | **Derived from .ai-context.md.** 20-50 lines, ultra-compact always-injected project profile. Contains: language, framework, database, auth, API style, critical invariants, safety rules, active tracks, recent changes. Auto-refreshed on mutations. | AI needing full context for simple tasks |
|
|
68
|
+
| `.ai-context.md` | **Derived from architecture.md via condensation.** 200-400 lines, token-optimized, self-contained AI context. Pulls core operational models, invariants with provenance, graph-derived structures, and extension patterns. Auto-refreshed on mutations. | AI re-analyzing codebase every session |
|
|
69
|
+
| `workflow.md` | TDD preference, commit style, review process | AI skipping tests or making giant commits |
|
|
70
|
+
| `guardrails.md` | Hard guardrails, learned conventions, learned anti-patterns. Entries include dual-layer timestamps (`discovered_at`, `established_at`, `last_verified_at`, `last_active_at`) for temporal reasoning. | AI repeating false positives or missing known-bad patterns |
|
|
71
|
+
| `spec.md` | Acceptance criteria for a specific track | Scope creep, gold-plating |
|
|
72
|
+
| `plan.md` | Ordered phases with verification steps | AI attempting everything at once |
|
|
73
|
+
|
|
74
|
+
### The Constraint Hierarchy
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
product.md → "Build a task manager for developers"
|
|
78
|
+
↓
|
|
79
|
+
tech-stack.md → "Use React, TypeScript, Tailwind"
|
|
80
|
+
↓
|
|
81
|
+
architecture.md → "Express API → Service layer → Prisma ORM → PostgreSQL"
|
|
82
|
+
↓ (.ai-context.md condensed for AI consumption)
|
|
83
|
+
↓ (.ai-profile.md ultra-compact 20-50 line always-on profile)
|
|
84
|
+
↓ (.state/facts.json atomic fact registry with knowledge graph)
|
|
85
|
+
spec.md → "Add drag-and-drop reordering"
|
|
86
|
+
↓
|
|
87
|
+
plan.md → "Phase 1: sortable list, Phase 2: persistence"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Each layer narrows the solution space. By the time AI writes code, most decisions are already made.
|
|
91
|
+
|
|
92
|
+
### Context Tiering
|
|
93
|
+
|
|
94
|
+
Draft uses a layered context system inspired by memory tiering — see `core/shared/draft-context-loading.md` for the authoritative specification.
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
Layer 0: .ai-profile.md (20-50 lines) — Always loaded. Minimum project context.
|
|
98
|
+
Layer 1: .ai-context.md (200-400 lines) — Base context: boundaries, invariants, flows.
|
|
99
|
+
Layer 1.5: draft/graph/*.jsonl — Structural graph (when available).
|
|
100
|
+
Layer 2: draft/.state/facts.json — Fact-level precision (queried by relevance).
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`architecture.md` is the source-of-truth document these layers are condensed from, not a layer itself. Simple tasks only need Layer 0. Implementation tasks load Layer 0+1 plus relevant graph/facts. Deep reviews access all layers. Relevance-scored loading keeps tokens bounded.
|
|
104
|
+
|
|
105
|
+
### Draft Command Workflow
|
|
106
|
+
|
|
107
|
+
```mermaid
|
|
108
|
+
graph TD
|
|
109
|
+
A["/draft:init"] -->|"Creates draft/ + graph-primary architecture.md"| B["/draft:plan"]
|
|
110
|
+
B -->|"Routes to new-track/change/adr"| C["/draft:new-track"]
|
|
111
|
+
C -->|"Creates spec.md + plan.md"| D{Complex?}
|
|
112
|
+
D -->|Yes| E["/draft:decompose"]
|
|
113
|
+
D -->|No| F["/draft:implement"]
|
|
114
|
+
E -->|"Creates hld.md (+ lld.md if needed)"| F
|
|
115
|
+
F -->|"TDD cycle per task"| G{Phase done?}
|
|
116
|
+
G -->|No| F
|
|
117
|
+
G -->|Yes| H["Three-Stage Review"]
|
|
118
|
+
H -->|Pass| I{All phases?}
|
|
119
|
+
H -->|Fail| F
|
|
120
|
+
I -->|No| F
|
|
121
|
+
I -->|Yes| J["Track Complete"]
|
|
122
|
+
J -->|"Upload for review"| U["/draft:upload"]
|
|
123
|
+
|
|
124
|
+
K["/draft:status"] -.->|"Check anytime"| F
|
|
125
|
+
L["/draft:revert"] -.->|"Undo if needed"| F
|
|
126
|
+
M["/draft:coverage"] -.->|"After implementation"| F
|
|
127
|
+
N["/draft:bughunt"] -.->|"Quality check"| F
|
|
128
|
+
O["/draft:review"] -.->|"At track end"| H
|
|
129
|
+
P["/draft:adr"] -.->|"Document decisions"| B
|
|
130
|
+
Q["/draft:jira-preview/create"] -.->|"Export to Jira"| C
|
|
131
|
+
R["/draft:deep-review"] -.->|"Audit module"| F
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Context Hierarchy
|
|
135
|
+
|
|
136
|
+
```mermaid
|
|
137
|
+
graph LR
|
|
138
|
+
P["product.md<br/><i>What & Why</i>"] --> T["tech-stack.md<br/><i>How (tools)</i>"]
|
|
139
|
+
T --> A[".ai-context.md<br/><i>How (structure)</i>"]
|
|
140
|
+
A --> S["spec.md<br/><i>What (specific)</i>"]
|
|
141
|
+
S --> PL["plan.md<br/><i>When & Order</i>"]
|
|
142
|
+
PL --> Code["Implementation"]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Keeping AI Constrained
|
|
146
|
+
|
|
147
|
+
Without constraints, AI will:
|
|
148
|
+
1. **Over-engineer** — add abstractions, utilities, "improvements" you didn't ask for
|
|
149
|
+
2. **Assume context** — guess at requirements instead of asking
|
|
150
|
+
3. **Lose focus** — drift across the codebase making tangential changes
|
|
151
|
+
4. **Skip verification** — claim completion without proving it works
|
|
152
|
+
|
|
153
|
+
| Mechanism | Effect |
|
|
154
|
+
|-----------|--------|
|
|
155
|
+
| Explicit spec | AI can only implement what's documented |
|
|
156
|
+
| Phased plans | AI works on one phase at a time |
|
|
157
|
+
| Verification steps | Each phase requires proof of completion |
|
|
158
|
+
| Status markers | Progress is tracked, not assumed |
|
|
159
|
+
|
|
160
|
+
The AI becomes an executor of pre-approved work, not an autonomous decision-maker.
|
|
161
|
+
|
|
162
|
+
### Human Review Before AI Codes
|
|
163
|
+
|
|
164
|
+
**This is Draft's most important feature.**
|
|
165
|
+
|
|
166
|
+
The workflow:
|
|
167
|
+
1. Developer runs `/draft:plan` — AI routes to the right planning workflow, usually `/draft:new-track`
|
|
168
|
+
2. Developer reviews and edits these documents
|
|
169
|
+
3. Developer commits them for peer review
|
|
170
|
+
4. Team approves the approach
|
|
171
|
+
5. *Only then* does `/draft:implement` begin
|
|
172
|
+
|
|
173
|
+
| Traditional AI Coding | Draft Approach |
|
|
174
|
+
|-----------------------|----------------|
|
|
175
|
+
| AI writes code immediately | AI writes spec first |
|
|
176
|
+
| Review happens on code PR | Review happens on spec PR |
|
|
177
|
+
| Disagreements require rewriting code | Disagreements resolved before coding |
|
|
178
|
+
| AI decisions are implicit | AI decisions are documented |
|
|
179
|
+
|
|
180
|
+
**Benefits:**
|
|
181
|
+
- **Faster reviews** — Reviewers approve approach, not implementation details
|
|
182
|
+
- **Fewer rewrites** — Catch design issues before code exists
|
|
183
|
+
- **Knowledge transfer** — Specs document *why*, not just *what*
|
|
184
|
+
- **Accountability** — Clear record of what was requested vs. delivered
|
|
185
|
+
- **Onboarding** — New team members read specs to understand features
|
|
186
|
+
|
|
187
|
+
### Team Workflow: Alignment Before Code
|
|
188
|
+
|
|
189
|
+
Draft's artifacts are designed for team collaboration through standard git workflows. Before any code is written, every markdown file goes through **commit → review → update → merge** until the team is aligned.
|
|
190
|
+
|
|
191
|
+
**The PR cycle on documents:**
|
|
192
|
+
|
|
193
|
+
1. **Project context** — Tech lead runs `/draft:init`. Team reviews `product.md`, `tech-stack.md`, and `workflow.md` via PR. Product managers review vision without reading code. Engineers review technical choices without context-switching into implementation.
|
|
194
|
+
2. **Spec & plan** — Lead runs `/draft:plan` for new work. In the common case, Draft routes to `/draft:new-track`. Team reviews `spec.md` (requirements, acceptance criteria) and `plan.md` (phased task breakdown, dependencies) via PR. Disagreements surface as markdown comments — resolved by editing a paragraph, not rewriting a module.
|
|
195
|
+
3. **Architecture / Design** — When planning reveals structural complexity, `/draft:plan` escalates to `/draft:decompose`. Team reviews `hld.md` (and `lld.md` when triggered) with module boundaries, API surfaces, dependency graph, and implementation order via PR. Senior engineers validate without touching the codebase. The graph-primary `architecture.md` + condensed `.ai-context.md` provide the machine-optimized view.
|
|
196
|
+
4. **Work distribution** — Lead runs `/draft:jira-preview` and `/draft:jira-create`. Epics, stories, and sub-tasks are created from the approved plan. Individual team members pick up Jira stories and implement — with or without `/draft:implement`.
|
|
197
|
+
5. **Implementation** — Only after all documents are merged does coding start. Every developer has full context: what to build (`spec.md`), in what order (`plan.md`), with what boundaries (`.ai-context.md` / graph-primary `architecture.md` / hld/lld).
|
|
198
|
+
|
|
199
|
+
**Why this works:** The CLI is single-user, but the artifacts it produces are the collaboration layer. Draft handles planning and decomposition. Git handles review. Jira handles distribution. Changing a sentence in `spec.md` takes seconds. Changing an architectural decision after 2,000 lines of code takes days.
|
|
200
|
+
|
|
201
|
+
### When to Use Draft
|
|
202
|
+
|
|
203
|
+
**Good fit:**
|
|
204
|
+
- Features requiring design decisions
|
|
205
|
+
- Work that will be reviewed by others
|
|
206
|
+
- Complex multi-step implementations
|
|
207
|
+
- Anything where "just do it" has failed before
|
|
208
|
+
|
|
209
|
+
**Overkill:**
|
|
210
|
+
- One-line bug fixes
|
|
211
|
+
- Typo corrections
|
|
212
|
+
- Exploratory prototypes you'll throw away
|
|
213
|
+
|
|
214
|
+
Draft adds structure. Use it when structure has value.
|
|
215
|
+
|
|
216
|
+
### Problems with Chat-Driven Development
|
|
217
|
+
|
|
218
|
+
Traditional AI chat interfaces have fundamental limitations:
|
|
219
|
+
|
|
220
|
+
| Problem | Impact |
|
|
221
|
+
|---------|--------|
|
|
222
|
+
| **Context window fills up** | Long chats exhaust token limits; AI loses early context |
|
|
223
|
+
| **Hallucination increases with context size** | More tokens → more confusion → worse decisions |
|
|
224
|
+
| **No persistent memory** | Close the chat, lose the context |
|
|
225
|
+
| **Unsearchable history** | "Where did I work on feature X?" — good luck finding it |
|
|
226
|
+
| **No team visibility** | Your chat history is invisible to colleagues |
|
|
227
|
+
| **Repeated context loading** | Every session starts from zero |
|
|
228
|
+
|
|
229
|
+
### How Draft Solves This
|
|
230
|
+
|
|
231
|
+
| Draft Approach | Benefit |
|
|
232
|
+
|----------------|---------|
|
|
233
|
+
| **File-based context** | Persistent memory on the filesystem |
|
|
234
|
+
| **Git-tracked specs** | Version history, diffs, blame |
|
|
235
|
+
| **Scoped context loading** | Only load what's needed for the current track |
|
|
236
|
+
| **Fewer tokens used** | Smaller context → better AI decisions |
|
|
237
|
+
| **Searchable artifacts** | `grep` your specs, not chat logs |
|
|
238
|
+
| **Team-visible planning** | Specs and plans are PR-reviewable |
|
|
239
|
+
|
|
240
|
+
### The Economics
|
|
241
|
+
|
|
242
|
+
Writing specs feels slower. It isn't.
|
|
243
|
+
|
|
244
|
+
| Scenario | Without Spec | With Spec |
|
|
245
|
+
|----------|--------------|-----------|
|
|
246
|
+
| Simple feature | 1 hour | 1.2 hours |
|
|
247
|
+
| Feature with ambiguity | 3 hours + rework | 2 hours |
|
|
248
|
+
| Feature requiring team input | 5 hours + meetings + rework | 2.5 hours |
|
|
249
|
+
| Wrong feature entirely | Days wasted | Caught in review |
|
|
250
|
+
|
|
251
|
+
The overhead is constant (~20% for simple tasks). The savings scale with:
|
|
252
|
+
- **Complexity** — More moving parts = more value from upfront planning
|
|
253
|
+
- **Team size** — More reviewers = more value from documented decisions
|
|
254
|
+
- **Criticality** — Higher stakes = more value from discipline
|
|
255
|
+
|
|
256
|
+
For critical product development, Draft isn't overhead — it's risk mitigation.
|
|
257
|
+
|
|
258
|
+
## Installation & Getting Started
|
|
259
|
+
|
|
260
|
+
### Prerequisites
|
|
261
|
+
|
|
262
|
+
- **Claude Code CLI** — Install from [claude.ai/code](https://claude.ai/code) or via `npm install -g @anthropic-ai/claude-code`
|
|
263
|
+
- **Git** — Version control is required for track history, revert, and commit workflows
|
|
264
|
+
- **Node.js 18+** — Required for Claude Code CLI
|
|
265
|
+
|
|
266
|
+
### Install Draft Plugin
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# From Claude Code CLI
|
|
270
|
+
claude plugin install draft
|
|
271
|
+
|
|
272
|
+
# Or clone and install locally
|
|
273
|
+
git clone <your-draft-repo-url> ~/.claude/plugins/draft
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Verify Installation
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Run the overview command
|
|
280
|
+
/draft
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
You should see the list of available Draft commands. If not, check that the plugin directory is correctly placed under `~/.claude/plugins/`.
|
|
284
|
+
|
|
285
|
+
### Quick Start
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# 1. Initialize project context (once per project)
|
|
289
|
+
/draft:init
|
|
290
|
+
|
|
291
|
+
# 2. Plan a feature track with spec and plan
|
|
292
|
+
/draft:plan "Add user authentication"
|
|
293
|
+
|
|
294
|
+
# 3. Review the generated spec.md and plan.md, then implement
|
|
295
|
+
/draft:implement
|
|
296
|
+
|
|
297
|
+
# 4. Check progress at any time
|
|
298
|
+
/draft:status
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Supported Platforms
|
|
302
|
+
|
|
303
|
+
Draft works with **Claude Code** (native `.claude-plugin/` support) and **Cursor** (supports `.claude/` plugin structure natively). No build pipeline required.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Core Workflow
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
Context → Spec & Plan → Implement
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
1. **Setup** - Initialize project context (once per project)
|
|
314
|
+
2. **New Track** - Create specification and plan
|
|
315
|
+
3. **Implement** - Execute tasks with optional TDD workflow
|
|
316
|
+
4. **Verify** - Confirm acceptance criteria met
|
|
317
|
+
|
|
318
|
+
## Tracks
|
|
319
|
+
|
|
320
|
+
A **track** is a high-level unit of work (feature, bug fix, refactor). Each track contains `spec.md`, `plan.md`, `metadata.json`, and optionally `jira-export.md`.
|
|
321
|
+
|
|
322
|
+
Two layouts are supported; both are valid:
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
# Single-track project (default) # Multi-track project
|
|
326
|
+
draft/ draft/tracks/<track-id>/
|
|
327
|
+
├── spec.md ├── spec.md
|
|
328
|
+
├── plan.md ├── plan.md
|
|
329
|
+
├── metadata.json ├── metadata.json
|
|
330
|
+
└── jira-export.md (optional) └── jira-export.md (optional)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`/draft:new-track` selects the multi-track layout when a second track is created (existing `draft/spec.md` and `draft/plan.md` are migrated into `draft/tracks/<original-track-id>/`). Commands referring to "the active track" resolve to whichever layout is in use.
|
|
334
|
+
|
|
335
|
+
### Track Lifecycle
|
|
336
|
+
|
|
337
|
+
1. **Planning** - Spec and plan are being drafted
|
|
338
|
+
2. **In Progress** - Tasks are being implemented
|
|
339
|
+
3. **Completed** - All acceptance criteria met
|
|
340
|
+
4. **Archived** - Track is archived for reference
|
|
341
|
+
|
|
342
|
+
## Project Context Files
|
|
343
|
+
|
|
344
|
+
Located in `draft/` of the target project:
|
|
345
|
+
|
|
346
|
+
| File | Purpose |
|
|
347
|
+
|------|---------|
|
|
348
|
+
| `product.md` | Product vision, users, goals, guidelines (optional section) |
|
|
349
|
+
| `tech-stack.md` | Languages, frameworks, patterns, accepted patterns |
|
|
350
|
+
| `architecture.md` | **Graph-primary source of truth.** Focused high-signal reference (Graph Health & Fidelity Dashboard + 9 critical sections with provenance/fidelity tags, gaps, and relationship to existing docs). |
|
|
351
|
+
| `.ai-context.md` | **Derived via condensation.** 200-400 lines, token-optimized AI context pulling operational models, invariants with provenance, and graph structures from the primary architecture.md. |
|
|
352
|
+
| `workflow.md` | TDD preferences, commit strategy, validation config |
|
|
353
|
+
| `guardrails.md` | Hard guardrails, learned conventions, learned anti-patterns |
|
|
354
|
+
| `jira.md` | Jira project configuration (optional) |
|
|
355
|
+
| `tracks.md` | Master list of all tracks |
|
|
356
|
+
| `.state/facts.json` | Atomic fact registry with temporal metadata and knowledge graph edges. Enables fact-level contradiction detection on refresh. |
|
|
357
|
+
| `.state/freshness.json` | SHA-256 hashes of all analyzed source files. Enables file-level staleness detection for incremental refresh. |
|
|
358
|
+
| `.state/signals.json` | Codebase signal classification (11 categories). Detects structural drift on refresh. |
|
|
359
|
+
| `.state/run-memory.json` | Run metadata, resumable checkpoints, unresolved questions. Enables cross-session continuity. |
|
|
360
|
+
|
|
361
|
+
### Key Sections
|
|
362
|
+
|
|
363
|
+
- **`product.md` `## Guidelines`** — UX standards, writing style, branding (optional)
|
|
364
|
+
- **`tech-stack.md` `## Accepted Patterns`** — Intentional design decisions honored by bughunt/deep-review/review
|
|
365
|
+
- **`guardrails.md`** — Hard guardrails (human-defined constraints), learned conventions (auto-discovered, skip in analysis), learned anti-patterns (auto-discovered, always flag)
|
|
366
|
+
|
|
367
|
+
## Status Markers
|
|
368
|
+
|
|
369
|
+
Used throughout spec.md and plan.md:
|
|
370
|
+
|
|
371
|
+
| Marker | Meaning |
|
|
372
|
+
|--------|---------|
|
|
373
|
+
| `[ ]` | Pending/New |
|
|
374
|
+
| `[~]` | In Progress |
|
|
375
|
+
| `[x]` | Completed |
|
|
376
|
+
| `[!]` | Blocked |
|
|
377
|
+
|
|
378
|
+
## Plan Structure
|
|
379
|
+
|
|
380
|
+
Plans are organized into phases:
|
|
381
|
+
|
|
382
|
+
1. **Foundation** - Core data structures, interfaces
|
|
383
|
+
2. **Implementation** - Main functionality
|
|
384
|
+
3. **Integration** - Connecting components
|
|
385
|
+
4. **Polish** - Error handling, edge cases, docs
|
|
386
|
+
|
|
387
|
+
### Task Granularity
|
|
388
|
+
|
|
389
|
+
Good tasks are:
|
|
390
|
+
- Completable in a focused session
|
|
391
|
+
- Have clear success criteria
|
|
392
|
+
- Produce testable output
|
|
393
|
+
- Fit in a single commit
|
|
394
|
+
|
|
395
|
+
## Command Workflows
|
|
396
|
+
|
|
397
|
+
### `/draft:init` — Initialize Project
|
|
398
|
+
|
|
399
|
+
Initializes a Draft project by creating the `draft/` directory and context files. Run once per project.
|
|
400
|
+
|
|
401
|
+
#### Project Discovery
|
|
402
|
+
|
|
403
|
+
Draft auto-classifies the project:
|
|
404
|
+
|
|
405
|
+
- **Brownfield (existing codebase):** Detected by the presence of `package.json`, `requirements.txt`, `go.mod`, `Cargo.toml`, `src/`, or git history with commits. Draft scans the existing stack and pre-fills `tech-stack.md`.
|
|
406
|
+
- **Greenfield (new project):** Empty or near-empty directory. Developer provides all context through dialogue.
|
|
407
|
+
- **Mature high-context brownfield:** Projects with strong existing agent-optimized docs (CLAUDE.md, INVARIANTS.md, ADRs, etc.) now receive an early Context Quality Audit, graph fidelity declaration, and explicit Relationship/Gaps sections so the generated architecture.md acts as graph-primary overlay rather than duplicative prose.
|
|
408
|
+
- **Monorepo:** Detected by `lerna.json`, `pnpm-workspace.yaml`, `nx.json`, `turbo.json`, or multiple package manifests in child directories. Suggests `/draft:index` instead.
|
|
409
|
+
|
|
410
|
+
#### Initialization Sequence
|
|
411
|
+
|
|
412
|
+
1. **Project discovery** — Classify as brownfield, greenfield, or monorepo
|
|
413
|
+
2. **Architecture discovery (brownfield only)** — Five-phase analysis:
|
|
414
|
+
|
|
415
|
+
**Phase 1: Discovery** — Directory structure, build/dependency files, API definitions, interface/type files. Includes **signal classification** — categorizes all source files into 11 signal categories (`backend_routes`, `frontend_routes`, `components`, `services`, `data_models`, `auth_files`, `state_management`, `background_jobs`, `persistence`, `test_infra`, `config_files`). Signal counts drive adaptive section depth.
|
|
416
|
+
|
|
417
|
+
**Phase 2: Wiring** — Entry points, orchestrator/controller initialization, registry/registration code, dependency wiring (DI, module system, import graph).
|
|
418
|
+
|
|
419
|
+
**Phase 3: Depth** — Data flows end-to-end, core module implementations, concurrency model, safety checks (invariants, validation, auth).
|
|
420
|
+
|
|
421
|
+
**Phase 4: Periphery** — External dependencies, test infrastructure, configuration mechanisms, existing documentation.
|
|
422
|
+
|
|
423
|
+
**Phase 5: Synthesis** — Cross-reference, completeness validation, pattern identification, diagram generation.
|
|
424
|
+
|
|
425
|
+
This produces `draft/architecture.md` (comprehensive human-readable reference), `draft/.ai-context.md` (200-400 line token-optimized context), and `draft/.ai-profile.md` (20-50 line ultra-compact always-on profile). All three become persistent context — every future track references them instead of re-analyzing the codebase.
|
|
426
|
+
|
|
427
|
+
3. **Fact extraction** — Extracts atomic architectural facts into `draft/.state/facts.json` with dual-layer timestamps (`discovered_at`, `established_at`, `last_verified_at`, `last_active_at`), relationship edges (`updates`, `extends`, `derives`), and per-fact confidence scoring. Enables granular change tracking and contradiction detection on refresh.
|
|
428
|
+
|
|
429
|
+
4. **State persistence** — Writes `draft/.state/` directory with four files:
|
|
430
|
+
- `facts.json` — Atomic fact registry with temporal metadata and knowledge graph edges (enables fact-level contradiction detection on refresh)
|
|
431
|
+
- `freshness.json` — SHA-256 hashes of all analyzed source files (enables file-level staleness detection on refresh)
|
|
432
|
+
- `signals.json` — Signal classification with section relevance mapping (enables structural drift detection)
|
|
433
|
+
- `run-memory.json` — Run metadata, unresolved questions, resumable checkpoints (enables cross-session continuity)
|
|
434
|
+
5. **Product definition** — Dialogue to define product vision, users, goals, constraints, guidelines (optional) → `draft/product.md`
|
|
435
|
+
6. **Tech stack** — Auto-detected for brownfield (cross-referenced with architecture discovery); manual for greenfield. Includes accepted patterns section → `draft/tech-stack.md`
|
|
436
|
+
7. **Workflow configuration** — TDD preference (strict/flexible/none), commit style, review process → `draft/workflow.md`
|
|
437
|
+
8. **Guardrails configuration** — Hard guardrails, learned conventions, learned anti-patterns → `draft/guardrails.md`
|
|
438
|
+
9. **Tracks registry** — Empty tracks list → `draft/tracks.md`
|
|
439
|
+
10. **Directory structure** — Creates `draft/tracks/` and `draft/.state/` directories
|
|
440
|
+
|
|
441
|
+
> **Note:** Architecture features (module decomposition, stories, execution state, skeletons, chunk reviews) are automatically enabled when you run `/draft:decompose` on a track. File-based activation — no opt-in needed.
|
|
442
|
+
|
|
443
|
+
If `draft/` already exists with context files, init reports "already initialized" and suggests using `/draft:init refresh` or `/draft:plan`.
|
|
444
|
+
|
|
445
|
+
#### Refresh Mode (`/draft:init refresh`)
|
|
446
|
+
|
|
447
|
+
Re-scans and updates existing context without starting from scratch. Uses stored state for incremental, targeted refresh.
|
|
448
|
+
|
|
449
|
+
0. **State-Aware Pre-Check** — Loads `draft/.state/freshness.json` and computes current file hashes. If all hashes match (no changed/new/deleted files), short-circuits: "Architecture context is current. Nothing to refresh." Also loads `draft/.state/signals.json` to detect structural drift (new signal categories appearing, e.g., auth files added for the first time). Checks `draft/.state/run-memory.json` for interrupted previous runs and offers resume.
|
|
450
|
+
1. **Tech Stack Refresh** — Re-scans `package.json`, `go.mod`, etc. Compares with existing `draft/tech-stack.md`. Proposes updates.
|
|
451
|
+
2. **Architecture Refresh** — Uses file-level hash deltas (from freshness state) to scope re-analysis to only changed/new files. Detects new directories, removed components, changed integrations, new domain objects, new or merged modules. Updates mermaid diagrams. Preserves modules added by `/draft:decompose`. Presents changes for review before writing. After updating `architecture.md`, derives `draft/.ai-context.md` and `draft/.ai-profile.md` using the Condensation Subroutine.
|
|
452
|
+
3. **Contradiction Detection** — If `facts.json` exists, performs fact-level diff against changed files. Detects superseded facts (contradictions), extended facts (refinements), and new facts. Generates a Fact Evolution Report showing confirmed/updated/extended/new/stale facts. Updates relationship edges in the knowledge graph.
|
|
453
|
+
4. **Product Refinement** — Asks if product vision/goals in `draft/product.md` need updates.
|
|
454
|
+
5. **Workflow Review** — Asks if `draft/workflow.md` settings (TDD, commits) need changing.
|
|
455
|
+
6. **State Refresh** — Regenerates all state files (`facts.json`, `freshness.json`, `signals.json`, `run-memory.json`) with current baseline. Updates profile.
|
|
456
|
+
7. **Preserve** — Does NOT modify `draft/tracks.md` unless explicitly requested.
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
### `/draft:plan` — Planning Orchestrator
|
|
461
|
+
|
|
462
|
+
Canonical parent command for planning and design work.
|
|
463
|
+
|
|
464
|
+
#### Purpose
|
|
465
|
+
|
|
466
|
+
`/draft:plan` routes to the right specialist planning workflow:
|
|
467
|
+
|
|
468
|
+
- `/draft:new-track` for fresh feature, bugfix, or refactor planning
|
|
469
|
+
- `/draft:decompose` for architecture and module boundary work
|
|
470
|
+
- `/draft:change` for mid-track requirement changes
|
|
471
|
+
- `/draft:adr` for durable technical decisions
|
|
472
|
+
|
|
473
|
+
#### Routing Rules
|
|
474
|
+
|
|
475
|
+
1. **Explicit mode wins** — `/draft:plan new-track|decompose|change|adr`
|
|
476
|
+
2. **Requirement drift beats deeper design** — existing-scope changes route to `/draft:change` first
|
|
477
|
+
3. **Complexity escalates to decomposition** — multi-module or structurally risky tracks route to `/draft:decompose`
|
|
478
|
+
4. **Decision capture is explicit or tradeoff-driven** — `/draft:adr` records lasting rationale
|
|
479
|
+
5. **Otherwise default to new-track** — fresh planning requests usually become `/draft:new-track`
|
|
480
|
+
|
|
481
|
+
#### Bare `/draft:plan`
|
|
482
|
+
|
|
483
|
+
When run without a clear mode, Draft inspects:
|
|
484
|
+
|
|
485
|
+
- `draft/tracks.md`
|
|
486
|
+
- active track `spec.md` and `plan.md`
|
|
487
|
+
- `hld.md` / `lld.md` when present
|
|
488
|
+
|
|
489
|
+
Then it announces the selected planning mode and reason before continuing.
|
|
490
|
+
|
|
491
|
+
Example:
|
|
492
|
+
|
|
493
|
+
```text
|
|
494
|
+
Planning mode selected: decompose
|
|
495
|
+
Reason: the active track spans multiple modules and has no HLD yet.
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
The parent command should move planning forward rather than listing options.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
### `/draft:index` — Monorepo Service Index
|
|
503
|
+
|
|
504
|
+
Aggregates Draft context from multiple services in a monorepo into unified root-level documents. Designed for organizations with multiple services, each with their own `draft/` context.
|
|
505
|
+
|
|
506
|
+
#### What It Does
|
|
507
|
+
|
|
508
|
+
1. **Scans** immediate child directories for services (detects `package.json`, `go.mod`, `Cargo.toml`, etc.)
|
|
509
|
+
2. **Reads** each service's `draft/product.md`, `draft/.ai-context.md` (or legacy `draft/architecture.md`), `draft/tech-stack.md`
|
|
510
|
+
3. **Synthesizes** root-level documents:
|
|
511
|
+
- `draft/service-index.md` — Service registry with status, tech, and links
|
|
512
|
+
- `draft/dependency-graph.md` — Inter-service dependency topology
|
|
513
|
+
- `draft/tech-matrix.md` — Technology distribution across services
|
|
514
|
+
- `draft/product.md` — Synthesized product vision (if not exists)
|
|
515
|
+
- `draft/.ai-context.md` — System-of-systems architecture view
|
|
516
|
+
- `draft/tech-stack.md` — Org-wide technology standards
|
|
517
|
+
|
|
518
|
+
#### Arguments
|
|
519
|
+
|
|
520
|
+
- `init-missing` — Run `/draft:init` on services that lack a `draft/` directory
|
|
521
|
+
- `bughunt [dir1 dir2 ...]` — Run `/draft:bughunt` across subdirectories with `draft/` folders. If no directories specified, auto-discovers all subdirectories with `draft/`. Generates summary report at `draft-index-bughunt-summary.md`.
|
|
522
|
+
|
|
523
|
+
#### When to Use
|
|
524
|
+
|
|
525
|
+
- After running `/draft:init` on individual services
|
|
526
|
+
- After adding or removing services from the monorepo
|
|
527
|
+
- Periodically to refresh cross-service context
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
### `/draft:new-track` — Create Feature Track
|
|
532
|
+
|
|
533
|
+
Creates a new track (feature, bug fix, or refactor) with a specification and phased plan.
|
|
534
|
+
|
|
535
|
+
#### Context Loading
|
|
536
|
+
|
|
537
|
+
Every new track loads the full project context before spec creation:
|
|
538
|
+
- `draft/product.md` — product vision, users, goals, guidelines
|
|
539
|
+
- `draft/tech-stack.md` — languages, frameworks, patterns, accepted patterns
|
|
540
|
+
- `draft/.ai-context.md` — system map, modules, data flows, invariants, security architecture (if exists). Falls back to `draft/architecture.md` for legacy projects.
|
|
541
|
+
- `draft/workflow.md` — TDD preference, commit conventions
|
|
542
|
+
- `draft/guardrails.md` — Hard guardrails, learned conventions, learned anti-patterns
|
|
543
|
+
- `draft/tracks.md` — existing tracks (check for overlap/dependencies)
|
|
544
|
+
|
|
545
|
+
Every spec includes a **Context References** section that explicitly links back to these documents with a one-line description of how each is relevant to this track. This ensures every track is grounded in the big picture.
|
|
546
|
+
|
|
547
|
+
#### Track Types
|
|
548
|
+
|
|
549
|
+
New track auto-detects the track type from the description and dialogue:
|
|
550
|
+
|
|
551
|
+
| Type | Indicators | Spec Template | Plan Structure |
|
|
552
|
+
|------|-----------|---------------|----------------|
|
|
553
|
+
| **Feature / Refactor** | "add", "implement", "refactor", "improve" | Standard spec | Flexible phases |
|
|
554
|
+
| **Bug / RCA** | "fix", "bug", "investigate", Jira bug ticket, "root cause", production incident | Bug spec with Code Locality, Blast Radius | Fixed 3-phase: Investigate → RCA → Fix |
|
|
555
|
+
|
|
556
|
+
#### Specification Creation (Feature)
|
|
557
|
+
|
|
558
|
+
Engages in dialogue to understand scope before generating `spec.md`:
|
|
559
|
+
- **What** — Exact scope and boundaries
|
|
560
|
+
- **Why** — Business/user value
|
|
561
|
+
- **Acceptance criteria** — How we know it's done
|
|
562
|
+
- **Non-goals** — What's explicitly out of scope
|
|
563
|
+
- **Technical approach** — High-level approach based on tech-stack.md and .ai-context.md
|
|
564
|
+
|
|
565
|
+
#### Specification Creation (Bug / RCA)
|
|
566
|
+
|
|
567
|
+
For bugs, incidents, and Jira-sourced issues. Focused investigation, not broad exploration:
|
|
568
|
+
- **Symptoms** — Exact error, affected users/flows, frequency
|
|
569
|
+
- **Reproduction** — Steps to trigger, environment conditions
|
|
570
|
+
- **Blast Radius** — What's broken AND what's not (scopes the investigation)
|
|
571
|
+
- **Code Locality** — Direct `file:line` references to suspect area, entry point, related code
|
|
572
|
+
- **Investigation Constraints** — Stay in the blast radius, respect module boundaries
|
|
573
|
+
|
|
574
|
+
The spec is presented for approval and iterated until the developer is satisfied.
|
|
575
|
+
|
|
576
|
+
#### Plan Creation
|
|
577
|
+
|
|
578
|
+
Based on the approved spec, generates a phased task breakdown in `plan.md`:
|
|
579
|
+
- **Feature tracks:** Tasks organized into phases (Foundation → Implementation → Integration → Polish)
|
|
580
|
+
- **Bug tracks:** Fixed 3-phase structure: Investigate & Reproduce → Root Cause Analysis → Fix & Verify. Includes an RCA Log table for tracking hypotheses.
|
|
581
|
+
- Each task specifies target files and test files
|
|
582
|
+
- Dependencies between tasks are documented
|
|
583
|
+
- Verification criteria defined per phase
|
|
584
|
+
|
|
585
|
+
Also creates `metadata.json` (status tracking) and registers the track in `draft/tracks.md`.
|
|
586
|
+
|
|
587
|
+
#### Track ID
|
|
588
|
+
|
|
589
|
+
Auto-generated kebab-case from the description:
|
|
590
|
+
- Full description converted to lowercase
|
|
591
|
+
- Spaces replaced with hyphens
|
|
592
|
+
- Special characters removed
|
|
593
|
+
- Examples:
|
|
594
|
+
- "Add user authentication" → `add-user-auth`
|
|
595
|
+
- "Fix: login bug" → `fix-login-bug`
|
|
596
|
+
- "Update project docs" → `update-project-docs`
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
### `/draft:implement` — Execute Tasks
|
|
601
|
+
|
|
602
|
+
Canonical implementation parent command.
|
|
603
|
+
|
|
604
|
+
#### Parent Behavior
|
|
605
|
+
|
|
606
|
+
`/draft:implement` owns the implementation family:
|
|
607
|
+
|
|
608
|
+
- baseline task-by-task execution
|
|
609
|
+
- `/draft:status` for progress inspection
|
|
610
|
+
- `/draft:coverage` for test-coverage measurement
|
|
611
|
+
- `/draft:revert` for safe rollback
|
|
612
|
+
|
|
613
|
+
Explicit parent modes route directly:
|
|
614
|
+
|
|
615
|
+
- `/draft:implement status`
|
|
616
|
+
- `/draft:implement coverage`
|
|
617
|
+
- `/draft:implement revert`
|
|
618
|
+
|
|
619
|
+
Implements tasks from the active track's plan, following the TDD workflow when enabled.
|
|
620
|
+
|
|
621
|
+
#### Task Selection
|
|
622
|
+
|
|
623
|
+
Scans `plan.md` for the first uncompleted task:
|
|
624
|
+
- `[ ]` Pending — picks this one
|
|
625
|
+
- `[~]` In Progress — resumes this one
|
|
626
|
+
- `[x]` Completed — skips
|
|
627
|
+
- `[!]` Blocked — skips, notifies user
|
|
628
|
+
|
|
629
|
+
#### Production Robustness Patterns (always active)
|
|
630
|
+
|
|
631
|
+
During code generation, the implement skill applies trigger→pattern rules across 6 dimensions: **atomicity** (all-or-nothing mutations, atomic file writes, DB-first state updates), **isolation** (lock-guarded shared state, deep-copy returns, no DB I/O under locks), **durability** (crash-recoverable state, no fire-and-forget writes), **defensive boundaries** (numeric validation, API response validation, parameterized SQL), **idempotency** (dedup keys, legal state transitions, alert dedup), and **fail-closed** (deny on error/missing data). Patterns activate based on code triggers — no manual opt-in needed.
|
|
632
|
+
|
|
633
|
+
When `draft/.ai-context.md` exists, project-specific invariants (lock ordering, concurrency model, consistency boundaries) are loaded as active constraints and take precedence over general patterns.
|
|
634
|
+
|
|
635
|
+
#### TDD Cycle (when enabled in `workflow.md`)
|
|
636
|
+
|
|
637
|
+
1. **RED** — Write a failing test that captures the requirement. Run the test, verify it fails with an assertion failure (not a syntax error).
|
|
638
|
+
2. **GREEN** — Write the minimum code to make the test pass. Run the test, verify it passes.
|
|
639
|
+
3. **REFACTOR** — Clean up the code while keeping tests green. Run all related tests after each change.
|
|
640
|
+
|
|
641
|
+
Red flags that stop the cycle: writing code before a test exists, test passes immediately, running tests mentally instead of executing.
|
|
642
|
+
|
|
643
|
+
#### Architecture Mode Checkpoints (when .ai-context.md exists)
|
|
644
|
+
|
|
645
|
+
**Activation:** Automatically enabled when track has `draft/tracks/<id>/.ai-context.md` (created by `/draft:decompose`). Falls back to `draft/tracks/<id>/architecture.md` for legacy projects.
|
|
646
|
+
|
|
647
|
+
Before the TDD cycle, three additional mandatory checkpoints:
|
|
648
|
+
|
|
649
|
+
1. **Story** — Natural-language algorithm description (Input → Process → Output) written as a comment at the top of the code file. Developer approves before proceeding.
|
|
650
|
+
2. **Execution State** — Define intermediate state variables needed for processing. Developer approves.
|
|
651
|
+
3. **Function Skeletons** — Generate function stubs with complete signatures and docstrings, no implementation bodies. Developer approves.
|
|
652
|
+
|
|
653
|
+
Additionally, implementation chunks are limited to ~200 lines with a review checkpoint after each chunk.
|
|
654
|
+
|
|
655
|
+
#### Progress Updates
|
|
656
|
+
|
|
657
|
+
After each task: update `plan.md` status markers, increment `metadata.json` counters, commit per workflow conventions.
|
|
658
|
+
|
|
659
|
+
#### Parent-Owned Escalations
|
|
660
|
+
|
|
661
|
+
The baseline implementation loop should absorb adjacent execution helpers when they are the obvious next step:
|
|
662
|
+
|
|
663
|
+
- **Status-style checkpoint** when blocked or ambiguous task state needs to be surfaced before continuing
|
|
664
|
+
- **Coverage checkpoint** after a phase or high-risk module completes
|
|
665
|
+
- **Revert guidance** when progress should not continue without undoing invalid work
|
|
666
|
+
|
|
667
|
+
This keeps `/draft:implement` as the common entry point while preserving explicit child modes for power users.
|
|
668
|
+
|
|
669
|
+
#### Phase Boundary Review
|
|
670
|
+
|
|
671
|
+
When all tasks in a phase are `[x]`, a three-stage review is triggered:
|
|
672
|
+
1. **Stage 1: Automated Validation** — Fast static checks (architecture conformance, dead code, circular dependencies, OWASP security, performance anti-patterns)
|
|
673
|
+
2. **Stage 2: Spec Compliance** — Verify all requirements for the phase are implemented
|
|
674
|
+
3. **Stage 3: Code Quality** — Verify patterns, error handling, test quality; classify issues as Critical/Important/Minor
|
|
675
|
+
|
|
676
|
+
Only proceeds to the next phase if no Critical issues remain.
|
|
677
|
+
|
|
678
|
+
#### Track Completion
|
|
679
|
+
|
|
680
|
+
When all phases complete: update `plan.md`, `metadata.json`, and `draft/tracks.md`. Move the track from Active to Completed.
|
|
681
|
+
|
|
682
|
+
#### Examples
|
|
683
|
+
|
|
684
|
+
```bash
|
|
685
|
+
/draft:implement # continue the next task
|
|
686
|
+
/draft:implement status # inspect current execution state
|
|
687
|
+
/draft:implement coverage # measure coverage for the active implementation scope
|
|
688
|
+
/draft:implement revert # start rollback flow
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
---
|
|
692
|
+
|
|
693
|
+
### `/draft:status` — Show Progress
|
|
694
|
+
|
|
695
|
+
Displays a comprehensive overview of project progress:
|
|
696
|
+
- All active tracks with phase and task counts
|
|
697
|
+
- Current task indicator
|
|
698
|
+
- Module status (if `.ai-context.md` exists) with coverage percentages
|
|
699
|
+
- Blocked items with reasons
|
|
700
|
+
- Recently completed tracks
|
|
701
|
+
- Quick stats summary
|
|
702
|
+
|
|
703
|
+
---
|
|
704
|
+
|
|
705
|
+
### `/draft:revert` — Git-Aware Rollback
|
|
706
|
+
|
|
707
|
+
Safely undo work at three levels. The command prompts interactively for the revert level and target.
|
|
708
|
+
|
|
709
|
+
| Level | What It Reverts |
|
|
710
|
+
|-------|----------------|
|
|
711
|
+
| **Task** | Single task's commits |
|
|
712
|
+
| **Phase** | All commits in a phase |
|
|
713
|
+
| **Track** | Entire track's commits |
|
|
714
|
+
|
|
715
|
+
#### Revert Process
|
|
716
|
+
|
|
717
|
+
1. **Select level** — Prompts user to choose: Task, Phase, or Track
|
|
718
|
+
2. **Identify commits** — Reads commit SHAs from `plan.md` or searches git log by track pattern (`feat(<track_id>): ...`)
|
|
719
|
+
3. **Preview** — Shows commits, affected files, and plan.md status changes before executing
|
|
720
|
+
4. **Confirm** — Requires explicit user confirmation
|
|
721
|
+
5. **Execute** — Runs `git revert --no-commit` for each commit (newest first), then creates a single revert commit
|
|
722
|
+
6. **Update Draft state** — Reverts task markers from `[x]` to `[ ]`, decrements metadata counters
|
|
723
|
+
|
|
724
|
+
If a revert produces merge conflicts, Draft reports the conflicted files and halts. The user resolves conflicts manually, then runs `git revert --continue`.
|
|
725
|
+
|
|
726
|
+
---
|
|
727
|
+
|
|
728
|
+
### `/draft:decompose` — Module Decomposition
|
|
729
|
+
|
|
730
|
+
Breaks a project or track into modules with clear responsibilities, dependencies, and implementation order.
|
|
731
|
+
|
|
732
|
+
#### Scope
|
|
733
|
+
|
|
734
|
+
- **Project-wide** (`/draft:decompose project`) → `draft/architecture.md` (derives `draft/.ai-context.md`)
|
|
735
|
+
- **Track-scoped** (`/draft:decompose` with active track) → `draft/tracks/<id>/architecture.md` (derives `draft/tracks/<id>/.ai-context.md`)
|
|
736
|
+
|
|
737
|
+
#### Process
|
|
738
|
+
|
|
739
|
+
1. **Load context** — Read product.md, tech-stack.md, spec.md; scan codebase for brownfield projects (directory structure, entry points, existing module boundaries, import patterns)
|
|
740
|
+
2. **Module identification** — Propose modules with: name, responsibility, files, API surface, dependencies, complexity. Each module targets 1-3 files with a single responsibility.
|
|
741
|
+
3. **CHECKPOINT** — Developer reviews and modifies module breakdown
|
|
742
|
+
4. **Dependency mapping** — Map inter-module imports, detect cycles, generate ASCII dependency diagram, determine implementation order via topological sort
|
|
743
|
+
5. **CHECKPOINT** — Developer reviews dependency diagram and implementation order
|
|
744
|
+
6. **Generate `architecture.md`** — Module definitions, dependency diagram/table, implementation order, story placeholders. Derive `.ai-context.md` for AI consumption.
|
|
745
|
+
7. **Update plan.md (track-scoped only)** — Restructure phases to align with module boundaries, preserving completed/in-progress task states
|
|
746
|
+
|
|
747
|
+
#### Cycle Breaking
|
|
748
|
+
|
|
749
|
+
When circular dependencies are detected, Draft proposes one of: extract shared interface module, invert dependency direction, or merge the coupled modules.
|
|
750
|
+
|
|
751
|
+
---
|
|
752
|
+
|
|
753
|
+
### `/draft:coverage` — Code Coverage Report
|
|
754
|
+
|
|
755
|
+
Measures test coverage quality after implementation. Complements TDD — TDD is the process, coverage is the measurement.
|
|
756
|
+
|
|
757
|
+
#### Process
|
|
758
|
+
|
|
759
|
+
1. **Detect coverage tool** — Auto-detect from tech-stack.md or project config files (jest, vitest, pytest-cov, go test -coverprofile, cargo tarpaulin, etc.)
|
|
760
|
+
2. **Determine scope** — Argument-provided path, architecture module files, track-changed files, or full project
|
|
761
|
+
3. **Run coverage** — Execute the coverage command and capture output
|
|
762
|
+
4. **Report** — Per-file breakdown with line/branch percentages and uncovered line ranges
|
|
763
|
+
5. **Gap analysis** — Classify uncovered lines:
|
|
764
|
+
- **Testable** — Should be covered; suggests specific tests to write
|
|
765
|
+
- **Defensive** — Error handlers for impossible states; acceptable to leave uncovered
|
|
766
|
+
- **Infrastructure** — Framework boilerplate; acceptable
|
|
767
|
+
6. **CHECKPOINT** — Developer reviews and approves
|
|
768
|
+
7. **Record results** — Update plan.md with coverage section, `.ai-context.md` module status, and metadata.json
|
|
769
|
+
|
|
770
|
+
Target: 95%+ line coverage (configurable in `workflow.md`).
|
|
771
|
+
|
|
772
|
+
---
|
|
773
|
+
|
|
774
|
+
### `/draft:jira` — Unified Jira Integration
|
|
775
|
+
|
|
776
|
+
Single entry point for Jira workflows via subcommands:
|
|
777
|
+
|
|
778
|
+
- `preview` (default): Generate editable export from track plan (supports `--epic` for richer hierarchy).
|
|
779
|
+
- `create`: Push issues to Jira via MCP (supports `--epic`).
|
|
780
|
+
- `review <JIRA-ID>`: Full qualification review of any existing Jira ticket using Draft's analysis tools (delegates to the review pipeline in `skills/jira/references/review.md`).
|
|
781
|
+
|
|
782
|
+
All work items live inside the root issue description by default. Use the unified router in normal usage.
|
|
783
|
+
|
|
784
|
+
---
|
|
785
|
+
|
|
786
|
+
### `/draft:adr` — Architecture Decision Records
|
|
787
|
+
|
|
788
|
+
Documents significant technical decisions with context, alternatives, and consequences. ADRs capture **why** a decision was made, not just what was decided.
|
|
789
|
+
|
|
790
|
+
#### When to Use
|
|
791
|
+
|
|
792
|
+
Create an ADR during or after `/draft:plan` when making architectural decisions:
|
|
793
|
+
- Adopting a new technology or framework
|
|
794
|
+
- Changing system architecture or module boundaries
|
|
795
|
+
- Selecting between multiple viable approaches with trade-offs
|
|
796
|
+
- Establishing patterns or conventions that constrain future work
|
|
797
|
+
|
|
798
|
+
Skip ADRs for trivial decisions (variable naming, formatting) or reversible choices.
|
|
799
|
+
|
|
800
|
+
#### ADR Structure
|
|
801
|
+
|
|
802
|
+
Each ADR contains:
|
|
803
|
+
- **Context** — The issue or forces driving the decision (technical, business, organizational)
|
|
804
|
+
- **Decision** — What we're proposing/doing, stated in active voice ("We will...")
|
|
805
|
+
- **Alternatives Considered** — At least 2 alternatives with pros/cons and rejection rationale
|
|
806
|
+
- **Consequences** — Positive outcomes, negative trade-offs, and risks with mitigations
|
|
807
|
+
|
|
808
|
+
#### Storage & Linking
|
|
809
|
+
|
|
810
|
+
ADRs are stored at `draft/adrs/NNNN-title.md` (e.g., `001-use-postgresql.md`). When created within a track context, the ADR file references the track ID in its metadata for traceability. Use `/draft:adr list` to see all decisions, `/draft:adr supersede <number>` to mark an ADR as replaced.
|
|
811
|
+
|
|
812
|
+
#### Status Lifecycle
|
|
813
|
+
|
|
814
|
+
`Proposed` (awaiting review) → `Accepted` (approved and in effect) → `Deprecated` (context changed) or `Superseded by ADR-XXX` (replaced by newer decision).
|
|
815
|
+
|
|
816
|
+
---
|
|
817
|
+
|
|
818
|
+
### `/draft:deep-review` — Module Lifecycle Audit
|
|
819
|
+
|
|
820
|
+
Perform an exhaustive end-to-end lifecycle review of a service, component, or module. Evaluates ACID compliance, architectural resilience, and production-grade enterprise quality.
|
|
821
|
+
|
|
822
|
+
#### Scope
|
|
823
|
+
|
|
824
|
+
- **Module-level only:** `/draft:deep-review src/auth`
|
|
825
|
+
|
|
826
|
+
Unlike standard review, this tool performs structural analysis and flags deep architectural flaws. It maintains a history file at `draft/deep-review-history.json` and generates an actionable specification for fixes at `draft/deep-review-report.md`. It does NOT auto-fix code.
|
|
827
|
+
|
|
828
|
+
---
|
|
829
|
+
|
|
830
|
+
### `/draft:bughunt` — Exhaustive Bug Discovery
|
|
831
|
+
|
|
832
|
+
Systematic bug hunt across 11 dimensions: correctness, reliability, security, performance, UI responsiveness, concurrency, state management, API contracts, accessibility, configuration, and tests.
|
|
833
|
+
|
|
834
|
+
#### Process
|
|
835
|
+
|
|
836
|
+
1. Load Draft context (architecture, tech-stack, product)
|
|
837
|
+
2. For tracks: verify implementation matches spec requirements
|
|
838
|
+
3. Analyze code across all 11 dimensions
|
|
839
|
+
4. Verify each finding (trace code paths, check for mitigations, eliminate false positives)
|
|
840
|
+
5. Generate severity-ranked report with fix recommendations
|
|
841
|
+
6. Detect language and test framework (GTest, pytest, go test, Jest/Vitest, cargo test, JUnit)
|
|
842
|
+
7. Discover test infrastructure (build system, test directories, naming conventions, dependencies)
|
|
843
|
+
8. Write regression tests in the project's native framework (new files for NO_COVERAGE, modifications for PARTIAL/WRONG_ASSERTION)
|
|
844
|
+
9. Validate tests compile/parse via language-appropriate command (up to 2 retries; never run tests — they are expected to fail against buggy code)
|
|
845
|
+
|
|
846
|
+
Generates report at `draft/bughunt-report-<timestamp>.md` (symlinked as `bughunt-report-latest.md`) or `draft/tracks/<id>/bughunt-report-<timestamp>.md`.
|
|
847
|
+
Test files are written directly to the project using native test conventions.
|
|
848
|
+
|
|
849
|
+
---
|
|
850
|
+
|
|
851
|
+
### `/draft:review` — Code Review Orchestrator
|
|
852
|
+
|
|
853
|
+
Canonical review parent command.
|
|
854
|
+
|
|
855
|
+
#### Parent Behavior
|
|
856
|
+
|
|
857
|
+
`/draft:review` owns the review family:
|
|
858
|
+
|
|
859
|
+
- baseline three-stage review
|
|
860
|
+
- `/draft:quick-review` for small ad-hoc change review
|
|
861
|
+
- `/draft:bughunt` for defect-focused escalation
|
|
862
|
+
- `/draft:deep-review` for module-level production-readiness escalation
|
|
863
|
+
- `/draft:assist-review` for human-review handoff summaries
|
|
864
|
+
|
|
865
|
+
Explicit parent modes route directly:
|
|
866
|
+
|
|
867
|
+
- `/draft:review quick`
|
|
868
|
+
- `/draft:review bughunt`
|
|
869
|
+
- `/draft:review deep`
|
|
870
|
+
- `/draft:review assist`
|
|
871
|
+
|
|
872
|
+
Important scope note:
|
|
873
|
+
|
|
874
|
+
- `/draft:impact` is not part of this family in the current implementation; it measures project delivery telemetry, not code-review depth.
|
|
875
|
+
|
|
876
|
+
#### Baseline Review
|
|
877
|
+
|
|
878
|
+
The default `/draft:review` path is the baseline three-stage review:
|
|
879
|
+
|
|
880
|
+
- Stage 1 automated validation
|
|
881
|
+
- Stage 2 spec compliance (track review only)
|
|
882
|
+
- Stage 3 code quality
|
|
883
|
+
|
|
884
|
+
When graph data exists, baseline review always includes blast-radius / hotspot impact analysis.
|
|
885
|
+
|
|
886
|
+
#### Track-Level Review
|
|
887
|
+
|
|
888
|
+
Reviews a track's implementation against its spec.md and plan.md:
|
|
889
|
+
- **Stage 1 (Automated Validation):** Fast, static checks for structural flaws (dead code, circular dependencies, OWASP secrets, N+1 patterns).
|
|
890
|
+
- **Stage 2 (Spec Compliance):** Verifies all functional requirements and acceptance criteria are met.
|
|
891
|
+
- **Stage 3 (Code Quality):** Evaluates architecture, error handling, testing, and maintainability.
|
|
892
|
+
|
|
893
|
+
Extracts commit SHAs from plan.md to determine diff range. Supports fuzzy track matching.
|
|
894
|
+
|
|
895
|
+
#### Project-Level Review
|
|
896
|
+
|
|
897
|
+
Reviews arbitrary changes (static validation + code quality only, no spec compliance):
|
|
898
|
+
- `project` — uncommitted changes
|
|
899
|
+
- `files <pattern>` — specific file patterns
|
|
900
|
+
- `commits <range>` — commit range
|
|
901
|
+
|
|
902
|
+
#### Quality Integration
|
|
903
|
+
|
|
904
|
+
- `with-bughunt` — include `/draft:bughunt` findings
|
|
905
|
+
- `with-assist` — include `/draft:assist-review` structural handoff summary
|
|
906
|
+
- `full` — enable bughunt + assist, and allow justified deep-review escalation
|
|
907
|
+
|
|
908
|
+
Generates unified report at `draft/tracks/<id>/review-report.md` or `draft/review-report.md`.
|
|
909
|
+
|
|
910
|
+
#### Examples
|
|
911
|
+
|
|
912
|
+
```bash
|
|
913
|
+
/draft:review # auto-detect active track
|
|
914
|
+
/draft:review track add-user-auth # review specific track
|
|
915
|
+
/draft:review project # review uncommitted changes
|
|
916
|
+
/draft:review files "src/**/*.ts" # review specific files
|
|
917
|
+
/draft:review commits main...HEAD # review commit range
|
|
918
|
+
/draft:review track my-feature full # comprehensive review with bughunt
|
|
919
|
+
/draft:review quick files "src/**/*.ts" # explicit quick review via parent
|
|
920
|
+
/draft:review deep auth # explicit deep review via parent
|
|
921
|
+
/draft:review assist track my-feature # reviewer handoff summary via parent
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
---
|
|
925
|
+
|
|
926
|
+
### `/draft:learn` — Pattern Discovery & Guardrails Update
|
|
927
|
+
|
|
928
|
+
Scans the codebase to discover recurring coding patterns and updates `draft/guardrails.md` with learned conventions (skip in future analysis) and anti-patterns (always flag). Creates a continuous improvement loop where quality commands become more accurate over time.
|
|
929
|
+
|
|
930
|
+
#### How It Works
|
|
931
|
+
|
|
932
|
+
1. Loads existing guardrails and Draft context
|
|
933
|
+
2. Scans source files across pattern dimensions: error handling, naming, architecture, concurrency, data flow, testing, configuration
|
|
934
|
+
3. Identifies patterns with 3+ consistent occurrences
|
|
935
|
+
4. Cross-references against `tech-stack.md ## Accepted Patterns` and `.ai-context.md` to avoid duplicates
|
|
936
|
+
5. Updates `draft/guardrails.md` with new entries (conventions or anti-patterns)
|
|
937
|
+
|
|
938
|
+
#### Subcommands
|
|
939
|
+
|
|
940
|
+
- No arguments — full codebase scan
|
|
941
|
+
- `promote` — review high-confidence learned patterns for promotion to Hard Guardrails or Accepted Patterns
|
|
942
|
+
- `migrate` — migrate `## Guardrails` from legacy `workflow.md` to `guardrails.md`
|
|
943
|
+
- `<path>` — scan specific directory or file pattern
|
|
944
|
+
|
|
945
|
+
#### Continuous Learning Loop
|
|
946
|
+
|
|
947
|
+
Quality commands (`/draft:bughunt`, `/draft:deep-review`, `/draft:review`) also update guardrails incrementally after each run via the shared pattern learning procedure. `/draft:learn` performs a comprehensive standalone scan.
|
|
948
|
+
|
|
949
|
+
#### Examples
|
|
950
|
+
|
|
951
|
+
```bash
|
|
952
|
+
/draft:learn # full codebase pattern scan
|
|
953
|
+
/draft:learn src/api/ # scan specific directory
|
|
954
|
+
/draft:learn promote # review promotion candidates
|
|
955
|
+
/draft:learn migrate # migrate from workflow.md
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
---
|
|
959
|
+
|
|
960
|
+
### `/draft:change` — Course Correction
|
|
961
|
+
|
|
962
|
+
Handles mid-track requirement changes without losing work. Analyzes the impact of the change on completed and pending tasks, proposes amendments to `spec.md` and `plan.md`, then applies them only after explicit confirmation.
|
|
963
|
+
|
|
964
|
+
#### When to Use
|
|
965
|
+
|
|
966
|
+
Use when requirements shift after a track is already in progress:
|
|
967
|
+
- A stakeholder changes scope mid-sprint
|
|
968
|
+
- A dependency constraint forces a pivot
|
|
969
|
+
- New information invalidates part of the original spec
|
|
970
|
+
|
|
971
|
+
#### Process
|
|
972
|
+
|
|
973
|
+
1. **Detect active track** — Auto-detects the `[~]` In Progress track; use `track <id>` to target a specific track
|
|
974
|
+
2. **Parse change description** — Extracts the change from `$ARGUMENTS`
|
|
975
|
+
3. **Impact analysis** — Classifies every existing task and AC against the change:
|
|
976
|
+
- Tasks still valid, need modification, now invalid, or newly required
|
|
977
|
+
- Completed `[x]` tasks that the change retroactively invalidates are flagged explicitly
|
|
978
|
+
4. **Propose amendments** — Presents exact diffs for `spec.md` and `plan.md` (what will be added, removed, or reworded)
|
|
979
|
+
5. **CHECKPOINT** — `[yes / no / edit]`. No file is touched until the user confirms. The loop continues until the user selects `yes` or `no`.
|
|
980
|
+
6. **Apply & log** — Writes changes to `spec.md` and `plan.md`, appends a timestamped entry to `## Change Log` in `plan.md`, updates `metadata.json`
|
|
981
|
+
|
|
982
|
+
#### Examples
|
|
983
|
+
|
|
984
|
+
```bash
|
|
985
|
+
/draft:change the export format should support JSON in addition to CSV
|
|
986
|
+
/draft:change track add-export-feature also require a progress indicator for exports over 500 rows
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
---
|
|
990
|
+
|
|
991
|
+
## Architecture Mode
|
|
992
|
+
|
|
993
|
+
Draft supports granular pre-implementation design for complex projects. **Architecture mode is automatically enabled when `draft/tracks/<id>/.ai-context.md` exists** (created by `/draft:decompose`). Falls back to `draft/tracks/<id>/architecture.md` for legacy projects.
|
|
994
|
+
|
|
995
|
+
**How it works:**
|
|
996
|
+
1. Run `/draft:decompose` on a track → Creates `draft/tracks/<id>/architecture.md` (and derived `.ai-context.md`)
|
|
997
|
+
2. Run `/draft:implement` → Automatically detects `architecture.md` and enables architecture features
|
|
998
|
+
3. Features: Story writing, Execution State design, Function Skeletons, ~200-line chunk reviews
|
|
999
|
+
|
|
1000
|
+
See `core/agents/architect.md` for detailed decomposition rules, story writing, and skeleton generation.
|
|
1001
|
+
|
|
1002
|
+
### Module Decomposition
|
|
1003
|
+
|
|
1004
|
+
Use `/draft:decompose` to break a project or track into modules:
|
|
1005
|
+
|
|
1006
|
+
- **Project-wide:** `draft/architecture.md` — overall codebase module structure (derives `draft/.ai-context.md`)
|
|
1007
|
+
- **Per-track:** `draft/tracks/<id>/architecture.md` — module breakdown for a specific feature (derives `draft/tracks/<id>/.ai-context.md`)
|
|
1008
|
+
|
|
1009
|
+
Each module defines: responsibility, files, API surface, dependencies, complexity. Modules are ordered by dependency graph (topological sort) to determine implementation sequence.
|
|
1010
|
+
|
|
1011
|
+
### Pre-Implementation Design
|
|
1012
|
+
|
|
1013
|
+
When `architecture.md` exists for a track, `/draft:implement` automatically enables three additional checkpoints before the TDD cycle:
|
|
1014
|
+
|
|
1015
|
+
1. **Story** — Natural-language algorithm description (Input → Process → Output) written as a comment at the top of the code file. Captures the "how" before coding. Mandatory checkpoint for developer approval.
|
|
1016
|
+
|
|
1017
|
+
2. **Execution State** — Define intermediate state variables (input state, intermediate state, output state, error state) needed for processing. Bridges the gap between algorithm and code structure. Mandatory checkpoint.
|
|
1018
|
+
|
|
1019
|
+
3. **Function Skeletons** — Generate function/method stubs with complete signatures, types, and docstrings. No implementation bodies. Developer approves names, signatures, and structure before TDD begins. Mandatory checkpoint.
|
|
1020
|
+
|
|
1021
|
+
Additionally, implementation chunks are limited to ~200 lines with a review checkpoint after each chunk.
|
|
1022
|
+
|
|
1023
|
+
### Code Coverage
|
|
1024
|
+
|
|
1025
|
+
Use `/draft:coverage` after implementation to measure test quality:
|
|
1026
|
+
|
|
1027
|
+
- Auto-detects coverage tool from `tech-stack.md`
|
|
1028
|
+
- Targets 95%+ line coverage (configurable in `workflow.md`)
|
|
1029
|
+
- Reports per-file breakdown and identifies uncovered lines
|
|
1030
|
+
- Classifies gaps: testable (should add tests), defensive (acceptable), infrastructure (acceptable)
|
|
1031
|
+
- Results recorded in `plan.md` and `.ai-context.md` using the following format:
|
|
1032
|
+
|
|
1033
|
+
#### Coverage Results Format (plan.md)
|
|
1034
|
+
|
|
1035
|
+
Add a `## Coverage` section at the end of the relevant phase:
|
|
1036
|
+
|
|
1037
|
+
```markdown
|
|
1038
|
+
## Coverage
|
|
1039
|
+
- **Overall:** 96.2% line coverage (target: 95%)
|
|
1040
|
+
- **Tool:** jest --coverage
|
|
1041
|
+
- **Date:** 2026-02-01
|
|
1042
|
+
|
|
1043
|
+
| File | Lines | Covered | % | Uncovered Lines |
|
|
1044
|
+
|------|-------|---------|---|-----------------|
|
|
1045
|
+
| src/auth.ts | 120 | 116 | 96.7% | 45, 88, 112, 119 |
|
|
1046
|
+
| src/config.ts | 80 | 80 | 100% | - |
|
|
1047
|
+
|
|
1048
|
+
### Gaps
|
|
1049
|
+
- **Testable:** `auth.ts:45` — error branch for expired token (add test)
|
|
1050
|
+
- **Defensive:** `auth.ts:88` — unreachable fallback (acceptable)
|
|
1051
|
+
- **Infrastructure:** `auth.ts:112,119` — logging statements (acceptable)
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
#### Coverage Results Format (.ai-context.md)
|
|
1055
|
+
|
|
1056
|
+
Update each module's status line to include coverage:
|
|
1057
|
+
|
|
1058
|
+
```markdown
|
|
1059
|
+
- **Status:** [x] Complete — 96.7% coverage
|
|
1060
|
+
```
|
|
1061
|
+
|
|
1062
|
+
And add a coverage summary in the Notes section:
|
|
1063
|
+
|
|
1064
|
+
```markdown
|
|
1065
|
+
## Notes
|
|
1066
|
+
- Overall coverage: 96.2% (target: 95%)
|
|
1067
|
+
- Uncovered gaps classified and documented in plan.md
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
Coverage complements TDD — TDD is the process (write test, implement, refactor), coverage is the measurement.
|
|
1071
|
+
|
|
1072
|
+
### When to Use Architecture Mode
|
|
1073
|
+
|
|
1074
|
+
**Good fit:**
|
|
1075
|
+
- Multi-module features with component dependencies
|
|
1076
|
+
- New projects where architecture decisions haven't been made
|
|
1077
|
+
- Complex algorithms or data transformations
|
|
1078
|
+
- Teams wanting maximum review granularity
|
|
1079
|
+
|
|
1080
|
+
**Overkill:**
|
|
1081
|
+
- Simple features touching 1-2 files
|
|
1082
|
+
- Bug fixes with clear scope
|
|
1083
|
+
- Configuration changes
|
|
1084
|
+
|
|
1085
|
+
### Workflow with Architecture Mode
|
|
1086
|
+
|
|
1087
|
+
```
|
|
1088
|
+
/draft:init
|
|
1089
|
+
│ (creates draft/architecture.md + draft/.ai-context.md for brownfield)
|
|
1090
|
+
│
|
|
1091
|
+
/draft:plan "feature"
|
|
1092
|
+
│ (creates draft/tracks/feature/spec.md + plan.md)
|
|
1093
|
+
│
|
|
1094
|
+
/draft:decompose
|
|
1095
|
+
│ (creates draft/tracks/feature/architecture.md + .ai-context.md)
|
|
1096
|
+
│ → Architecture mode AUTO-ENABLED
|
|
1097
|
+
│
|
|
1098
|
+
/draft:implement
|
|
1099
|
+
│ ├── Story → CHECKPOINT
|
|
1100
|
+
│ ├── Execution State → CHECKPOINT
|
|
1101
|
+
│ ├── Skeletons → CHECKPOINT
|
|
1102
|
+
│ ├── TDD (red/green/refactor)
|
|
1103
|
+
│ └── ~200-line chunk review → CHECKPOINT
|
|
1104
|
+
│
|
|
1105
|
+
/draft:coverage → coverage report → CHECKPOINT
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
**Key insight:** Running `/draft:decompose` automatically enables architecture features for that track. No manual configuration needed.
|
|
1109
|
+
|
|
1110
|
+
---
|
|
1111
|
+
|
|
1112
|
+
## Jira Integration (Optional)
|
|
1113
|
+
|
|
1114
|
+
Sync tracks to Jira via the unified router:
|
|
1115
|
+
|
|
1116
|
+
`/draft:jira preview` → review/edit export → `/draft:jira create`
|
|
1117
|
+
|
|
1118
|
+
Story points are auto-calculated from task count:
|
|
1119
|
+
- 1-2 tasks = 1 point
|
|
1120
|
+
- 3-4 tasks = 2 points
|
|
1121
|
+
- 5-6 tasks = 3 points
|
|
1122
|
+
- 7+ tasks = 5 points
|
|
1123
|
+
|
|
1124
|
+
Requires `jira.md` configuration with project key, board ID, and epic link field.
|
|
1125
|
+
|
|
1126
|
+
## TDD Workflow (Optional)
|
|
1127
|
+
|
|
1128
|
+
When enabled in workflow.md:
|
|
1129
|
+
|
|
1130
|
+
1. **Red** - Write failing test first
|
|
1131
|
+
2. **Green** - Implement minimum code to pass
|
|
1132
|
+
3. **Refactor** - Clean up with tests green
|
|
1133
|
+
4. **Commit** - Following project conventions
|
|
1134
|
+
|
|
1135
|
+
## Intent Mapping
|
|
1136
|
+
|
|
1137
|
+
Natural language patterns that map to Draft commands:
|
|
1138
|
+
|
|
1139
|
+
| User Says | Action |
|
|
1140
|
+
|-----------|--------|
|
|
1141
|
+
| "set up the project" | Initialize Draft |
|
|
1142
|
+
| "plan this", "scope this work", "continue planning" | Planning orchestrator |
|
|
1143
|
+
| "index services", "aggregate context" | Monorepo service index |
|
|
1144
|
+
| "new feature", "add X" | Planning orchestrator (usually routes to new track) |
|
|
1145
|
+
| "start implementing" | Execute tasks from plan |
|
|
1146
|
+
| "what's the status" | Show progress overview |
|
|
1147
|
+
| "undo", "revert" | Rollback changes |
|
|
1148
|
+
| "break into modules" | Module decomposition |
|
|
1149
|
+
| "check coverage" | Code coverage report |
|
|
1150
|
+
| "deep review", "audit module", "production audit" | Module lifecycle audit |
|
|
1151
|
+
| "hunt bugs", "find bugs" | Systematic bug discovery |
|
|
1152
|
+
| "review code", "review track", "check quality" | Code review orchestrator (track/project) |
|
|
1153
|
+
| "learn patterns", "update guardrails", "discover conventions" | Pattern discovery & guardrails update |
|
|
1154
|
+
| "requirements changed", "scope changed", "update the spec" | Planning orchestrator (routes to course correction) |
|
|
1155
|
+
| "preview jira", "export to jira" | Preview Jira issues |
|
|
1156
|
+
| "create jira issues" | Create Jira issues via MCP |
|
|
1157
|
+
| "upload for review", "open a PR", "submit code" | Upload for review |
|
|
1158
|
+
| "find regression", "when did this break", "bisect" | Regression detection |
|
|
1159
|
+
| "qualify epic", "epic qualification" | Epic status and qualification |
|
|
1160
|
+
| "the plan" | Read active track's plan.md |
|
|
1161
|
+
| "the spec" | Read active track's spec.md |
|
|
1162
|
+
|
|
1163
|
+
## Quality Disciplines
|
|
1164
|
+
|
|
1165
|
+
### Verification Before Completion
|
|
1166
|
+
|
|
1167
|
+
**Iron Law:** Evidence before claims, always.
|
|
1168
|
+
|
|
1169
|
+
Every completion claim requires running the verification command in the current message, reading full output, showing evidence alongside the claim, and only then updating `[x]` status markers. No fresh run in this message → no check.
|
|
1170
|
+
|
|
1171
|
+
### Systematic Debugging
|
|
1172
|
+
|
|
1173
|
+
**Iron Law:** No fixes without root cause investigation first. See `core/agents/debugger.md` for the four-phase process (Investigate → Analyze → Hypothesize → Implement).
|
|
1174
|
+
|
|
1175
|
+
### Root Cause Analysis (Bug Tracks)
|
|
1176
|
+
|
|
1177
|
+
**Iron Law:** No fix without a confirmed root cause. No investigation without scope boundaries. See `core/agents/rca.md` for the four-phase RCA process, classification taxonomy, and distributed-systems considerations.
|
|
1178
|
+
|
|
1179
|
+
### Three-Stage Review
|
|
1180
|
+
|
|
1181
|
+
At phase boundaries: Stage 1 automated validation → Stage 2 spec compliance → Stage 3 code quality. See `core/agents/reviewer.md` for the output template, stopping rules, and full process.
|
|
1182
|
+
|
|
1183
|
+
---
|
|
1184
|
+
|
|
1185
|
+
## Agents
|
|
1186
|
+
|
|
1187
|
+
Canonical agent behavior lives in `core/agents/*.md` — those files are inlined at runtime. This table is a pointer index only; when in doubt, defer to the agent file.
|
|
1188
|
+
|
|
1189
|
+
| Agent | File | Role |
|
|
1190
|
+
|-------|------|------|
|
|
1191
|
+
| Debugger | `core/agents/debugger.md` | Activated on `[!]` blocked tasks. Four-phase root cause investigation. |
|
|
1192
|
+
| RCA | `core/agents/rca.md` | Activated for bug/RCA tracks. Structured SRE-style postmortem methodology. |
|
|
1193
|
+
| Reviewer | `core/agents/reviewer.md` | Activated at phase boundaries. Three-stage automated + spec + quality review. |
|
|
1194
|
+
| Architect | `core/agents/architect.md` | Activated in `/draft:decompose` and architecture-mode `/draft:implement`. Module decomposition, story writing, function skeletons. |
|
|
1195
|
+
| Planner | `core/agents/planner.md` | Activated during `/draft:plan`, `/draft:new-track`, and `/draft:decompose`. Phased plan generation. |
|
|
1196
|
+
| Writer | `core/agents/writer.md` | Activated during `/draft:documentation`. Doc generation and condensation. |
|
|
1197
|
+
| Ops | `core/agents/ops.md` | Activated for `/draft:incident-response`, `/draft:deploy-checklist`, `/draft:standup`. Hands off to RCA for deep investigation. |
|
|
1198
|
+
|
|
1199
|
+
---
|
|
1200
|
+
|
|
1201
|
+
## Concurrency
|
|
1202
|
+
|
|
1203
|
+
Draft skills are designed for single-agent, single-track execution. Do not run multiple Draft commands concurrently on the same track.
|
|
1204
|
+
|
|
1205
|
+
## Communication Style
|
|
1206
|
+
|
|
1207
|
+
Lead with conclusions. Be concise. Prioritize clarity over comprehensiveness.
|
|
1208
|
+
|
|
1209
|
+
- Direct, professional tone
|
|
1210
|
+
- Code over explanation when implementing
|
|
1211
|
+
- Complete, runnable code blocks
|
|
1212
|
+
- Show only changed lines with context for updates
|
|
1213
|
+
- Ask clarifying questions only when requirements are genuinely ambiguous
|
|
1214
|
+
|
|
1215
|
+
## Principles
|
|
1216
|
+
|
|
1217
|
+
1. **Plan before you build** - Create specs and plans that guide development
|
|
1218
|
+
2. **Maintain context** - Ensure agents follow style guides and product goals
|
|
1219
|
+
3. **Iterate safely** - Review plans before code is written
|
|
1220
|
+
4. **Work as a team** - Share project context across team members
|
|
1221
|
+
5. **Verify before claiming** - Evidence before assertions, always
|