You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ Execution instructions...
84
84
```
85
85
86
86
2. The body **must** start with `# Title` followed by a blank line (build script skips first 3 body lines via `tail -n +4`)
87
-
3. Add the skill name to `SKILL_ORDER` array and add header/trigger case entries in `scripts/build-integrations.sh`
87
+
3. Add the skill name to the `SKILL_ORDER` array in `scripts/lib.sh`, then add a case entry in `get_skill_header()` AND `get_copilot_trigger()` in `scripts/build-integrations.sh`
88
88
4. Run `make build && make test`
89
89
5. Add the command to `README.md`
90
90
6. Add a test if the skill has validatable behavior
Copy file name to clipboardExpand all lines: book/notebook-sources/00_what_is_draft.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ You installed an AI coding assistant. It writes code fast. But it also picks the
8
8
9
9
## What Draft Is
10
10
11
-
Draft is a free, open-source plugin that adds structured development methodology to AI coding agents. It provides 28 slash commands and 7 specialized agents that turn your AI assistant from an autonomous guessing machine into a disciplined executor of pre-approved work.
11
+
Draft is a free, open-source plugin that adds structured development methodology to AI coding agents. It provides 33 slash commands and 7 specialized agents that turn your AI assistant from an autonomous guessing machine into a disciplined executor of pre-approved work.
12
12
13
13
The core idea: before AI writes a single line of code, it analyzes your codebase, generates a specification, builds a phased plan, and waits for your approval. Only then does implementation begin — constrained by your architecture, your conventions, and your acceptance criteria.
14
14
@@ -26,7 +26,7 @@ Draft is for developers and teams who use AI coding assistants and have experien
26
26
27
27
## What You Get
28
28
29
-
4 primary workflow commands (`/draft:init`, `/draft:new-track`, `/draft:implement`, `/draft:review`) plus 5 routers (`/draft:plan`, `/draft:ops`, `/draft:docs`, `/draft:discover`, `/draft:jira`) as the recommended public interface. 22 specialist commands are dispatched by the routers for targeted work (debug, bughunt, deep-review, tech-debt, ADR, etc.).
29
+
4 primary workflow commands (`/draft:init`, `/draft:new-track`, `/draft:implement`, `/draft:review`) plus 5 routers (`/draft:plan`, `/draft:ops`, `/draft:docs`, `/draft:discover`, `/draft:jira`) as the recommended public interface. 24 specialist commands are dispatched by the routers for targeted work (debug, bughunt, deep-review, tech-debt, ADR, etc.).
30
30
31
31
The router model reduces cognitive load: state your intent to a router and it dispatches to the right specialist with context.
32
32
@@ -36,7 +36,7 @@ The router model reduces cognitive load: state your intent to a router and it di
36
36
37
37
Draft works with the AI coding tools you already use:
38
38
39
-
* Claude Code— Native plugin installation via/plugin install
39
+
* Claude Code— Native plugin installation via`npx @drafthq/draft install claude-code`
40
40
* Cursor— Native support for the.claude/plugin structure
Copy file name to clipboardExpand all lines: book/notebook-sources/02_context_driven_development.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ What it locks in:technology choices, dependency constraints, accepted patterns.
32
32
33
33
### architecture.md — How (Structure)
34
34
35
-
The source of truth. A comprehensive 25-section engineering reference generated from exhaustive codebase analysis. It includes module boundaries, dependency graphs, data flows, API definitions, concurrency models, security architecture, and testing infrastructure — all with real Mermaid diagrams and actual code snippets from your codebase.
35
+
The source of truth. A comprehensive 10-section engineering reference generated from exhaustive codebase analysis. It includes module boundaries, dependency graphs, data flows, API definitions, concurrency models, security architecture, and testing infrastructure — all with real Mermaid diagrams and actual code snippets from your codebase.
36
36
37
37
What it locks in:module boundaries, interaction contracts, data flow patterns, invariants. The AI cannot violate your architecture because the architecture is explicitly documented with every component, every interface, and every constraint.
38
38
@@ -68,7 +68,7 @@ This is where the AI gets enough context to make correct decisions without the f
68
68
69
69
### Tier 2: Long-Term Storage
70
70
71
-
architecture.mdis the full, comprehensive reference — 25 sections plus appendices, with Mermaid diagrams and code snippets. It is loaded for deep reviews, architecture refreshes, and complex analysis tasks. Most day-to-day development never touches this tier directly.
71
+
architecture.mdis the full, comprehensive reference — 10 sections with Mermaid diagrams and code snippets. It is loaded for deep reviews, architecture refreshes, and complex analysis tasks. Most day-to-day development never touches this tier directly.
72
72
73
73
Smaller context windows produce better AI decisions. By loading only what's needed, Draft reduces token consumption, decreases hallucination risk, and keeps the AI focused on the relevant subset of your architecture. The right context for the task — not all the context, all the time.
Copy file name to clipboardExpand all lines: book/notebook-sources/03_getting_started.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Draft installs with a single command. No API keys, no accounts, no hosted servic
12
12
13
13
### Claude Code (Recommended)
14
14
15
-
That's it. You now have all 28 commands available as/draft:*slash commands.
15
+
That's it. You now have all 33 commands available as/draft:*slash commands.
16
16
17
17
### Cursor
18
18
@@ -85,7 +85,7 @@ After the five-phase analysis, Draft creates thedraft/directory with these files
85
85
86
86
### architecture.md (Source of Truth)
87
87
88
-
A comprehensive 25-section engineering reference with appendices. This is the primary artifact — designed for both human engineers and AI agents. It includes:
88
+
A comprehensive 10-section engineering reference. This is the primary artifact — designed for both human engineers and AI agents. It includes:
Copy file name to clipboardExpand all lines: book/notebook-sources/10_context_tiering.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ This file isderivedfromarchitecture.md, not written directly. Draft's condensati
34
34
35
35
## Tier 2: The Full Architecture
36
36
37
-
The filedraft/architecture.mdis the source of truth. It is a comprehensive, human-readable engineering reference with 25 sections and 4 appendices, complete with Mermaid diagrams, code snippets, interaction matrices, and state machine definitions. It exists for two audiences: AI agents performing deep analysis, and engineers who need to understand a module without reading source code.
37
+
The filedraft/architecture.mdis the source of truth. It is a comprehensive, human-readable 10-section engineering reference, complete with Mermaid diagrams, code snippets, interaction matrices, and state machine definitions. It exists for two audiences: AI agents performing deep analysis, and engineers who need to understand a module without reading source code.
38
38
39
39
Tier 2 is loaded only for deep analysis:/draft:initrefresh,/draft:deep-review,/draft:decompose, and full architecture refreshes. Most day-to-day development never touches it. When it is loaded, it provides exhaustive context that Tier 1 intentionally omits: per-module state machines, thread safety annotations, the full implementation catalog, concurrency model details, and configuration reference tables.
40
40
@@ -76,7 +76,7 @@ Evening: you run/draft:deep-reviewon the auth module after a security concern. D
76
76
77
77
## Why Not Just Load Everything?
78
78
79
-
Token budgets are finite. A 400-line.ai-context.mdplus a 2000-linearchitecture.mdplus 150 facts consumes significant context window space — space that competes with the actual code being analyzed, the spec being checked, and the plan being followed. Tiering is not an optimization. It is a necessity. Without it, large projects would hit context limits before the AI could even begin working.
79
+
Token budgets are finite. A 400-line.ai-context.mdplus a comprehensive 10-sectionarchitecture.mdplus 150 facts consumes significant context window space — space that competes with the actual code being analyzed, the spec being checked, and the plan being followed. Tiering is not an optimization. It is a necessity. Without it, large projects would hit context limits before the AI could even begin working.
80
80
81
81
The three-tier system also reflects a truth about information relevance: most of your project's architectural knowledge is irrelevant to any single task. Loading it anyway does not make the AI smarter. It makes it noisier. Focused context produces focused output.
Copy file name to clipboardExpand all lines: book/notebook-sources/18_monorepo_federation.md
+31-41Lines changed: 31 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,69 +4,59 @@ Part VI: Enterprise· Chapter 18
4
4
5
5
4 min read
6
6
7
-
A monorepo with twelve services has twelvedraft/directories after initialization. Each service has its own architecture documentation, its own tech stack, its own context files. But nobody has a unified view of the whole system — which services depend on which, what technologies are used where, or how the pieces fit together./draft:indexbuilds that view.
7
+
Draft has no separate index command. Monorepo support is built directly into `/draft:init`, which is scope-aware and root-first. Run it at the repo root to build the whole-repo knowledge graph; run it inside a sub-module and it resolves the repo root automatically, builds that module's snapshot, and writes `draft/graph/root-link.json` pointing up to the root graph — so every module has full cross-module understanding without an extra step. Federation is the root-link mechanism, not a separate command.
8
8
9
9
## The Monorepo Context Problem
10
10
11
-
Running/draft:initon each service in a monorepo produces excellent per-service context. The auth service has a detailed.ai-context.mdexplaining its JWT validation flow. The billing service documents its Stripe integration. But cross-service questions remain unanswered: what happens when auth goes down? Which services share PostgreSQL? Is anyone still using the deprecated notification API?
11
+
A monorepo with twelve services raises a cross-module question that per-service context cannot answer: what happens when the auth service changes? Which services share PostgreSQL? Which team owns the notification API? Per-service `/draft:init` runs produce excellent local context — detailed `.ai-context.md` files for each service — but answering cross-service questions requires connecting those views.
12
12
13
-
/draft:indexanswers these questions by aggregating service-level context into root-level knowledge files, without deep code analysis. It reads what/draft:initalready produced and synthesizes a system-of-systems view.
13
+
Draft solves this through the root-link mechanism built into `/draft:init`. There is no separate aggregation step. Running `/draft:init` anywhere in the monorepo is enough.
14
14
15
-
## Auto-Detection
15
+
## How Scope-Aware Init Works
16
16
17
-
Draft detects services by scanning immediate child directories (depth=1 only, never recursive) for standard project markers:
17
+
`/draft:init` is root-first. When invoked at the repo root, it builds the whole-repo knowledge graph in `draft/graph/`. When invoked inside a sub-module (for example, `services/billing/`), it:
It excludesnode_modules/,vendor/,.git/, and hidden directories. Each detected directory is categorized as initialized (has adraft/subdirectory) or uninitialized. Only initialized services contribute to the index.
19
+
1.**Resolves the repo root** — walks ancestor directories looking for an existing `draft/` directory, then falls back to `git rev-parse --show-toplevel`, then falls back to cwd.
20
+
2.**Builds the module snapshot** — runs full analysis for the sub-module and writes its graph under the module's own `draft/graph/`.
21
+
3.**Writes `draft/graph/root-link.json`** — a pointer from the module's graph to the root graph. This file tells any Draft command running inside the module where the whole-repo graph lives.
27
22
28
-
## What Gets Generated
23
+
The result: a Draft command running inside `services/billing/` can answer cross-module questions by following the root link to the root graph, without re-running any analysis at the root level.
29
24
30
-
/draft:indexproduces six root-level files that together form a complete system map:
25
+
## The root-link.json File
31
26
32
-
### service-index.md
27
+
`draft/graph/root-link.json` is a small JSON file written by `/draft:init` when it detects it is running inside a sub-module. It contains the absolute path to the root `draft/graph/` directory and metadata about when the link was established. Commands that need cross-module context read this file and query the root graph directly.
33
28
34
-
A directory of all detected services with their status, tech stack, dependencies, team ownership, and links to their individual context files. This is the entry point — the table of contents for the entire monorepo.
29
+
If no root graph exists yet, the root link points to a pending state and falls back gracefully to module-local context. Running `/draft:init` at the repo root later fills the gap — no re-initialization of sub-modules required.
35
30
36
-
### dependency-graph.md
31
+
##The Committed Graph: Only schema.yaml
37
32
38
-
Cross-service dependency mapping with a Mermaid topology diagram, a dependency matrix (depends-on and depended-by for every service), and a topological implementation order. This file answers "what breaks if this service changes?" and "what must exist before this service can function?"
33
+
The knowledge graph itself is engine-only. The `codebase-memory-mcp` engine (by DeusData, 159 languages, 100% local) maintains the structural graph in-process. No `architecture.json`, `hotspots.jsonl`, or `*.mermaid` files are committed to the repository.
39
34
40
-
### tech-matrix.md
35
+
The only committed file in `draft/graph/` is `schema.yaml` — a gate marker containing engine metadata, project identity, and point-of-index counts. Its `access: engine-live` field signals that structural data is queried live from the engine, not read from committed files.
41
36
42
-
A technology distribution report showing which languages, databases, frameworks, and infrastructure components are used across which services. It identifies organizational standards (technologies used by the majority of services) and variances (services that deviate, with documented justifications).
37
+
## Flags
43
38
44
-
### Synthesized Root Context
39
+
`/draft:init` supports two flags relevant to monorepo workflows:
45
40
46
-
If the root-leveldraft/product.md,draft/architecture.md, anddraft/tech-stack.mdare missing or are placeholders,/draft:indexsynthesizes them from service-level data:
41
+
*`--module-only` — Analyzes only the current sub-module; skips root-level synthesis. Use when you want to refresh a single service without touching the root graph.
42
+
*`--graph-only` — Builds or refreshes the graph without regenerating prose context files (architecture.md, .ai-context.md, etc.). Use for fast graph updates after code changes.
47
43
48
-
* product.md— Aggregated product vision from all service visions, deduplicated target users, capability matrix mapping features to services
49
-
* architecture.md— System-of-systems view with topology diagram, service directory, shared infrastructure, and cross-cutting patterns
After generatingarchitecture.md, the Condensation Subroutine runs to produce a root-level.ai-context.md— a token-optimized aggregate of all service knowledge.
44
+
## The Workflow
52
45
53
-
## Root-Level vs. Service-Level Context
46
+
A typical monorepo onboarding sequence:
54
47
55
-
After indexing, the monorepo has two layers of context:
48
+
1. Run `/draft:init` at the repo root — builds the whole-repo graph and generates root-level context files.
49
+
2. Run `/draft:init` inside each sub-module that needs its own spec/plan context — each one generates module-local context and writes a `draft/graph/root-link.json` pointing to the root.
50
+
3. Work inside any sub-module — Draft automatically loads module-local context for implementation tasks and follows the root link for cross-module analysis (impact, deep-review, bughunt across services).
56
51
57
-
When working within a single service, the AI loads that service's context. When making cross-service decisions — adding a new API dependency, changing a shared schema, planning a migration — the AI loads root-level context.
52
+
Re-run `/draft:init` (or `/draft:init --graph-only`) after significant architecture changes to any service, before major cross-service planning, or as part of documentation hygiene. The graph engine handles incremental updates; unchanged modules are not re-analyzed.
58
53
59
-
## Service Manifests
54
+
## Cross-Module Analysis
60
55
61
-
For each initialized service,/draft:indexcreates or updates amanifest.jsoninside the service'sdraft/directory. This manifest contains the service name, type, summary, primary technology, dependencies on other services, dependents (reverse lookup), team ownership, and indexing timestamps. Manifests enable fast re-indexing without re-reading all markdown files.
56
+
Once root links are in place, any graph-aware Draft command can scope across modules:
62
57
63
-
## Initializing Missing Services
64
-
65
-
Running/draft:index --init-missingoffers to initialize uninitialized services. For each one, Draft prompts with four options:y(initialize this service),n(skip),all(initialize all remaining), orskip-rest(skip all remaining). This makes it practical to bring an entire monorepo under Draft management incrementally.
66
-
67
-
## Bughunt Mode
68
-
69
-
/draft:indexalso supports a bughunt aggregation mode. Running/draft:index bughuntexecutes/draft:bughuntsequentially across all initialized services (or a specified subset), then generatesdraft/bughunt-summary.md— an aggregate report showing bug counts by severity across all services, directories requiring immediate attention, and links to individual service reports.
70
-
71
-
Re-run/draft:indexafter initializing a new service, after significant architecture changes to any service, before major cross-service planning, or as part of weekly documentation hygiene. The command preserves manual edits in sections marked with<!-- MANUAL START -->and<!-- MANUAL END -->comments.
58
+
*`/draft:impact` — follows the root link to find downstream dependencies across service boundaries.
59
+
*`/draft:deep-review` — loads cross-module invariants from the root graph when reviewing a service that calls others.
60
+
*`/draft:bughunt` — can be scoped to a single service or run against the root graph for a system-wide sweep.
72
61
62
+
The federation is transparent: commands do not need to know whether they are running in a mono-module repo or a large monorepo. The root-link mechanism handles the routing.
0 commit comments