Create a Design Spec
Create a new design spec in specs/ following the spec document model.
Step 0: Parse arguments
$ARGUMENTS has the form: <track/name> [description...]
- The first token is the spec location:
<track>/<name> where <track> is
one of the tracks this repo actually uses and <name> is the kebab-case spec
name without .md. Example: local/live-serve.
- Never assume a fixed track list — tracks come and go. Read the live set from
the directories under
specs/, plus any track: frontmatter values in use
where specs sit directly in a directory that holds no sub-tracks. Take each
track's meaning from its section heading and intro in specs/README.md.
- If only a name is given without a track, list the live tracks with those
one-line meanings and ask the user which one it belongs to.
- Everything after the first token is a description — a short explanation
of what the spec should cover. If no description is provided, ask the user
what the spec should address.
Derive the output file path by answering two independent questions from how the
tree is actually laid out. They compose: specs/local/003-live-serve.md is a
perfectly ordinary path.
If specs/ does not exist yet, bootstrap a flat tree: create specs/, put the
first spec directly inside it with the requested track in track: frontmatter,
and create specs/README.md in Step 5. Do not force a directory scheme before
the project has chosen one.
- Which directory? If
specs/ has track directories, the spec goes in the
one it belongs to: specs/<track>/<name>.md. If specs sit directly under
specs/, it goes there and the track is recorded as a track: frontmatter
field instead.
- Numbered or not? If the sibling specs in that same directory carry an
NNN- prefix, give the new one the next number in that directory — usually
its current max + 1, zero-padded to three digits. If they do not, use the
bare name. Numbering is a per-directory reading-order convention, not a
property of the repo, and a repo may number one directory and not another.
The number is a local ordering hint only. Dependency order lives in
depends_on, which resolves repo-root-relative and forms one DAG across the
whole tree regardless of how any directory is grouped or numbered.
Step 1: Read context
- Read
specs/README.md to understand the track organization, dependency
graph, and what already exists. For a new tree where it is absent, record
that Step 5 must create a minimal index.
- Review the frontmatter schema and spec conventions. Where they are written
down varies by repo — look for a document-model spec under
specs/, or an
internals doc describing how specs are parsed. If neither exists, infer the
schema from the most recently updated spec in the tree.
- Grep spec files for any existing specs that overlap with the proposed topic
— check by name and by
affects paths. If a closely related spec exists,
warn the user and ask whether to proceed, merge, or abort.
Step 2: Explore the codebase
Based on the description, identify which parts of the codebase are relevant:
- Determine which packages, files, and interfaces the spec will affect.
- Use Grep and Glob to find existing code, types, and patterns in those areas.
- Launch Agent subagents (Explore type) for up to 3 independent areas in
parallel if the spec spans multiple subsystems.
- Note existing patterns, interfaces, and constraints that the spec must
account for.
The goal is to ground the spec in reality — reference actual file paths,
function names, and existing patterns rather than hypothetical code.
Step 3: Identify dependencies
Determine which existing specs this new spec depends on:
- Check
specs/README.md for specs that produce interfaces, types, or
infrastructure this spec needs.
- Check the
affects lists of existing specs for overlapping code paths.
- Only add
depends_on entries for specs whose deliverables are prerequisites
— not merely related specs.
Also identify which existing specs might depend on this new one (reverse
impact). Flag these to the user but do NOT modify them.
Step 4: Write the spec
Create the spec file at the path derived in Step 0 with this structure (add a
track: <track> line under status: only when the spec's directory does not
already name its track):
---
title: <Human-readable title>
status: drafted
depends_on:
- <spec paths, or empty list>
affects:
- <code paths and packages this spec will modify>
effort: <small | medium | large | xlarge>
created: <today's date, YYYY-MM-DD>
updated: <today's date, YYYY-MM-DD>
author: your-name
dispatched_task_id: null
---
# <Title>
## Overview
<2-4 sentences: what this spec delivers and why it matters. State the problem,
the user need, or the architectural gap it fills.>
## Current State
<Brief description of what exists today in the codebase that is relevant.
Reference actual file paths, types, and functions. This grounds the spec in
reality and helps readers understand the starting point.>
## Architecture
<How the solution fits into the existing system. Describe the key components,
their relationships, and where they live in the codebase. Use a diagram
(Mermaid) if the relationships are non-trivial.>
## Components
<For each major component or change:>
### <Component Name>
<What it does, where it lives, key design decisions. Reference existing
patterns in the codebase where relevant. Include:>
- File paths (existing files to modify, new files to create)
- Key types and interfaces
- Integration points with existing code
## Data Flow
<How data moves through the system for the primary use cases. Describe the
request/response path, state transitions, or processing pipeline. Skip this
section if the spec doesn't involve data flow.>
## API Surface
<New or modified API routes, CLI flags, env variables, or configuration
options. Follow the repository's existing reference format. Skip this section
if no external surface changes.>
## Error Handling
<How errors are detected, reported, and recovered from. What failure modes
exist and how the system degrades. Skip this section if error handling is
trivial.>
## Testing Strategy
<What to test and how. Reference existing test patterns in the affected
packages. Identify:>
- Unit tests (per-function, per-method)
- Integration tests (cross-package, end-to-end)
- Edge cases and failure scenarios
Writing guidelines:
- Focus on system design, not inline code. Use references to actual files
instead of code blocks where possible.
- Keep sections proportional to complexity — a simple spec doesn't need all
sections. Delete sections marked "skip if..." when they don't apply.
- Reference existing patterns with a concrete path from the repository instead
of re-explaining the pattern.
- Be specific about file paths and function names. Vague specs produce vague
implementations.
- Size the spec appropriately:
- Small/medium effort: one file, all sections concise. Can be implemented
directly.
- Large/xlarge effort: may be a parent spec that will be broken down via
/spec:breakdown. Focus on architecture and
component boundaries rather than implementation details.
Step 5: Update specs/README.md
- Read
specs/README.md. If it does not exist, create a minimal index with a
title, a short explanation of the track recorded in frontmatter, and the
spec table below.
- Add the new spec to the appropriate track table, maintaining the table's
existing order — alphabetical, or by number where the directory is numbered.
The link path is whatever Step 0 derived, relative to
specs/:| [<name>.md](<track>/<name>.md) | Not started | <one-line deliverable> |
- Add the spec to the Status Quo section if appropriate (use
○ for not
started).
- If the spec has dependencies, note them in the dependency graph section
if one exists.
Step 6: Commit
Stage the new spec file and the updated specs/README.md. Commit with:
specs: add <name> spec for <one-line purpose>
Do NOT push unless the user explicitly asks.
Step 7: Summary
Report to the user:
- The spec file path and a one-line summary
- Dependencies identified (both upstream and downstream impact)
- Effort estimate and rationale
- Suggested next steps:
- If large/xlarge: "Run
/spec:breakdown <spec-path> design to decompose
into sub-design problems"
- If small/medium: "Run
/spec:breakdown <spec-path> tasks to create
implementable tasks, or /spec:implement <spec-path> to implement directly"
- If dependencies are incomplete: "Blocked by ; implement that first
or run
/spec:impact <spec-path> for full analysis"
1---2name: create3description: Write a new spec from scratch when none exists for the idea yet. Gathers context, explores the codebase, fills the frontmatter, and indexes it in specs/README.md. Use when the user says "create a spec", "write a spec", or "new spec". When a spec already exists but is out of date, use refine instead.4---56# Create a Design Spec78Create a new design spec in `specs/` following the spec document model.910## Step 0: Parse arguments1112$ARGUMENTS has the form: `<track/name> [description...]`1314- The **first token** is the spec location: `<track>/<name>` where `<track>` is15 one of the tracks this repo actually uses and `<name>` is the kebab-case spec16 name without `.md`. Example: `local/live-serve`.17- Never assume a fixed track list — tracks come and go. Read the live set from18 the directories under `specs/`, plus any `track:` frontmatter values in use19 where specs sit directly in a directory that holds no sub-tracks. Take each20 track's meaning from its section heading and intro in `specs/README.md`.21- If only a name is given without a track, list the live tracks with those22 one-line meanings and ask the user which one it belongs to.23- Everything after the first token is a **description** — a short explanation24 of what the spec should cover. If no description is provided, ask the user25 what the spec should address.2627Derive the output file path by answering two independent questions from how the28tree is actually laid out. They compose: `specs/local/003-live-serve.md` is a29perfectly ordinary path.3031If `specs/` does not exist yet, bootstrap a flat tree: create `specs/`, put the32first spec directly inside it with the requested track in `track:` frontmatter,33and create `specs/README.md` in Step 5. Do not force a directory scheme before34the project has chosen one.35361. **Which directory?** If `specs/` has track directories, the spec goes in the37 one it belongs to: `specs/<track>/<name>.md`. If specs sit directly under38 `specs/`, it goes there and the track is recorded as a `track:` frontmatter39 field instead.402. **Numbered or not?** If the sibling specs *in that same directory* carry an41 `NNN-` prefix, give the new one the next number in that directory — usually42 its current max + 1, zero-padded to three digits. If they do not, use the43 bare name. Numbering is a per-directory reading-order convention, not a44 property of the repo, and a repo may number one directory and not another.4546The number is a local ordering hint only. Dependency order lives in47`depends_on`, which resolves repo-root-relative and forms one DAG across the48whole tree regardless of how any directory is grouped or numbered.4950## Step 1: Read context51521. Read `specs/README.md` to understand the track organization, dependency53 graph, and what already exists. For a new tree where it is absent, record54 that Step 5 must create a minimal index.552. Review the frontmatter schema and spec conventions. Where they are written56 down varies by repo — look for a document-model spec under `specs/`, or an57 internals doc describing how specs are parsed. If neither exists, infer the58 schema from the most recently updated spec in the tree.593. Grep spec files for any existing specs that overlap with the proposed topic60 — check by name and by `affects` paths. If a closely related spec exists,61 warn the user and ask whether to proceed, merge, or abort.6263## Step 2: Explore the codebase6465Based on the description, identify which parts of the codebase are relevant:66671. Determine which packages, files, and interfaces the spec will affect.682. Use Grep and Glob to find existing code, types, and patterns in those areas.693. Launch Agent subagents (Explore type) for up to 3 independent areas in70 parallel if the spec spans multiple subsystems.714. Note existing patterns, interfaces, and constraints that the spec must72 account for.7374The goal is to ground the spec in reality — reference actual file paths,75function names, and existing patterns rather than hypothetical code.7677## Step 3: Identify dependencies7879Determine which existing specs this new spec depends on:80811. Check `specs/README.md` for specs that produce interfaces, types, or82 infrastructure this spec needs.832. Check the `affects` lists of existing specs for overlapping code paths.843. Only add `depends_on` entries for specs whose deliverables are prerequisites85 — not merely related specs.8687Also identify which existing specs might depend on this new one (reverse88impact). Flag these to the user but do NOT modify them.8990## Step 4: Write the spec9192Create the spec file at the path derived in Step 0 with this structure (add a93`track: <track>` line under `status:` only when the spec's directory does not94already name its track):9596````markdown97---98title: <Human-readable title>99status: drafted100depends_on:101 - <spec paths, or empty list>102affects:103 - <code paths and packages this spec will modify>104effort: <small | medium | large | xlarge>105created: <today's date, YYYY-MM-DD>106updated: <today's date, YYYY-MM-DD>107author: your-name108dispatched_task_id: null109---110111# <Title>112113## Overview114115<2-4 sentences: what this spec delivers and why it matters. State the problem,116the user need, or the architectural gap it fills.>117118## Current State119120<Brief description of what exists today in the codebase that is relevant.121Reference actual file paths, types, and functions. This grounds the spec in122reality and helps readers understand the starting point.>123124## Architecture125126<How the solution fits into the existing system. Describe the key components,127their relationships, and where they live in the codebase. Use a diagram128(Mermaid) if the relationships are non-trivial.>129130## Components131132<For each major component or change:>133134### <Component Name>135136<What it does, where it lives, key design decisions. Reference existing137patterns in the codebase where relevant. Include:>138- File paths (existing files to modify, new files to create)139- Key types and interfaces140- Integration points with existing code141142## Data Flow143144<How data moves through the system for the primary use cases. Describe the145request/response path, state transitions, or processing pipeline. Skip this146section if the spec doesn't involve data flow.>147148## API Surface149150<New or modified API routes, CLI flags, env variables, or configuration151options. Follow the repository's existing reference format. Skip this section152if no external surface changes.>153154## Error Handling155156<How errors are detected, reported, and recovered from. What failure modes157exist and how the system degrades. Skip this section if error handling is158trivial.>159160## Testing Strategy161162<What to test and how. Reference existing test patterns in the affected163packages. Identify:>164- Unit tests (per-function, per-method)165- Integration tests (cross-package, end-to-end)166- Edge cases and failure scenarios167````168169**Writing guidelines:**170171- Focus on system design, not inline code. Use references to actual files172 instead of code blocks where possible.173- Keep sections proportional to complexity — a simple spec doesn't need all174 sections. Delete sections marked "skip if..." when they don't apply.175- Reference existing patterns with a concrete path from the repository instead176 of re-explaining the pattern.177- Be specific about file paths and function names. Vague specs produce vague178 implementations.179- Size the spec appropriately:180 - **Small/medium effort**: one file, all sections concise. Can be implemented181 directly.182 - **Large/xlarge effort**: may be a parent spec that will be broken down via183 `/spec:breakdown`. Focus on architecture and184 component boundaries rather than implementation details.185186## Step 5: Update specs/README.md1871881. Read `specs/README.md`. If it does not exist, create a minimal index with a189 title, a short explanation of the track recorded in frontmatter, and the190 spec table below.1912. Add the new spec to the appropriate track table, maintaining the table's192 existing order — alphabetical, or by number where the directory is numbered.193 The link path is whatever Step 0 derived, relative to `specs/`:194 ```195 | [<name>.md](<track>/<name>.md) | Not started | <one-line deliverable> |196 ```1973. Add the spec to the Status Quo section if appropriate (use `○` for not198 started).1994. If the spec has dependencies, note them in the dependency graph section200 if one exists.201202## Step 6: Commit203204Stage the new spec file and the updated `specs/README.md`. Commit with:205`specs: add <name> spec for <one-line purpose>`206207Do NOT push unless the user explicitly asks.208209## Step 7: Summary210211Report to the user:212- The spec file path and a one-line summary213- Dependencies identified (both upstream and downstream impact)214- Effort estimate and rationale215- Suggested next steps:216 - If large/xlarge: "Run `/spec:breakdown <spec-path> design` to decompose217 into sub-design problems"218 - If small/medium: "Run `/spec:breakdown <spec-path> tasks` to create219 implementable tasks, or `/spec:implement <spec-path>` to implement directly"220 - If dependencies are incomplete: "Blocked by <spec>; implement that first221 or run `/spec:impact <spec-path>` for full analysis"