From draft
Decomposes projects or tracks into modules with dependency mapping. Updates architecture.md and generates token-optimized .ai-context.md with module definitions, diagrams, and implementation order.
npx claudepluginhub mayurpise/draft --plugin draftThis skill uses the workspace's default tool permissions.
You are decomposing a project or track into modules with clear responsibilities, dependencies, and implementation order.
Creates specs and phased file-level implementation plans for features, bugs, refactors by researching codebase with search, graph queries, and context files.
Scans codebase and generates high-level architecture graph as interlinked markdown files in docs/professor/architecture/. Use for new project analysis or significant changes.
Guides architecture design via Socratic questioning, generates technical docs like overview.md, domain-model.md, and ADR for new features, systems, or project structuring.
Share bugs, ideas, or general feedback.
You are decomposing a project or track into modules with clear responsibilities, dependencies, and implementation order.
ALL generated files MUST include the standard YAML frontmatter. This enables refresh tracking, sync verification, and traceability.
Before generating any file, run these commands to gather metadata:
# Project name (from manifest or directory)
basename "$(pwd)"
# Git branch
git branch --show-current
# Git remote tracking branch
git rev-parse --abbrev-ref --symbolic-full-name @{upstream} 2>/dev/null || echo "none"
# Git commit SHA (full)
git rev-parse HEAD
# Git commit SHA (short)
git rev-parse --short HEAD
# Git commit date
git log -1 --format="%ci"
# Git commit message (first line)
git log -1 --format="%s"
# Check for uncommitted changes
git status --porcelain | head -1
For track-scoped decomposition, also derive the human-readable track title used in the track-architecture.md H1:
{TRACK_TITLE} — first-level heading text from the active track's spec.md (the # ... line). If spec.md has no H1, fall back to the {TRACK_ID}.Insert this YAML frontmatter block at the top of every generated file:
---
project: "{PROJECT_NAME}"
module: "{MODULE_NAME or 'root'}"
track_id: "{TRACK_ID or null}"
generated_by: "draft:decompose"
generated_at: "{ISO_TIMESTAMP}"
git:
branch: "{LOCAL_BRANCH}"
remote: "{REMOTE/BRANCH or 'none'}"
commit: "{FULL_SHA}"
commit_short: "{SHORT_SHA}"
commit_date: "{COMMIT_DATE}"
commit_message: "{FIRST_LINE_OF_COMMIT_MESSAGE}"
dirty: {true|false}
synced_to_commit: "{FULL_SHA}"
---
Note:
generated_byusesdraft:commandformat (not/draft:command) for cross-platform compatibility.
Parse $ARGUMENTS for flags first, then strip them before interpreting the remaining text as scope:
--lld → LLD mode — generate Section 6 (Low-Level Design) in addition to HLD. Strip from arguments before scope detection.Scope detection (on stripped arguments):
project or no argument with no active track → Project-wide decomposition → draft/.ai-context.mddraft/tracks/<id>/architecture.mdLLD auto-trigger: Even without --lld, LLD is generated automatically when any module in Step 3 is marked Complexity: High. Tell the developer when this triggers: "One or more modules are High complexity — generating LLD automatically."
draft/product.md for product understandingdraft/tech-stack.md for technical patternsspec.md for requirementsplan.md for existing task breakdownFor brownfield projects, scan the existing codebase using these concrete steps:
Directory structure — Map top-level organization:
ls -d src/*/ lib/*/ app/*/ packages/*/ 2>/dev/null
Entry points — Find main files and exports:
index.ts, main.ts, app.ts, mod.rs, __init__.py, main.gopackage.json main/exports fields, pyproject.toml entry points, go.mod module pathExisting module boundaries — Identify by:
src/auth/, src/users/)package.json in subdirs, __init__.py, go package declarations)index.ts re-exporting from a directory)Dependency patterns — Trace imports:
import / require / from statements across source filesutils/ imported everywhere)File type filters by language:
| Language | Source Extensions | Config Files |
|---|---|---|
| TypeScript/JS | *.ts, *.tsx, *.js, *.jsx | tsconfig.json, package.json |
| Python | *.py | pyproject.toml, setup.py, requirements.txt |
| Go | *.go | go.mod, go.sum |
| Rust | *.rs | Cargo.toml |
What to ignore: node_modules/, __pycache__/, target/, dist/, build/, .git/, vendored dependencies. Always respect .gitignore and .claudeignore.
draft/graph/ exists)When graph data is available, use it as the primary source for module discovery instead of manual scanning:
draft/graph/module-graph.jsonl — exact module list with file counts per language (.cc, .h, .go, .proto, .py)draft/graph/hotspots.jsonl — high-complexity files that may need further decompositiondraft/graph/modules/<name>.jsonl for file-level graphs within modules of interestThis data is deterministic and exhaustive. Prefer it over heuristic scanning when available. See core/shared/graph-query.md.
Propose a module breakdown through dialogue:
For each module, define:
core/agents/architect.md)STOP. Present the module breakdown to the developer.
═══════════════════════════════════════════════════════════
MODULE BREAKDOWN
═══════════════════════════════════════════════════════════
Scope: [Project / Track: <track-id>]
MODULE 1: [name]
Responsibility: [one sentence]
Files: [file list]
API: [public interface summary]
Dependencies: [none / module names]
Complexity: [Low/Medium/High]
MODULE 2: [name]
...
═══════════════════════════════════════════════════════════
Wait for developer approval. Developer may add, remove, rename, or reorganize modules.
After modules are approved:
STOP. Present the dependency diagram and implementation order.
═══════════════════════════════════════════════════════════
DEPENDENCY ANALYSIS
═══════════════════════════════════════════════════════════
DIAGRAM
─────────────────────────────────────────────────────────
[auth] ──> [database]
│ │
└──> [config] <──┘
│
[logging] (no deps)
TABLE
─────────────────────────────────────────────────────────
Module | Depends On | Depended By
---------- | ----------------- | -----------------
logging | - | auth, database, config
config | logging | auth, database
database | config, logging | auth
auth | database, config | -
IMPLEMENTATION ORDER
─────────────────────────────────────────────────────────
1. logging (leaf - no dependencies)
2. config (depends on: logging)
3. database (depends on: config, logging)
4. auth (depends on: database, config)
Parallel opportunities: config and database can start after logging.
═══════════════════════════════════════════════════════════
Wait for developer approval.
Template selection depends on scope:
core/templates/architecture.md (full 25-section reference)core/templates/track-architecture.md (HLD-focused, with optional LLD block)Location:
draft/architecture.md with the module changes, then run the Condensation Subroutine (defined in core/shared/condensation.md) to regenerate draft/.ai-context.mddraft/tracks/<id>/architecture.mdFor track-scoped decomposition, populate these HLD sections in the track-architecture template — do not leave placeholders:
spec.md (Problem Statement, Technical Approach, Non-Functional Requirements). Name integration points from draft/.ai-context.md.New / Modified / Existing), responsibility, files, API surface, deps, complexity.flowchart TD with three subgraphs: modules in scope, existing system modules this track touches, external collaborators (DB, queue, third-party API). Label edges with transport type when non-obvious.flowchart LR tracing the primary data transformation: input → validation → logic → persistence → output. Add a separate read-path diagram if the track has both.sequenceDiagram per acceptance criterion that crosses more than one module. Include at minimum: (a) the happy-path flow, (b) one error/failure path. Annotate gates and invariants with Note over.stateDiagram-v2 only if the track introduces or mutates stateful entities. Omit the section when not applicable — do not emit empty diagrams.Cycle? column.core/agents/architect.md Story Lifecycle for how this gets populated during /draft:implement)[ ] Not Started)Trigger: --lld flag was passed in Step 1 OR any module in §2 has Complexity: High.
Skip condition: None of the above. Leave §6 with the stub: "LLD not generated. Run /draft:decompose --lld to expand."
When triggered, populate §6 of the track-architecture template. Refer to core/agents/architect.md for contract-design conventions.
New or Modified, list every public function/method with: language-appropriate signature, param constraints, return shape, error types. Document preconditions, postconditions, and invariants (thread safety, idempotency, ordering).STOP. Present the generated track-architecture.md to the developer. Call out:
--lld flag or auto-triggered by High-complexity module X)Wait for developer approval before proceeding to Step 6.
If this is a track-scoped decomposition and a plan.md exists:
When restructuring plan.md around modules, follow these rules for existing tasks:
Completed tasks [x]: Preserve exactly as-is. Map them to the appropriate module phase. Do not rename, reorder, or modify. Add a note: (preserved from original plan).
In-progress tasks [~]: Map to the appropriate module phase. Flag for developer review if the task spans multiple modules:
- [~] **Task 2.1:** Original task description
- ⚠ REVIEW: This task may need splitting across modules [auth] and [database]
Pending tasks [ ]: Remap freely to module phases. Split tasks that span module boundaries into per-module tasks. Preserve the original task description in the new task.
Blocked tasks [!]: Preserve the blocked status and reason. Map to appropriate module. If the blocker is in a different module, add a cross-module dependency note.
Conflict handling: If a task doesn't map cleanly to any module:
### Unmapped Tasks section at the endSTOP. Present the updated plan structure.
PROPOSED PLAN RESTRUCTURE
─────────────────────────────────────────────────────────
Phase 1: [Module A] (Foundation)
- Task 1.1: [existing or new task]
- Task 1.2: ...
Phase 2: [Module B] (depends on Module A)
- Task 2.1: ...
...
Wait for developer approval before writing changes to plan.md.
After applying the approved plan changes:
metadata.json: Set phases.total to match the new number of phases in the restructured plan.draft/tracks.md: Update the phase count for this track's entry to reflect the new total (e.g., Phase: 0/4 → Phase: 0/5 if a phase was added).Announce:
Architecture decomposition complete.
Created: [path to architecture.md]
Modules: [count]
Implementation order: [module names in order]
Next steps:
- Review architecture.md and edit as needed
- Run /draft:implement to start building (stories, execution state,
and skeleton checkpoints will activate automatically)
- After implementation is complete, run `/draft:coverage` to verify test quality
draft/architecture.mdis the source of truth.draft/.ai-context.mdis derived from it via the Condensation Subroutine (defined incore/shared/condensation.md). Always updatearchitecture.mdfirst, then regenerate.ai-context.md.
When adding new modules to the project-wide architecture:
draft/architecture.md: append module definitions, update dependency diagram and table[x] Existing modulesgit.commit and git.message to current HEADcore/shared/condensation.md) to regenerate draft/.ai-context.mdSafe write pattern for architecture.md:
architecture.md → architecture.md.backuparchitecture.md.newarchitecture.md with architecture.md.new, run Condensation Subroutine, then delete architecture.md.backuparchitecture.md.new and rename architecture.md.backup back to architecture.mdWhen revisiting decomposition (running /draft:decompose on an existing .ai-context.md or architecture.md):
After defining module boundaries and interfaces:
"Decomposition complete. Consider:
Testing:
→ /draft:testing-strategy — Define per-module test boundaries and integration test strategy
Documentation:
→ /draft:documentation api <module> — Document public module interfaces
Architecture:
→ /draft:adr "Module boundary decisions for {project}" — Record decomposition rationale"
If dependency analysis (Step 4) detects cycles or high coupling:
"Detected dependency cycles / high coupling. Consider:
→ /draft:tech-debt — Catalog architecture debt and prioritize remediation"
When decomposition involves breaking a monolith, choosing module boundaries, or extracting services:
/draft:adr "Module boundary decisions for {project}"