Context-Driven Development REV 5.0.2 · MIT

Draft it before your agent builds it.

Draft maps your repo into a local knowledge graph and turns your ideas into reviewable specs — so your AI agent ships from a plan, not a guess. Spec-first planning, a three-stage review, and a 14-dimension bug hunt, in one plugin. Free forever.

npx @drafthq/draft install claude-code
Commands 4/33
Languages 159
Graph modes 6
Platforms 6
License MIT
$ graph-impact --file src/auth/login.ts live graph
target src/auth/login.ts
depth 1 4
  • api/session/route.ts
  • api/auth/[...nextauth]/route.ts
  • pages/login.tsx
  • tests/auth/login.spec.ts
depth 2 1
  • tests/api/session.spec.ts
depth 3 0
    5 files 3 modules code 3 · test 2
    Works in
    • Claude Code
    • Cursor
    • Codex
    • opencode
    • GitHub Copilot
    • Gemini

    AI ships fast. Without a plan, it ships chaos.

    Hand an agent a vague prompt and it guesses. It invents requirements, picks approaches that don't match your stack, and calls it done without proof. Here is what that looks like — flagged like defects on a drawing.

    Guesses requirements

    Assumes what you meant instead of asking the questions a teammate would.

    Picks at random

    Reaches for whatever it saw most, not what fits your architecture and conventions.

    Breaks the patterns

    Writes code that ignores the structures your codebase already relies on.

    Claims it's done

    Skips verification and reports success with no test, no diff, no evidence.

    Without Draft

    • Context in ephemeral chat
    • No version history for decisions
    • Loads the entire project every session
    • Unsearchable conversations
    • Invisible to teammates

    With Draft

    • File-based persistent memory
    • Git-tracked specs with diffs and blame
    • Scoped context per track
    • Grep-able specs and plans
    • PR-reviewable planning artifacts

    Your repo, queryable.

    Draft installs a local knowledge-graph engine that maps every module, call, dependency, and hotspot in your codebase. No daemon. No external service. No code leaves your machine. Try the queries below — illustrative results from a typical codebase, in the engine's real output schema.

    $ graph-impact --file src/lib/auth/jwt.ts
    
                    

    Tree-sitter + LSP across 159 languages · 100% local, no API key · Incremental, git-aware indexing

    How the engine works →

    Four you run. Twenty-nine that route themselves.

    The whole workflow comes down to four commands. Everything else — bug hunts, coverage, debugging, ADRs, deploy checklists, Jira — is a specialist the routers reach for on their own. Each one is still there to call by name the moment you want it.

    draft — zsh
    $ |
    01 /draft:review

    Three stages on your branch. Runs with zero setup — start here, before indexing anything.

    02 /draft:init

    Map the codebase once. Adds blast radius, caller lookup, and cycle detection to every later review.

    03 /draft:new-track

    Turn an idea into a reviewable spec and a phased plan before any code.

    04 /draft:implement

    Build the plan task by task, test-first, with verification gates between steps.

    You don't pick the specialist. Draft routes intent to it — and you can still call it by name.

    draft "fix the flaky login test"
    intent router reads what you mean
    /draft:debug /draft:testing-strategy /draft:bughunt /draft:coverage
    29 specialists routed for you — or call any of them by name

    Enterprise-grade methodology, zero cost.

    Every capability below reads the same context files and the same graph, so the answers agree with each other. Nothing here needs an account, a key, or a network call.

    5-phase analysis

    Architecture discovery

    Graph-primary deep analysis producing a focused, high-signal engineering reference (Graph Health Dashboard + 9 other critical sections with provenance and fidelity tags). Derives the 200-400 line .ai-context.md. Strong emphasis on honest coverage gaps and relationship to any pre-existing high-quality agent documentation.

    Graph-primaryFidelity + provenanceIncremental refresh

    TDD enforcement

    RED → GREEN → REFACTOR cycle. Production robustness patterns enforced: atomicity, isolation, durability, idempotency, fail-closed, resilience. Property-based testing, observability prompts, contract testing at service boundaries.

    95%+ target7 robustness patterns

    Three-stage code review

    Automated validation + spec compliance + code quality. STRIDE threat modeling for new endpoints. Context-specific checks (crypto, DB, API, config, UI). SAST tool integration. Adversarial pass on zero findings.

    3 stagesSTRIDESAST

    Collaborative intake

    AI as expert partner — asks one question at a time, contributes patterns, risks, trade-offs. Builds the spec progressively with citations from DDD, Clean Architecture, OWASP.

    AI as partner
    Exhaustive sweep

    14-dimension bug hunt

    Systematic defect discovery across 14 dimensions: correctness, reliability, security, performance, UI responsiveness, concurrency, state management, API contracts, accessibility, configuration, tests, dependency/supply chain security, algorithmic complexity, and i18n/l10n. Severity-ranked with file:line locations. Only HIGH/CONFIRMED confidence — false-positive elimination and taint tracking built in.

    14 dimensionsTaint trackingConfidence filteringRegression tests

    ACID deep review

    Module lifecycle audit evaluating atomicity, isolation, durability, fail-closed behavior, and idempotency. Enterprise-grade production pattern enforcement.

    ACID compliant

    Pattern learning

    Scans your codebase for recurring patterns (3+ occurrences). Discovers conventions to skip and anti-patterns to always flag. Every quality command updates guardrails.md after each run — your codebase teaches Draft what to enforce, and false positives disappear over time.

    Auto-learningTemporal analysisguardrails.md
    Built in

    Knowledge graph engine

    Tree-sitter + LSP-grade resolution across 159 languages, 100% local. Query tools — callers, callees, impact, cycles, hotspots, mermaid. Incremental, git-aware indexing. Impact queries break results down by code/test/doc/config. Powers /draft:impact, enriches /draft:bughunt and /draft:review.

    Built on codebase-memory-mcp — 159 languages, 100% local, no API key

    159 languagesQuery toolsIncremental100% local
    Track memory

    Track impact memory

    Each completed track records its blast radius in metadata.json — files touched, modules affected, downstream count, by-category breakdown. /draft:plan reads recent tracks' impact during context load and surfaces overlap warnings before you even write a spec.

    Auto-recordedOverlap detection
    53 helpers

    Deterministic helpers

    Skills delegate mechanical work to 53 shell tools under scripts/tools/ — git metadata, file classification, hotspot ranking, cycle detection, freshness checks, ADR indexing, test-framework detection, and more. Uniform JSON output and exit-code contract. Graph wrappers fail loud on shapeless engine JSON rather than reporting a clean empty result.

    JSON contractReproducible
    Enterprise

    Enterprise ready

    Monorepo federation with service discovery and dependency graphs. Unified Jira router — preview, create (Track → Epic, Phase → Story, Task → Sub-task), and review <JIRA-ID> that qualifies a ticket with deep-review + bug hunt + coverage + test-gap analysis. Architecture Decision Records with full lifecycle. Git-aware task/phase/track-level revert. Mid-track change management with impact analysis.

    MonorepoJira preview / create / reviewADRsRevertChange mgmt

    /draft:init — your codebase, fully mapped.

    One command performs a 5-phase deep analysis of your entire codebase — not a diagram of intent, a map of reality. Every future interaction is grounded in this understanding, and you pay the cost once.

    0

    Graph build

    Builds a tree-sitter knowledge graph mapping module boundaries, dependencies, call paths, and hotspots. This powers precise impact analysis and accelerates every later phase.

    1

    Discovery

    Directory structure, build files, API definitions, interface and type files. Signal classification sorts every source file into 11 categories (routes, services, auth, models, state, jobs, persistence, tests, config…) to drive adaptive analysis depth.

    2

    Wiring

    Entry points, orchestrator initialization, registry and registration code, dependency injection, module system, import graph. Maps how components find and connect to each other.

    3

    Depth

    End-to-end data flows, core module implementations, concurrency model, safety checks. Traces invariants, validation, auth gates. Identifies state machines and consistency boundaries.

    4

    Periphery

    External dependencies, test infrastructure, configuration mechanisms, existing documentation. Maps the full operational envelope of your system.

    5

    Synthesis

    Graph-first synthesis with explicit fidelity declarations and provenance. Tier-gated output (DRAFT_INIT_MODE): small repos get the graph-primary architecture.md; larger repos get an OKF concept taxonomy under draft/wiki/ with architecture.md as a generated view. Either way, .ai-context.md (200-400 lines, token-optimized) is the AI index root.

    .ai-context.md

    Machine-optimized · 200-400 lines

    Dense tables, YAML frontmatter, flat sections. Token-efficient — minimal prose, maximum signal. Consumed by all Draft commands and external AI tools.

    architecture.md

    Graph-primary · explicit fidelity

    Prose, annotated Mermaid diagrams, onboarding framing. The source of truth — all mutations happen here. For engineers, leads, and PR reviewers.

    • System map with file:line refs
    • Data lifecycle & state machines
    • Critical paths & recovery matrix
    • Invariants & constraints
    • Extension cookbooks
    • Graph health dashboard

    guardrails.md

    Auto-learning · rules + patterns

    Human-defined constraints plus auto-discovered conventions and anti-patterns. Quality commands read this file, skip known patterns, flag violations — then update it after every run. Your codebase teaches Draft what to enforce.

    State persistence — pay the analysis cost once

    freshness.json

    SHA-256 hashes of every analyzed file. /draft:init refresh only re-analyzes files with changed hashes — no full re-scan.

    signals.json

    11-category signal classification. Detects structural drift on refresh (for example, auth files added for the first time).

    run-memory.json

    Phases completed, unresolved questions, resumable checkpoints. Interrupted runs resume where they left off.

    Each layer narrows the solution space. By the time AI writes code, most decisions are already made: product.md → tech-stack.md → .ai-context.md → spec.md → plan.md. Seven specialized agents (Planner, Architect, Reviewer, Debugger, RCA, Ops, Writer) enforce this at every step — and because the AI knows your system, it writes code that fits it.

    The only one with all three.

    Most tools cover one corner of AI-assisted development. Draft brings methodology, codebase intelligence, and verification together in one plugin.

      Draft Cursor / Copilot / Aider Sourcegraph / GitNexus ChatPRD / specStory
    Spec-driven planning Specs & phased plans before code Copilot Plan Mode · ad-hoc No PRD docs (ChatPRD)
    Knowledge graph engine Built-in · 159 languages · 100% local Indexes only Yes (separate service) No
    Three-stage code review Validation · spec compliance · quality PR bug review (BugBot) · not spec-aware No No
    Bug discovery 14-dimension sweep + taint tracking Cross-repo PR scan (BugBot) No No
    ACID-style audits Module lifecycle deep-review No No No
    Multi-IDE Claude, Cursor, Codex, opencode, Copilot, Gemini Copilot multi-IDE · rest single Editor extensions Web-only mostly
    Persistent context Git-tracked spec/plan/architecture Session-bound Index, not artifacts ChatPRD app · specStory repo files
    Price Free, MIT, no telemetry Subscription Sourcegraph paid · GitNexus free OSS Subscription

    Comparison reflects Draft 4.0 vs. publicly documented features of the named alternatives as of September 2026. Draft is the open-source plugin you install once and own forever.

    Built for every seat at the table.

    Draft speaks a different language to each role, but the artifacts are the same files — so the value compounds across the whole organization.

    Stop re-explaining your codebase to AI.

    /draft:init generates an architecture reference once. Every later agent interaction starts with full context, and each track loads only what's relevant. Write code that fits your system because Draft knows your system.

    • 5-phase codebase analysis with incremental refresh
    • TDD enforcement and a 14-dimension bug hunt
    • Token-optimized AI context, 200-400 lines
    Start with
    /draft:review no setup /draft:init then index
    Getting started guide →

    Review specs before code exists.

    Every track ships with a reviewable spec, a phased plan, and a three-stage code review. Team alignment happens in documents, not meetings, and quality gates sit at every phase boundary. Module audits enforce atomicity, consistency, isolation, and durability.

    • PR-reviewable planning artifacts
    • Three-stage review pipeline with spec compliance
    • Module lifecycle deep-review and pattern learning
    Start with
    /draft:new-track spec + plan /draft:review three stages
    See the review pipeline →

    A knowledge graph and 53 deterministic helpers.

    Tree-sitter + LSP across 159 languages. Incremental, git-aware indexing. 100% local — no API key, no code leaves your machine. Skills delegate mechanical work to JSON-emitting shell tools with a uniform exit-code contract, so every result is reproducible.

    • Six graph query modes: callers, callees, impact, cycles, hotspots, mermaid
    • Per-module SHA-256 freshness hashing
    • Scope-aware init for monorepos, module graphs linked to root
    Start with
    /draft:graph build the index /draft:impact blast radius
    How the graph stays fresh →

    Know what's being built before it's built.

    Specs anyone can read and review. Jira export with story points, tracks mapped to epics, phases to stories, tasks to sub-tasks. Status tracking across every track in the repo, straight from the files engineers already keep current.

    • Readable spec.md and plan.md per track
    • Jira preview, create, and ticket qualification
    • Progress and blockers from /draft:status
    Start with
    /draft:jira preview see the export /draft:status where things stand
    Jira integration →

    Deterministic quality gates you can audit, at zero cost.

    ACID compliance audits, Architecture Decision Records, monorepo federation. Every review cites the file, the line, and the graph query behind it. MIT licensed, no telemetry, no vendor lock-in — the specs and architecture docs are plain markdown in your own repo.

    • Auditable gates: specs before code, TDD, blast radius, ADRs
    • 100% local engine — no code leaves the machine
    • Enterprise-grade methodology, free forever
    Start with
    /draft:deep-review ACID audit /draft:adr decision records
    Deep review, explained →

    Turn any project into a documented system.

    Architecture discovery writes the reference you never had time to. Bug hunting catches what you'd never find by hand. Free, open source, MIT — the only costs are the host tools you already use.

    • Architecture docs with Mermaid diagrams, generated from the graph
    • 14-dimension bug hunt with regression tests
    • Works on brownfield and greenfield repos alike
    Start with
    /draft:init map the repo /draft:bughunt find defects
    The bug hunt chapter →

    Review specs, not surprises.

    Every markdown file goes through commit → review → merge before a single line of code is written. By the time implementation starts, the entire team has already agreed on what to build.

    1

    Initialize

    Tech lead runs /draft:init. Team reviews architecture, tech stack, and workflow via PR.

    2

    Spec & plan

    Lead runs /draft:plan. Team reviews requirements and task breakdown via PR.

    3

    Decompose

    Lead runs /draft:decompose. Team reviews module boundaries and API surfaces via PR.

    4

    Distribute

    /draft:jira create (or the unified /draft:jira router) pushes the work to Jira with full track context.

    5

    Implement

    Every developer has spec.md, plan.md, and .ai-context.md. Quality tools verify completeness.

    Changing a sentence in spec.md takes seconds. Changing an architectural decision after 2,000 lines of code takes days.

    Install in 30 seconds.

    Works with your existing tools. Zero switching cost. Run the review first — it needs no setup — and index the repo once you've seen what it catches.

    Claude Code CLI
    # Install Draft with one command
    npx @drafthq/draft install claude-code
    
    # Start here — no setup, reviews your current diff
    /draft:review
    
    # Once you've seen what it catches, index the repo
    /draft:init
    /draft:review  # same command, now with blast radius + hotspots

    Runs claude plugin marketplace add + install for you (default scope --global), then restart Claude Code. /draft:review works on an un-indexed repo and tells you which structural checks it had to skip — indexing is the upgrade, not the entry fee. Requires the claude CLI on your PATH. Using the Claude Code app without the CLI? Run /plugin marketplace add drafthq/draft then /plugin install draft inside a session instead.

    Cursor
    # Install Draft into Cursor
    npx @drafthq/draft install cursor

    Default scope --global. Installs to ~/.cursor/plugins/local/draft, writes .cursor-plugin/plugin.json, and registers + enables draft@draft-plugins in Cursor's plugin registry. Restart Cursor (or Developer: Reload Window) to load /draft:* commands.

    OpenAI Codex
    # Install Draft into Codex
    npx @drafthq/draft install codex

    Default scope --project. Writes AGENTS.md to your repo root — Codex reads it automatically. Pass --global to install outside the current project.

    opencode
    # Install Draft into opencode
    npx @drafthq/draft install opencode

    Default scope --project. Writes AGENTS.md + bundles skills under ~/.agents/skills/draft. Pass --global to install outside the current project.

    GitHub Copilot / Gemini
    # GitHub Copilot — copy the instructions file
    curl -o .github/copilot-instructions.md \
      https://raw.githubusercontent.com/drafthq/draft/main/integrations/copilot/.github/copilot-instructions.md
    
    # Gemini
    curl -o .gemini.md \
      https://raw.githubusercontent.com/drafthq/draft/main/integrations/gemini/.gemini.md

    Copilot & Gemini read a committed instructions file — copy it directly (not a draft install host).

    Prefer a persistent command? Install once with npm install -g @drafthq/draft, then run draft install <host>. Use draft list to see every host and its default scope (--global for Claude Code and Cursor, --project for Codex and opencode).

    No vendor lock-in. Your specs, plans, and architecture docs are plain markdown files in your repo. Switch tools any time — your project knowledge stays with you.

    The gates a senior reviewer would ask for, automated.

    Specs before code, TDD gates, blast-radius analysis, ADRs, ACID audits — enforced by the tool instead of remembered by the reviewer.

    Rank Practice Draft implementation Industry equivalent Companies
    1 Design-first engineering spec.md & plan.md per track Amazon PR/FAQ, Google design docs Google, Amazon, Stripe, Uber
    1 Monorepo / shared context /draft:init (scope-aware, per module root) Unified codebase, dependency graphing Google, Meta, Twitter
    2 Test-driven development /draft:implement RED-GREEN-REFACTOR TDD / CI gates Netflix, Pivotal
    3 Structured code review /draft:review 3-stage Google Critique system Google, Meta
    3 Architecture Decision Records /draft:adr + architecture.md Immutable ADRs Spotify, AWS, GitHub
    4 Bug bashes /draft:bughunt 14 dimensions Scheduled team testing sessions Microsoft, game studios
    5 Service catalog product.md + tech-stack.md Internal developer platform Spotify, Lyft

    Draft

    $0

    Free forever. Open source, MIT licensed.

    Host tool costs apply (Claude Code, Copilot, etc.)

    Kiro (AWS)

    $19-39/mo

    Free preview, then paid tiers

    Cursor

    $20-40/mo

    Free tier, then Pro/Business

    Windsurf

    $15+/mo

    Free tier, then paid

    What that actually buys you

    Three defects /draft:review found in Draft's own codebase, shipped as fixes in v3.6.0 — and the graph query that scopes each one.

    Reproducible
    Critical

    scripts/tools/_graph_queries.sh · gq_escape

    Escaped quotes but not backslashes, so a symbol name ending in \ broke out of the Cypher string literal and altered the query. Every graph tool routes user input through this function.

    Critical

    scripts/tools/graph-impact.sh

    Built its JSON payload by hand. When the engine failed, it emitted a well-formed empty result with source:"memory-graph" — a blast-radius query that reported "nothing downstream" instead of "I could not answer".

    Important

    scripts/tools/check-track-hygiene.sh

    A grep in a pipeline returned 1 on clean input, and under set -euo pipefail that aborted the validator mid-run. A track with zero problems produced zero output — indistinguishable from a pass.

    $ scripts/tools/graph-callers.sh --repo . --symbol json_escape
    {
      "symbol": "json_escape",
      "callers": [
        { "name": "emit",        "file": "scripts/tools/check-scope-conflicts.sh" },
        { "name": "emit",        "file": "scripts/tools/check-skill-line-caps.sh" },
        { "name": "emit",        "file": "scripts/tools/check-track-hygiene.sh" },
        { "name": "emit_array",  "file": "scripts/tools/scan-markers.sh" },
        { "name": "emit_lang",   "file": "scripts/tools/detect-test-framework.sh" },
        /* … 17 more */
      ]
    }
    # 22 callers across 20 files. Change this function's contract and the review
    # knows every file that has to be re-verified — before you open the PR.

    Run it yourself: /draft:review needs no setup, and /draft:init then adds the structural queries above. Every finding here is reproducible from the changelog and the finding-by-finding record.

    Frequently asked questions.

    Short answers to the things engineers ask before they install. The book covers everything else in depth.

    What is Draft?

    Draft is a free, open-source plugin that adds Context-Driven Development to AI coding agents. It provides 33 commands covering spec-driven planning, TDD enforcement, 3-stage code review, 14-dimension bug hunting, and architecture discovery for Claude Code, Cursor, Codex, opencode, GitHub Copilot, and Gemini.

    Is Draft free?

    Yes, Draft is completely free and open source under the MIT license. There are no paid tiers, no usage limits, and no vendor lock-in. The only costs are from the host AI tools you use (Claude Code, Copilot, etc.).

    What AI coding agents does Draft support?

    Draft supports Claude Code, Cursor, Codex, opencode, GitHub Copilot, and Gemini. It integrates natively with each platform using their respective configuration formats — slash commands for Claude Code and Cursor, an AGENTS.md file for Codex and opencode, copilot-instructions.md for Copilot, and .gemini.md for Gemini (including the Antigravity IDE).

    How do I install Draft?

    Run npx @drafthq/draft install claude-code to install for Claude Code. Alternatively: /plugin marketplace add drafthq/draft then /plugin install draft. For Cursor, run npx @drafthq/draft install cursor. For Copilot, download copilot-instructions.md into your .github directory. Each platform takes under 30 seconds to set up.

    Do I have to run /draft:init before I get anything?

    No. /draft:review runs on an un-indexed repo with zero setup: it resolves scope from git, runs automated validation and the four code-quality dimensions, and prints the report in the conversation without writing anything into your repo. It then names the specific checks it could not run — blast radius, downstream callers, dependency cycles, module boundaries — because those need the knowledge graph. /draft:init is the upgrade that switches them on, not the entry fee.

    What is Context-Driven Development?

    Context-Driven Development is a methodology where AI coding agents operate from persistent, file-based project context rather than ephemeral chat. Draft analyzes your codebase to generate architecture docs, then enforces a spec-first workflow: specifications and plans are written and reviewed before any code is generated.

    Does Draft work with my existing project?

    Yes. Running /draft:init performs a multi-phase analysis of your existing codebase, generating architecture documentation, AI context files, and signal classifications. It works with any language, framework, or project structure — brownfield or greenfield.

    How is Draft different from other AI coding tools?

    Draft is not an AI coding tool — it is a methodology layer that runs on top of existing AI agents. While tools like Cursor or Copilot generate code, Draft ensures that code follows approved specifications, passes TDD gates, and fits your architecture. It adds structure and quality gates, not another AI model.

    Does Draft require any configuration?

    Minimal. After installation, run /draft:init and it automatically analyzes your codebase and generates all necessary configuration files (product.md, tech-stack.md, architecture.md, etc.). You can customize these files afterward, but the defaults work out of the box.

    Can Draft work with monorepos?

    Yes. Run /draft:init at each module root — it is scope-aware and links each module graph to the root graph for full cross-module understanding.

    Does Draft support Jira integration?

    Yes. Use /draft:jira preview to generate the export and /draft:jira create (or the unified router) to push issues. The modern entry point is /draft:jira.