@drafthq/draft 3.6.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/README.md +28 -49
  5. package/bin/README.md +47 -1
  6. package/cli/src/installer.js +1 -1
  7. package/cli/src/lib/cursor-registry.js +10 -0
  8. package/core/agents/architect.md +21 -9
  9. package/core/agents/debugger.md +5 -0
  10. package/core/agents/ops.md +7 -2
  11. package/core/agents/planner.md +7 -0
  12. package/core/agents/rca.md +14 -3
  13. package/core/agents/reviewer.md +1 -0
  14. package/core/agents/writer.md +6 -0
  15. package/core/knowledge-base.md +22 -3
  16. package/core/methodology.md +30 -5
  17. package/core/shared/condensation.md +27 -17
  18. package/core/shared/context-verify.md +3 -1
  19. package/core/shared/cross-skill-dispatch.md +7 -3
  20. package/core/shared/draft-context-loading.md +3 -0
  21. package/core/shared/git-report-metadata.md +1 -0
  22. package/core/shared/graph-query.md +0 -2
  23. package/core/shared/graph-usage-report.md +1 -1
  24. package/core/shared/jira-sync.md +10 -6
  25. package/core/shared/okf-retrieval.md +1 -1
  26. package/core/shared/parallel-analysis.md +14 -7
  27. package/core/shared/pattern-learning.md +2 -0
  28. package/core/shared/template-contract.md +1 -1
  29. package/core/shared/vcs-commands.md +5 -2
  30. package/core/templates/ai-context.md +3 -2
  31. package/core/templates/ai-profile.md +7 -0
  32. package/core/templates/architecture.md +6 -2
  33. package/core/templates/discovery.md +1 -1
  34. package/core/templates/guardrails.md +9 -0
  35. package/core/templates/hld.md +5 -4
  36. package/core/templates/intake-questions.md +45 -0
  37. package/core/templates/jira.md +11 -2
  38. package/core/templates/lld.md +8 -5
  39. package/core/templates/okf/concept.md +0 -1
  40. package/core/templates/product.md +11 -2
  41. package/core/templates/rca.md +6 -0
  42. package/core/templates/service-index.md +1 -0
  43. package/core/templates/spec.md +15 -0
  44. package/core/templates/tech-stack.md +12 -0
  45. package/core/templates/workflow.md +20 -0
  46. package/integrations/agents/AGENTS.md +1272 -292
  47. package/integrations/copilot/.github/copilot-instructions.md +1272 -292
  48. package/package.json +1 -1
  49. package/scripts/fetch-memory-engine.sh +24 -6
  50. package/scripts/lib.sh +11 -4
  51. package/scripts/tools/_graph_queries.sh +10 -3
  52. package/scripts/tools/_lib.sh +33 -11
  53. package/scripts/tools/check-repo-size.sh +125 -0
  54. package/scripts/tools/check-skill-line-caps.sh +1 -2
  55. package/scripts/tools/check-template-noop.sh +0 -1
  56. package/scripts/tools/classify-files.sh +2 -2
  57. package/scripts/tools/cycle-detect.sh +16 -8
  58. package/scripts/tools/fix-whitespace.sh +3 -0
  59. package/scripts/tools/git-metadata.sh +6 -0
  60. package/scripts/tools/graph-arch.sh +1 -1
  61. package/scripts/tools/graph-callers.sh +6 -3
  62. package/scripts/tools/graph-impact.sh +4 -2
  63. package/scripts/tools/graph-init.sh +12 -8
  64. package/scripts/tools/graph-preflight.sh +3 -0
  65. package/scripts/tools/graph-query.sh +70 -7
  66. package/scripts/tools/graph-snapshot.sh +29 -5
  67. package/scripts/tools/hotspot-rank.sh +2 -1
  68. package/scripts/tools/install-smoke-test.sh +223 -0
  69. package/scripts/tools/mermaid-from-graph.sh +2 -1
  70. package/scripts/tools/migrate-track-frontmatter.sh +9 -10
  71. package/scripts/tools/okf-coverage-check.sh +4 -3
  72. package/scripts/tools/okf-fix-links.sh +18 -93
  73. package/scripts/tools/okf-plan-concepts.sh +5 -8
  74. package/scripts/tools/okf-render-views.sh +19 -14
  75. package/scripts/tools/okf-validate-quality.sh +13 -2
  76. package/scripts/tools/okf-validate.sh +13 -2
  77. package/scripts/tools/parse-git-log.sh +19 -1
  78. package/scripts/tools/resolve-tools.sh +24 -8
  79. package/scripts/tools/verify-citations.sh +1 -2
  80. package/scripts/tools/verify-doc-anchors.sh +13 -33
  81. package/scripts/tools/verify-graph-binary.sh +13 -3
  82. package/skills/GRAPH.md +21 -10
  83. package/skills/adr/SKILL.md +24 -6
  84. package/skills/assist-review/SKILL.md +2 -1
  85. package/skills/bughunt/SKILL.md +54 -11
  86. package/skills/bughunt/references/regression-tests.md +14 -4
  87. package/skills/change/SKILL.md +19 -9
  88. package/skills/coverage/SKILL.md +26 -10
  89. package/skills/debug/SKILL.md +12 -2
  90. package/skills/decompose/SKILL.md +39 -9
  91. package/skills/deep-review/SKILL.md +17 -4
  92. package/skills/deploy-checklist/SKILL.md +9 -2
  93. package/skills/documentation/SKILL.md +12 -1
  94. package/skills/draft/SKILL.md +40 -29
  95. package/skills/draft/context-files.md +8 -1
  96. package/skills/draft/quality-guide.md +10 -2
  97. package/skills/graph/SKILL.md +1 -1
  98. package/skills/impact/SKILL.md +3 -1
  99. package/skills/implement/SKILL.md +60 -18
  100. package/skills/incident-response/SKILL.md +5 -2
  101. package/skills/init/SKILL.md +102 -23
  102. package/skills/init/references/architecture-spec.md +31 -7
  103. package/skills/init/references/okf-emitter.md +3 -3
  104. package/skills/jira/SKILL.md +33 -13
  105. package/skills/jira/references/review.md +61 -19
  106. package/skills/learn/SKILL.md +29 -6
  107. package/skills/new-track/SKILL.md +73 -18
  108. package/skills/quick-review/SKILL.md +7 -2
  109. package/skills/revert/SKILL.md +11 -5
  110. package/skills/review/SKILL.md +123 -24
  111. package/skills/review/references/zero-setup-mode.md +117 -0
  112. package/skills/standup/SKILL.md +9 -1
  113. package/skills/status/SKILL.md +6 -6
  114. package/skills/tech-debt/SKILL.md +7 -1
  115. package/skills/testing-strategy/SKILL.md +10 -2
  116. package/skills/tour/SKILL.md +2 -1
  117. package/skills/upload/SKILL.md +3 -2
@@ -12,7 +12,7 @@
12
12
  "name": "draft",
13
13
  "source": "./",
14
14
  "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
15
- "version": "3.6.0",
15
+ "version": "3.7.1",
16
16
  "author": {
17
17
  "name": "mayurpise"
18
18
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "draft",
3
3
  "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
4
- "version": "3.6.0",
4
+ "version": "3.7.1",
5
5
  "author": {
6
6
  "name": "mayurpise"
7
7
  },
@@ -2,7 +2,7 @@
2
2
  "name": "draft",
3
3
  "displayName": "Draft",
4
4
  "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
5
- "version": "3.6.0",
5
+ "version": "3.7.1",
6
6
  "skills": "./skills/",
7
7
  "agents": "./core/agents/",
8
8
  "author": {
package/README.md CHANGED
@@ -40,6 +40,8 @@ Three stages, one command:
40
40
  2. **Spec compliance** — checks the diff against the agreed spec, not vibes
41
41
  3. **Code quality** — flags hotspots, blast radius, and missing test coverage using a tree-sitter knowledge graph of your repo
42
42
 
43
+ No setup required for the first run: on an un-indexed repo it reviews the diff and names the structural checks it skipped, so you see findings before you spend anything.
44
+
43
45
  Free. No API keys. No paid tier. No vendor lock-in. Catches the 3 bugs you missed before they hit your reviewer.
44
46
 
45
47
  > *Demo coming soon — for now, [watch the 8-minute walkthrough](https://www.youtube.com/watch?v=gBSwFEFVd7Y).*
@@ -76,35 +78,44 @@ Flags: `--global` / `--project` to pick scope, `--dry-run` to preview, `--force`
76
78
  Then, in Claude Code (after restarting):
77
79
 
78
80
  ```bash
79
- /draft:init # 5-phase codebase analysis (one-time)
80
- /draft:review # run this on every branch before you push
81
+ /draft:review # start here. No setup, no indexing. Reviews your current diff.
82
+ /draft:init # once you've seen what it catches: index the repo (one-time)
83
+ /draft:review # same command, now with blast radius + hotspots + cycle detection
81
84
  ```
82
85
 
86
+ `/draft:review` runs on an un-indexed repo and tells you exactly which structural checks it had to skip. Indexing is the upgrade, not the entry fee.
87
+
83
88
  Run `/draft` for the full command map.
84
89
 
85
90
  <details>
86
91
  <summary><strong>Other ways to install →</strong></summary>
87
92
 
88
93
  ### Claude Code — native marketplace
94
+
89
95
  ```bash
90
96
  /plugin marketplace add drafthq/draft
91
97
  /plugin install draft
92
98
  ```
93
99
 
94
100
  ### Cursor — from GitHub
101
+
95
102
  Cursor requires `.cursor-plugin/plugin.json`; the `draft install cursor` command also registers the plugin via the shared Claude plugin registry that Cursor reads on many builds. To add from source instead, use *Settings > Rules, Skills, Subagents > Rules > New > Add from Github*:
96
- ```
103
+
104
+ ```text
97
105
  https://github.com/drafthq/draft.git
98
106
  ```
99
107
 
100
108
  ### GitHub Copilot
109
+
101
110
  Copilot reads a committed instructions file — copy it directly (not a `draft install` host):
111
+
102
112
  ```bash
103
113
  mkdir -p .github && curl -o .github/copilot-instructions.md \
104
114
  https://raw.githubusercontent.com/drafthq/draft/main/integrations/copilot/.github/copilot-instructions.md
105
115
  ```
106
116
 
107
117
  ### Gemini
118
+
108
119
  ```bash
109
120
  curl -o .gemini.md https://raw.githubusercontent.com/drafthq/draft/main/integrations/gemini/.gemini.md
110
121
  ```
@@ -113,53 +124,19 @@ curl -o .gemini.md https://raw.githubusercontent.com/drafthq/draft/main/integrat
113
124
 
114
125
  ---
115
126
 
116
- ## Beyond `/draft:review` — 32 more commands
127
+ ## The five commands
117
128
 
118
- `/draft:review` is the wedge. Once Draft has indexed your repo, you also get spec-driven planning, TDD-enforced implementation, exhaustive bug hunting, deep architectural audits, and 32 more commands covering the full development lifecycle.
119
-
120
- ---
129
+ | Command | What it does |
130
+ |---------|--------------|
131
+ | **`/draft:review`** | 3-stage review of your diff. **Works with zero setup** — run it first. |
132
+ | **`/draft:init`** | Index the repo once. Adds blast radius, caller lookup, hotspot ranking, and cycle detection to every later review. |
133
+ | **`/draft:new-track`** | Turn an idea into a spec + plan before any code is written. |
134
+ | **`/draft:implement`** | Execute the plan task-by-task under TDD with verification gates. |
135
+ | **`/draft:graph`** | Build or refresh the knowledge-graph snapshot on its own. |
121
136
 
122
- ## What You Get
137
+ That is the whole loop. 28 more specialist commands — bug hunting, ACID audits, ADRs, tech debt, incident response, Jira, coverage, standups — sit behind five intent routers (`/draft:plan`, `/draft:discover`, `/draft:ops`, `/draft:docs`, `/draft:jira`).
123
138
 
124
- | Command | What It Does |
125
- |---------|--------------|
126
- | **`/draft`** | Overview, intent mapping, and command reference |
127
- | **`/draft:plan`** | Router for planning, architecture, and track management |
128
- | **`/draft:ops`** | Router for operations, deployment, incident, and lifecycle |
129
- | **`/draft:docs`** | Router for authoring and documentation workflows |
130
- | **`/draft:discover`** | Router for discovery, debugging, investigation, and quality |
131
- | **`/draft:init`** | Analyze codebase, create context files + state tracking |
132
- | **`/draft:graph`** | Build / refresh the knowledge-graph snapshot |
133
- | **`/draft:new-track`** | Collaborative spec + plan with AI |
134
- | **`/draft:decompose`** | Module decomposition with dependency mapping |
135
- | **`/draft:implement`** | TDD workflow with checkpoints |
136
- | **`/draft:coverage`** | Code coverage report (target 95%+) |
137
- | **`/draft:review`** | 3-stage review (validation + spec compliance + code quality) |
138
- | **`/draft:deep-review`** | Enterprise-grade module lifecycle and ACID audit |
139
- | **`/draft:bughunt`** | Exhaustive 14-dimension defect discovery with taint tracking |
140
- | **`/draft:learn`** | Discover coding patterns, update guardrails |
141
- | **`/draft:adr`** | Architecture Decision Records |
142
- | **`/draft:status`** | Show progress overview |
143
- | **`/draft:revert`** | Git-aware rollback |
144
- | **`/draft:change`** | Handle mid-track requirement changes |
145
- | **`/draft:debug`** | Structured debugging: reproduce, isolate, diagnose, fix |
146
- | **`/draft:quick-review`** | Lightweight 4-dimension code review |
147
- | **`/draft:deploy-checklist`** | Pre-deployment verification with rollback triggers |
148
- | **`/draft:upload`** | Pre-upload handoff gate (review, HLD, checklist, validators) |
149
- | **`/draft:testing-strategy`** | Test plan design with coverage targets |
150
- | **`/draft:tech-debt`** | Technical debt analysis across 6 dimensions |
151
- | **`/draft:standup`** | Git activity standup summary (read-only) |
152
- | **`/draft:incident-response`** | Incident lifecycle: triage, communicate, mitigate, postmortem |
153
- | **`/draft:documentation`** | Technical docs: readme, runbook, api, onboarding |
154
- | **`/draft:integrations`** | External system exports and syncs (jira preview / create) |
155
- | **`/draft:jira`** | Unified Jira workflows (preview / create / review) |
156
- | **`/draft:tour`** | Interactive architecture mentorship and codebase walk-through |
157
- | **`/draft:impact`** | ROI analytics tracking friction and timeline metrics |
158
- | **`/draft:assist-review`** | Summarize intent and highlight structural PR risks for reviewers |
159
-
160
- [See full command reference →](core/methodology.md#command-workflows)
161
-
162
- > **Recommended next step after install:** run `/draft:init` to index your repo, then `/draft:review` on any branch with AI-generated changes. Once you've seen what it catches, explore the rest.
139
+ [Full command reference →](docs/COMMANDS.md) · run `/draft` for the interactive intent map
163
140
 
164
141
  ---
165
142
 
@@ -193,7 +170,7 @@ Skills also call into **shell helpers** under `scripts/tools/` for mechanical wo
193
170
 
194
171
  ## How It Works
195
172
 
196
- ```
173
+ ```text
197
174
  ┌─────────────────────────────────────────────────────────────┐
198
175
  │ /draft:init │
199
176
  │ 5-phase codebase analysis + signal detection + state │
@@ -249,7 +226,7 @@ Both modes produce the same `product.md`, `tech-stack.md`, `workflow.md`,
249
226
 
250
227
  AI tools are fast but unstructured. Draft applies Context-Driven Development to impose clear boundaries: explicit context, phased execution, and built-in verification, ensuring outputs remain aligned, predictable, and production-ready.
251
228
 
252
- ```
229
+ ```text
253
230
  product.md → "Build a task manager"
254
231
  tech-stack.md → "React, TypeScript, Tailwind"
255
232
  architecture.md → Comprehensive: 10-section graph-primary engineering reference, Mermaid diagrams (source of truth). Mature brownfield projects with strong existing agent docs (CLAUDE.md, INVARIANTS.md, etc.) receive early Context Quality Audit, graph fidelity dashboard, and explicit Relationship + Gaps sections (no blind duplication).
@@ -270,11 +247,13 @@ Each layer narrows the solution space. By the time AI writes code, decisions are
270
247
  ## Contributing
271
248
 
272
249
  ### Source of Truth
250
+
273
251
  1. `core/methodology.md` — Master methodology
274
252
  2. `skills/<name>/SKILL.md` — Command implementations
275
253
  3. `integrations/` — Auto-generated (don't edit)
276
254
 
277
255
  ### Update Workflow
256
+
278
257
  ```bash
279
258
  # 1. Edit core/methodology.md or skills/*/SKILL.md
280
259
  # 2. Rebuild integrations
package/bin/README.md CHANGED
@@ -13,7 +13,7 @@ CMM_VERSION=latest scripts/fetch-memory-engine.sh # or a specific tag / latest
13
13
 
14
14
  This installs the binary to the **Draft-managed location**:
15
15
 
16
- ```
16
+ ```text
17
17
  ~/.cache/draft/bin/codebase-memory-mcp
18
18
  ```
19
19
 
@@ -57,3 +57,49 @@ Structural graph data (architecture, hotspots, module deps, service routes) is q
57
57
  ## Offline / air-gapped distributions
58
58
 
59
59
  To ship the engine in-tree, place the binary at `bin/<os>-<arch>/codebase-memory-mcp` (resolution step 4). This is optional and not the default; the managed fetch is preferred.
60
+
61
+ ---
62
+
63
+ ## Trust story
64
+
65
+ Draft's differentiator depends on a binary published by a third party ([DeusData](https://github.com/DeusData)). That is a real supply-chain dependency and deserves a stated position rather than an implied one.
66
+
67
+ ### What is actually guaranteed
68
+
69
+ | Property | Status |
70
+ |---|---|
71
+ | Version pinned | Yes — `DEFAULT_VERSION` in `scripts/fetch-memory-engine.sh`. Bumps are deliberate commits, never floating. `CMM_VERSION` overrides per-install. |
72
+ | SHA-256 verified | Yes when the release publishes `checksums.txt` and lists the archive. A **mismatch is always fatal.** |
73
+ | Missing checksum | **Warns and installs by default.** Set `DRAFT_STRICT_VERIFY=1` to make an unverifiable download fatal instead. |
74
+ | Signature / attestation | **No.** There is no code signing or SLSA provenance today. Verification is checksum-only. |
75
+ | Source available | Yes — the engine is open source at [DeusData/codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp). |
76
+ | Reproducible build | Not verified by Draft. We check the archive matches the publisher's checksum, not that the checksum matches the source. |
77
+
78
+ Be explicit about the residual risk: a checksum proves the download matches what the publisher released. It does not prove the publisher released what the source says.
79
+
80
+ ### What the engine does at runtime
81
+
82
+ - Reads the repository you point it at and writes a SQLite graph under its own cache.
83
+ - Runs entirely locally. No API key, no telemetry endpoint, no outbound calls during indexing or querying.
84
+ - Network is used exactly once, by `fetch-memory-engine.sh`, to download the release archive.
85
+
86
+ Draft invokes it only through `codebase-memory-mcp cli <tool> '<json>'` (see `_lib.sh:memory_cli`). It is never given credentials and never writes into your source tree.
87
+
88
+ ### If you cannot run an unvetted binary
89
+
90
+ Three supported postures, in increasing strictness:
91
+
92
+ 1. **Strict verification** — `DRAFT_STRICT_VERIFY=1 scripts/fetch-memory-engine.sh`. Refuses to install anything it cannot checksum.
93
+ 2. **Vendor it yourself** — review the source, build the binary in your own pipeline, and place it at `bin/<os>-<arch>/codebase-memory-mcp` (resolution step 4) or point `DRAFT_MEMORY_BIN` at it. Draft never re-downloads when a binary already resolves.
94
+ 3. **Run without it** — `DRAFT_MEMORY_DISABLE=1`, or `draft install <host> --no-graph`. Every graph-backed skill degrades to a documented reduced-context mode; `/draft:review` still runs (see `skills/review/references/zero-setup-mode.md`). You lose blast radius, caller enumeration, hotspot ranking, and cycle detection — nothing silently returns wrong answers.
95
+
96
+ ### Contingency if the upstream project stalls
97
+
98
+ The dependency is bounded by design, which is what makes this survivable:
99
+
100
+ - **The interface is small.** Draft consumes a documented CLI (`cli <tool> '<json>'`), not a library. The entire coupling lives in `scripts/tools/_lib.sh` (`memory_cli`, `memory_ensure_index`, `memory_project_for_repo`) and `_graph_queries.sh`. Swapping engines means reimplementing those, not rewriting skills.
101
+ - **Skills never call the engine directly.** They call `graph-*.sh` wrappers, all of which already fail loud with `source: "unavailable"`. An engine that disappears degrades the product; it does not break it.
102
+ - **Pinning buys time.** A stalled upstream keeps working at the pinned version; only new language support would be lost.
103
+ - **The graph contract is replaceable.** The queries are ordinary Cypher-shaped structural lookups (callers, callees, fan-in, cycles, routes) over a tree-sitter/LSP index — reproducible on another indexer.
104
+
105
+ If upstream goes unmaintained, the migration path is: fork at the pinned tag for continuity, then reimplement `_lib.sh`'s three wrappers against a replacement indexer. No skill markdown changes.
@@ -83,7 +83,7 @@ function install(host, ctx) {
83
83
  // failure writes nothing.
84
84
  for (const act of plan.actions) {
85
85
  if (act.kind === 'exec') continue;
86
- if (!fsx.exists(act.src)) {
86
+ if (act.src && !fsx.exists(act.src)) {
87
87
  log.error(`Bundled asset missing: ${act.src}`);
88
88
  log.error('Reinstall @drafthq/draft — the package looks incomplete.');
89
89
  return 1;
@@ -24,11 +24,21 @@ function readJson(filePath, fallback) {
24
24
  }
25
25
  }
26
26
 
27
+ // The temp file is a fresh inode, so renaming it over the destination discards
28
+ // the destination's permissions. settings.json can carry env secrets and is often
29
+ // deliberately 0600 — a plain write would silently widen it to the umask default.
27
30
  function writeJsonAtomic(filePath, data) {
28
31
  const dir = path.dirname(filePath);
29
32
  fs.mkdirSync(dir, { recursive: true });
30
33
  const tmp = `${filePath}.tmp.${process.pid}`;
34
+ let mode;
35
+ try {
36
+ mode = fs.statSync(filePath).mode & 0o777;
37
+ } catch {
38
+ /* new file — let the umask decide, exactly as a plain write would */
39
+ }
31
40
  fs.writeFileSync(tmp, JSON.stringify(data, null, 2) + '\n', 'utf8');
41
+ if (mode !== undefined) fs.chmodSync(tmp, mode);
32
42
  fs.renameSync(tmp, filePath);
33
43
  }
34
44
 
@@ -25,6 +25,7 @@ You are an architecture agent for Draft-based development. You guide developers
25
25
  ### Module Definition Format
26
26
 
27
27
  For each module, define:
28
+
28
29
  - **Name** - Short, descriptive (e.g., `auth`, `scheduler`, `parser`)
29
30
  - **Responsibility** - One sentence describing what it owns
30
31
  - **Files** - Expected source files
@@ -39,7 +40,8 @@ Output format: Use the template at `core/templates/ai-context.md` for project-wi
39
40
  Represent API surfaces using the conventions of the project's primary language:
40
41
 
41
42
  **TypeScript:**
42
- ```
43
+
44
+ ```text
43
45
  - API Surface:
44
46
  - `createUser(data: CreateUserInput): Promise<User>`
45
47
  - `deleteUser(id: string): Promise<void>`
@@ -48,7 +50,8 @@ Represent API surfaces using the conventions of the project's primary language:
48
50
  ```
49
51
 
50
52
  **Python:**
51
- ```
53
+
54
+ ```text
52
55
  - API Surface:
53
56
  - `create_user(data: CreateUserInput) -> User`
54
57
  - `delete_user(user_id: str) -> None`
@@ -57,7 +60,8 @@ Represent API surfaces using the conventions of the project's primary language:
57
60
  ```
58
61
 
59
62
  **Go:**
60
- ```
63
+
64
+ ```text
61
65
  - API Surface:
62
66
  - `func CreateUser(data CreateUserInput) (*User, error)`
63
67
  - `func DeleteUser(id string) error`
@@ -66,7 +70,8 @@ Represent API surfaces using the conventions of the project's primary language:
66
70
  ```
67
71
 
68
72
  **Rust:**
69
- ```
73
+
74
+ ```text
70
75
  - API Surface:
71
76
  - `pub fn create_user(data: CreateUserInput) -> Result<User, Error>`
72
77
  - `pub fn delete_user(id: &str) -> Result<(), Error>`
@@ -79,6 +84,7 @@ Use the project's primary language from `draft/tech-stack.md`. Include function
79
84
  ### Ingredients
80
85
 
81
86
  Each module typically contains some combination of:
87
+
82
88
  - **API** - Public interface exposed to other modules
83
89
  - **Control Flow** - Core logic and decision paths
84
90
  - **Execution State** - Intermediate data structures used during processing
@@ -97,7 +103,7 @@ Each module typically contains some combination of:
97
103
 
98
104
  ### Dependency Diagram Format
99
105
 
100
- ```
106
+ ```json
101
107
  [auth] ──> [database]
102
108
  │ │
103
109
  └──> [config] <──┘
@@ -128,18 +134,21 @@ When modules form a circular dependency (A → B → A), apply this decision pro
128
134
  **Example:**
129
135
 
130
136
  Before (cycle):
131
- ```
137
+
138
+ ```json
132
139
  [user-service] ──> [notification-service]
133
140
  ↑ │
134
141
  └────────────────────┘
135
142
  ```
143
+
136
144
  `user-service` imports `sendNotification` from `notification-service`.
137
145
  `notification-service` imports `getUserPreferences` from `user-service`.
138
146
 
139
147
  Analysis: Both modules need user preference data. Extract it.
140
148
 
141
149
  After (resolved):
142
- ```
150
+
151
+ ```json
143
152
  [user-preferences] (new - extracted shared concern)
144
153
  ↑ ↑
145
154
  │ │
@@ -149,6 +158,7 @@ After (resolved):
149
158
  ```
150
159
 
151
160
  New module `user-preferences`:
161
+
152
162
  - **Responsibility:** Owns user notification/display preference data and access
153
163
  - **API Surface:** `getUserPreferences(userId): Preferences`
154
164
  - **Files:** `user-preferences.ts`, `user-preferences.test.ts`
@@ -178,6 +188,7 @@ Stories flow through three stages:
178
188
  1. **Placeholder** — During `/draft:decompose`, each module in `.ai-context.md` (or track-level `architecture.md`) gets a Story field set to `[placeholder - filled during /draft:implement]`. This signals that the module exists but its algorithm hasn't been documented yet.
179
189
 
180
190
  2. **Written** — During `/draft:implement` (with architecture mode), before coding each module's first file, write the Story as a code comment at the top of the file. Present it to the developer for approval. Once approved, update the module's Story field in `.ai-context.md` (or `architecture.md`) with a one-line summary referencing the file:
191
+
181
192
  ```markdown
182
193
  - **Story:** Documented in `src/auth.ts:1-12` — validates token, resolves user, checks permissions
183
194
  ```
@@ -188,7 +199,7 @@ Stories flow through three stages:
188
199
 
189
200
  ### Story Format
190
201
 
191
- ```
202
+ ```text
192
203
  // Story: [Module/File Name]
193
204
  //
194
205
  // Input: [what this module/function receives]
@@ -238,7 +249,7 @@ Define the intermediate state variables your code will use during processing. Th
238
249
 
239
250
  ### Execution State Format
240
251
 
241
- ```
252
+ ```text
242
253
  ## Execution State: [Module Name]
243
254
 
244
255
  ### Input State
@@ -332,6 +343,7 @@ function validateEntries(
332
343
  ### Escalation
333
344
 
334
345
  If module boundaries are unclear after analysis:
346
+
335
347
  1. Document what you know
336
348
  2. List the ambiguous boundaries
337
349
  3. Ask developer to clarify responsibility ownership
@@ -29,6 +29,7 @@ Before investigating, follow the context loading procedure in `core/shared/draft
29
29
  4. **Document findings** - Write down what you observe
30
30
 
31
31
  **Red Flags - STOP if you're:**
32
+
32
33
  - Tempted to make a "quick fix"
33
34
  - Guessing at the cause
34
35
  - Changing code "to see what happens"
@@ -47,6 +48,7 @@ Before investigating, follow the context loading procedure in `core/shared/draft
47
48
  4. **Narrow the scope** - What's the smallest change that breaks it?
48
49
 
49
50
  **Questions to answer:**
51
+
50
52
  - Is this a data problem or code problem?
51
53
  - Is this a timing/race condition?
52
54
  - Is this an environment difference?
@@ -81,6 +83,7 @@ Select techniques appropriate to the language and failure type. Not all techniqu
81
83
  4. **Run the test** - Execute and compare to prediction
82
84
 
83
85
  **If hypothesis is wrong:**
86
+
84
87
  - Return to Phase 2
85
88
  - Do NOT try another random fix
86
89
  - Update your understanding
@@ -146,6 +149,7 @@ Do NOT guess at performance bottlenecks. Profile first.
146
149
  5. **Re-profile** — confirm the hot path is resolved and no new bottleneck appeared
147
150
 
148
151
  **Anti-patterns for performance debugging:**
152
+
149
153
  - Optimizing without profiling data
150
154
  - Optimizing code that isn't on the hot path
151
155
  - Micro-optimizing when the bottleneck is I/O
@@ -167,6 +171,7 @@ Do NOT guess at performance bottlenecks. Profile first.
167
171
  ## When to Escalate
168
172
 
169
173
  If after 3 hypothesis cycles you haven't found root cause:
174
+
170
175
  1. Document all findings
171
176
  2. List what you've eliminated
172
177
  3. Ask for external input
@@ -37,6 +37,7 @@ You are an operations agent. When assessing production readiness, managing incid
37
37
  ## Operational Checklists
38
38
 
39
39
  ### Pre-Deploy Assessment
40
+
40
41
  1. Rollback plan documented and tested?
41
42
  2. Database migrations reversible?
42
43
  3. Feature flags in place for new features?
@@ -46,6 +47,7 @@ You are an operations agent. When assessing production readiness, managing incid
46
47
  7. On-call engineer aware and available?
47
48
 
48
49
  ### Incident Response Framework
50
+
49
51
  1. **Detect** — Alert fires or user report received
50
52
  2. **Triage** — Assess severity, assign incident commander
51
53
  3. **Communicate** — Notify stakeholders, open war room (if SEV1/2)
@@ -57,6 +59,7 @@ You are an operations agent. When assessing production readiness, managing incid
57
59
  ### Rollback Decision Framework
58
60
 
59
61
  Initiate rollback if ANY of these are true:
62
+
60
63
  - Error rate exceeds 2x baseline
61
64
  - p95 latency exceeds 3x baseline
62
65
  - Data corruption detected
@@ -67,7 +70,8 @@ Initiate rollback if ANY of these are true:
67
70
  ## Communication Templates
68
71
 
69
72
  ### Stakeholder Update (During Incident)
70
- ```
73
+
74
+ ```json
71
75
  [SEV{N}] {Service Name} — {1-line summary}
72
76
  Status: {Investigating | Mitigating | Monitoring | Resolved}
73
77
  Impact: {user-facing impact description}
@@ -76,7 +80,8 @@ Next update: {time of next update}
76
80
  ```
77
81
 
78
82
  ### Post-Incident Summary
79
- ```
83
+
84
+ ```yaml
80
85
  Incident: {title}
81
86
  Duration: {start} → {end} ({total time})
82
87
  Impact: {users affected, SLO impact}
@@ -50,12 +50,14 @@ Organize plans into phases:
50
50
  ## Task Granularity
51
51
 
52
52
  Good task:
53
+
53
54
  - Completable in a focused session
54
55
  - Has clear success criteria
55
56
  - Produces testable output
56
57
  - Fits in single commit
57
58
 
58
59
  Bad task:
60
+
59
61
  - "Implement the feature"
60
62
  - Multi-day scope
61
63
  - Vague completion criteria
@@ -63,11 +65,13 @@ Bad task:
63
65
  ## Dependency Mapping
64
66
 
65
67
  Identify:
68
+
66
69
  - Which tasks must complete before others
67
70
  - Parallel execution opportunities
68
71
  - External blockers
69
72
 
70
73
  Format in plan.md:
74
+
71
75
  ```markdown
72
76
  - [ ] Task 2.1: Add validation
73
77
  - Depends on: Task 1.1, Task 1.2
@@ -76,6 +80,7 @@ Format in plan.md:
76
80
  ## Risk Identification
77
81
 
78
82
  Flag in spec.md:
83
+
79
84
  - Technical unknowns
80
85
  - External dependencies
81
86
  - Performance concerns
@@ -128,6 +133,7 @@ Each criterion must be:
128
133
  | **Complete** | Covers both success and failure paths | Include error scenarios |
129
134
 
130
135
  **Anti-patterns:**
136
+
131
137
  - "System works correctly" (too vague)
132
138
  - "Code is clean" (subjective)
133
139
  - "Performance is good" (not measurable — use "Response time < 200ms at p95")
@@ -152,6 +158,7 @@ When recommending technical approaches, cite sources from `core/knowledge-base.m
152
158
  ## Escalation
153
159
 
154
160
  If requirements are ambiguous after analysis:
161
+
155
162
  1. Document what is clear
156
163
  2. List specific ambiguities with options
157
164
  3. Present to developer with trade-off analysis
@@ -69,6 +69,7 @@ Before investigating, load and reference the project's big picture documents:
69
69
  **Output:** Reproduction confirmed with evidence. Blast radius and SLO impact documented. Investigation scoped to specific module(s).
70
70
 
71
71
  **Anti-patterns:**
72
+
72
73
  - Starting to read code before reproducing
73
74
  - Assuming the bug reporter's diagnosis is correct
74
75
  - Investigating the entire system instead of scoping first
@@ -82,18 +83,23 @@ Before investigating, load and reference the project's big picture documents:
82
83
  **Techniques (use the most appropriate):**
83
84
 
84
85
  #### Control Flow Tracing
86
+
85
87
  Follow the execution path from entry point to failure:
86
- ```
88
+
89
+ ```text
87
90
  request arrives → handler (file:line)
88
91
  → validation (file:line) ✓ passes
89
92
  → service call (file:line) ✓ returns data
90
93
  → transformation (file:line) ✗ FAILS HERE
91
94
  ```
95
+
92
96
  Document each hop with `file:line` references.
93
97
 
94
98
  #### Data Flow Tracing
99
+
95
100
  Track data transformation through the system:
96
- ```
101
+
102
+ ```yaml
97
103
  input: { userId: "abc", role: "admin" }
98
104
  → after auth middleware (file:line): { userId: "abc", role: "admin", verified: true }
99
105
  → after service layer (file:line): { userId: "abc", role: null } ← DATA LOST HERE
@@ -101,6 +107,7 @@ input: { userId: "abc", role: "admin" }
101
107
  ```
102
108
 
103
109
  #### Differential Analysis (Google SRE Practice)
110
+
104
111
  Compare what works vs. what doesn't:
105
112
 
106
113
  | Aspect | Working Case | Failing Case | Difference |
@@ -112,8 +119,10 @@ Compare what works vs. what doesn't:
112
119
  This narrows the investigation to the specific difference that causes the failure.
113
120
 
114
121
  #### 5 Whys (Toyota/Google Practice)
122
+
115
123
  Once you find the immediate cause, ask "why" to find the root:
116
- ```
124
+
125
+ ```text
117
126
  1. Why did the request fail? → NullPointerException at file:line
118
127
  2. Why was the value null? → The cache returned stale data
119
128
  3. Why was the cache stale? → The invalidation event was dropped
@@ -125,6 +134,7 @@ Once you find the immediate cause, ask "why" to find the root:
125
134
  **Output:** Data/control flow trace with exact code references. Divergence point identified.
126
135
 
127
136
  **Anti-patterns:**
137
+
128
138
  - Reading code randomly instead of tracing the specific flow
129
139
  - Assuming you know the code path without verifying
130
140
  - Skipping the "what works" comparison
@@ -149,6 +159,7 @@ Once you find the immediate cause, ask "why" to find the root:
149
159
  | 1 | Cache returns stale data when TTL=0 | Unit test with TTL=0 | Should return stale | Returns stale | **Confirmed** |
150
160
 
151
161
  **If hypothesis fails:**
162
+
152
163
  - Do NOT try a random different fix
153
164
  - Record the failed hypothesis (it narrows the search space)
154
165
  - Return to Phase 2 with updated understanding
@@ -84,6 +84,7 @@ Check against the track's `spec.md`:
84
84
  - [ ] Integration points work as specified
85
85
 
86
86
  **Verdict options:**
87
+
87
88
  - **PASS** — All requirements met, all acceptance criteria verified
88
89
  - **PASS WITH NOTES** — All requirements met but minor gaps exist in acceptance criteria verification
89
90
  - **FAIL** — Missing requirements or acceptance criteria not met
@@ -37,6 +37,7 @@ You are a technical writer agent. When generating documentation, follow structur
37
37
  ### Step 1: Audience Analysis
38
38
 
39
39
  Before writing, answer:
40
+
40
41
  - Who will read this? (role, experience level)
41
42
  - When will they read it? (onboarding, debugging, integrating)
42
43
  - What question are they trying to answer?
@@ -45,6 +46,7 @@ Before writing, answer:
45
46
  ### Step 2: Information Architecture
46
47
 
47
48
  Organize content using this hierarchy:
49
+
48
50
  1. **Title** — What is this document about?
49
51
  2. **TL;DR** — 1-3 sentence summary for scanners
50
52
  3. **Quick Start** — Minimum steps to get started (if applicable)
@@ -71,22 +73,26 @@ Organize content using this hierarchy:
71
73
  ## Documentation Modes
72
74
 
73
75
  ### README Mode
76
+
74
77
  - Audience: New team members, external visitors
75
78
  - Structure: What → Why → Quick Start → Architecture Overview → Development → Deployment → Contributing
76
79
  - Sources: product.md, tech-stack.md, .ai-context.md, workflow.md
77
80
 
78
81
  ### Runbook Mode
82
+
79
83
  - Audience: Operators, on-call engineers
80
84
  - Structure: Service Overview → Health Checks → Common Issues → Escalation → Recovery Procedures
81
85
  - Sources: .ai-context.md (service map), tech-stack.md (infrastructure), incident history
82
86
  - Reference: `core/agents/ops.md` for operational mindset
83
87
 
84
88
  ### API Mode
89
+
85
90
  - Audience: Integrators, frontend developers
86
91
  - Structure: Authentication → Endpoints (grouped by resource) → Request/Response Examples → Error Codes → Rate Limits
87
92
  - Sources: Code analysis, tech-stack.md (API patterns), existing API tests
88
93
 
89
94
  ### Onboarding Mode
95
+
90
96
  - Audience: New team members (day 1-5)
91
97
  - Structure: Prerequisites → Environment Setup → First Task Walkthrough → Key Concepts → Who to Ask
92
98
  - Sources: All draft context files, workflow.md, guardrails.md