Spec-Driven Development
The big picture: A spec turns a rough idea into durable, reviewable artifacts — requirements.md, design.md, and tasks.md — and then into working code. Each phase has a human approval gate, every task can be dispatched to an agent, and every step is recorded with who did it and when.
Why it matters: Chat is great for exploration, but large features need structure that survives across sessions and people. A spec is the shared, versioned source of truth: what we're building, how, the ordered task list, and the full history of decisions.
Spec vs. Plan
| Plan (Architect) | Spec | |
|---|---|---|
| Lifespan | One chat session | Durable, git-tracked |
| Output | A plan you act on now | requirements.md + design.md + tasks.md |
| Gates | None | Human Approve / Revise per phase |
| Execution | Inline in the session | Tasks dispatched as workers (inline, background, or worktree) |
| Accountability | — | Owner + append-only history |
Use a Plan for a focused change you'll finish in one sitting. Use a Spec when the work spans multiple sessions, people, or waves of parallel tasks — and you want an auditable trail.
File layout
Specs live in your repository so they review and version like code:
.cfactory/specs/<feature>/ requirements.md # business proposition, prioritized user stories (Gherkin), FR/NFR design.md # how (architecture, components, trade-offs, traceability) tasks.md # business-oriented checklist with dependencies + What/Why/Acceptance meta.yaml # owner + provenance (service-owned, never LLM-edited) history.jsonl # append-only event log (service-owned)
Platform default templates (Admin CoW base) ship SpecForge-aligned structure: business-first requirements, design with mermaid, and wave-schedulable tasks with business-oriented titles. bugfix specs use a single bugfix.md in place of requirements/design.
meta.yaml and history.jsonl are written only by CFactory, never by the agent. This keeps ownership and history trustworthy.
The workflow
- Create a spec (kind:
feature,bugfix, orquick). CFactory seeds the templates and sets you as the owner. - Requirements → Design → Tasks. Each phase uses a dedicated agent (
spec-requirements→spec-design→spec-tasks). The agent fills the artifact, then asks you to Approve or Revise. Nothing advances without your gate. - Implement. Run tasks — one at a time, or the next wave of independent tasks in parallel — via the
spec-implementagent.
quick specs skip the gates and generate all artifacts in one pass, for small, well-understood work.
The task graph and waves
tasks.md is a normal Markdown checklist. CFactory derives an execution order from it:
- [ ] 1. Add the HTTP endpoint - [x] 1.1 Define the schema - [~] 1.2 Wire the handler - [P] 2. Build the TUI list # [P] = safe to run in parallel - [ ] 3. Wire the IDE view - _Depends: 1, 2_ # explicit dependency edge - _Requirements: 1.2_ # traceability back to requirements - _Optional_ # excluded from "run all"
- Checkbox state maps to status:
[ ]pending,[~]in progress,[x]done. - Nested items depend on their parent;
_Depends:_adds explicit edges. - CFactory groups tasks into waves — each wave is a set of tasks with no unmet dependencies, so they can run together.
Running waves & background dispatch
When you run a task, CFactory dispatches a worker session. Choose the isolation:
- inline — runs in the current context.
- background — a detached agent session you can monitor while you keep working.
- worktree — an isolated git worktree, ideal for parallel waves that touch overlapping files.
As workers finish, CFactory flips the checkboxes in tasks.md and records the result.
Owner & history
Every spec has an owner, and every meaningful action is appended to history.jsonl: spec created, phase approved/revised (with your comment), owner changed, task dispatched, task completed. The actor is resolved in priority order — your signed-in CFactory account, then your git identity, then the dispatching agent, then the local host — so the log answers "who validated this phase?" and "who ran this task?" at a glance.
Spec UI in the IDE
Open Specs from the CFactory sidebar toolbar. You get:
- A list of specs with phase, task progress, and owner.
- A detail panel with the phase stepper, task tree, wave breakdown, live workers, and recent history.
- Actions to Approve / Request revision on the current gate, Run the next wave, and Abort a running worker.
The view is powered by the same backend as the CLI, so status stays in sync — checkbox and phase changes on disk are reflected live.
Spec CLI
The same spec is available from a terminal:
cfactory spec list # table of specs cfactory spec new --kind feature --title "Checkout flow" cfactory spec show checkout-flow # phase stepper, task tree, waves, history cfactory spec run checkout-flow # dispatch the next wave cfactory spec run checkout-flow --task 1.2 --isolation worktree cfactory spec history checkout-flow --type phase.approved
Add --json to any read command to script against the raw data.
Customizing templates & the SDD agents
The default SDD chain uses one specialized agent per step:
| Step | Agent |
|---|---|
| Requirements | spec-requirements |
| Design | spec-design |
| Tasks | spec-tasks |
| Implement (wave workers) | spec-implement |
spec remains the coordinator (and the agent for quick specs). The IDE and CLI select the phase agent automatically for generate / refine / approve / revise / run.
The artifact templates and the per-phase agent prompts resolve through a layered overlay, each layer overriding the one before it:
- Built-in defaults shipped with CFactory.
- User global — your personal overrides.
- Organization — policies published in the Admin content library (may lock templates/prompts so projects can't override them).
- Project — files under
.cfactory/spec/templates/and.cfactory/spec/prompts/in the repo.
Instructions append across layers (user → org → project). When an org locks a template, project and user files for it are ignored and the resolved source is marked org.
JetBrains and Console surfaces for specs, and an org-admin visual template editor, are not included in this release. Manage org templates/prompts through Admin and org configuration for now.