This project uses Livespec for living, synchronized, spec-driven development. This document is your complete guide on how to use it.
Livespec treats specifications as living documentation that evolves with code:
- Specs are the source of truth — code implements specs, not the other way around
- Bidirectional sync — when code drifts from specs, prompt the user to decide: fix code or update spec
- Context-rich — specs include the "why", not just the "what"
- AI-native — sync and maintenance done by AI, not scripts
- Test-linked — features are made of scenarios, each with automated tests to ensure correctness and prevent regressions
- Cohesive grouping — one spec file per capability, keeping related screens, modals, and logic together
This empowers creative iteration — you can explore freely knowing specs keep everything aligned.
| Term | Definition |
|---|---|
| Spec | A markdown file containing testable scenarios for a feature |
| Scenario | A single testable behavior with WHEN/THEN structure and spec ID |
| Spec ID | Unique identifier like [PRJ.sidebar.tabs] linking specs ↔ tests ↔ code |
| Feature | A cohesive capability including its screens, modals, and logic |
| Plan | A proposal for changes, lives in plans/active/ until complete |
| Sync | Periodic check between specs, code, and tests |
| Entry point | A route or action where users begin interacting with a feature |
Each project has a 3-character code prefix for spec IDs. Examples:
| Code | Project | Path |
|---|---|---|
| APP | Main App | livespec/projects/app/ |
| API | Backend API | livespec/projects/api/ |
livespec/
├── livespec.md # This file - AI instructions
├── sync/ # Sync reports (keeps last 10)
│ └── YYYY-MM-DD-HHMMSS.md
├── projects/
│ └── [project-name]/
│ ├── project.md # Project context, codebase location, domain knowledge
│ └── [feature]/
│ └── spec.md # Specs with context + scenarios
├── plans/
│ ├── active/ # In-progress plans
│ │ └── [plan-name]/
│ │ ├── plan.md # Proposal + tasks + design (combined)
│ │ └── specs/ # Draft specs (promote when done)
│ └── archived/ # Completed plans (historical record)
│ └── YYYY-MM-DD-[plan-name]/
# Feature Name [PRJ.feature]
Narrative explanation of what this feature is and why it exists.
## Entry Points
Optional section. Where users access this feature.
| Route / Trigger | Description |
|-----------------|-------------|
| /path/to/page | Main screen for this feature |
| Modal from [PRJ.other-feature] | Triggered by action in another feature |
## UI
Optional section. Layout structure, components, and available actions.
### Figma
Optional subsection. Link to Figma designs.
https://figma.com/file/...
## Design Decisions
Optional section. Rationale for non-obvious choices.
---
## Requirement Name [PRJ.feature.requirement]
Brief description of what this requirement ensures.
### Scenario: Specific behavior [PRJ.feature.requirement.behavior]
Testing: e2e
- WHEN precondition or action
- THEN expected outcome
- AND additional outcomes
### Scenario: Another behavior [PRJ.feature.requirement.other]
- WHEN different condition
- THEN different outcomeWhen a segment (e.g., [PRJ.users.profile]) grows too large:
- Create a subdirectory:
users/profile/spec.md - The ID prefix matches the path:
[PRJ.users.profile] - Parent spec links to child or remains as overview
users/
├── spec.md # [PRJ.users] - overview + common scenarios
└── profile/
└── spec.md # [PRJ.users.profile] - detailed scenarios
- Format:
[PRJ.path.to.item]where PRJ is the 3-char project code - Dot-separated:
[PRJ.sidebar.tabs](dashes allowed but shorter names preferred) - Lowercase, descriptive names
- NEVER change existing IDs unless requested — changing IDs breaks test and code references
Unit tests are the default. Only declare Testing: when using a different type:
### Scenario: Tab display on navigation [PRJ.sidebar.tabs-display]
Testing: e2eValid test types:
unit— Unit tests (fast, isolated) — DEFAULT, don't declare. MUST be preferred — extremely fast. Interactive code (prompts, CLI) can be unit tested by mocking the prompt library.e2e— End-to-end tests (browser, full flow)integration— Integration tests (API, database)none— No automated test — MUST be avoided; find a way to test the behavior
Related e2e scenarios can share a single test session when they follow a natural user flow. This is faster than spinning up separate browser sessions for each scenario.
/**
* @spec [PRJ.checkout.add-item]
* @spec [PRJ.checkout.update-quantity]
* @spec [PRJ.checkout.remove-item]
*/
test('checkout cart operations', async ({ page }) => {
// ... tests for all three scenarios in sequence
})When to batch: Scenarios that form a logical flow where each step builds on the previous state.
Tests for specified behavior MUST reference specs via @spec in JSDoc-like comments:
/** @spec [PRJ.sidebar.tabs-display] */
it('shows all exports as tabs', () => { ... })Internal implementation tests (helpers, utilities) don't need @spec references.
Sync uses these annotations to verify test coverage. MUST use /** */ (or equivalent for used language) over // for spec references.
Use JSDoc-like comments for implementation code:
/**
* Handles tab overflow with horizontal scrolling.
* @spec [PRJ.sidebar.tabs-overflow]
*/
function handleTabOverflow() { ... }Code references are optional but help with traceability.
Plans combine proposal, tasks, and design into one file:
# Plan: [Brief Description]
## Summary
1-2 sentences on what this plan achieves.
## Why
Problem or opportunity being addressed.
## What Changes
- Bullet list of changes
- Mark breaking changes with **BREAKING**
## Design Decisions (if needed)
### Decision: [What]
**Choice:** [Selected option]
**Alternatives considered:** [Other options and why not]
**Rationale:** [Why this choice]
## Tasks
### Phase 1: [Name]
- [ ] Task description
- [ ] Another task
### Phase 2: [Name]
- [ ] Dependent task
## Affected Specs
- `[PRJ.sidebar.tabs]` — ADDED/MODIFIED/REMOVED- Use kebab-case:
add-msw-mocking,refactor-sidebar - Verb-led prefixes:
add-,update-,remove-,refactor-,fix- - Short and descriptive
- Ensure uniqueness within
plans/active/
Each project has a project.md with context and conventions:
# Project Name
## Overview
What this project does, codebase location.
## Domain Knowledge
Key concepts, terminology, gotchas.
## Entry Points
| Route | Feature | Description |
|-------|---------|-------------|
| /home | [PRJ.home] | Authenticated landing |
| /checkout | [PRJ.checkout] | Purchase flow |
## UI Conventions
- Use X component for buttons
- Theme-aware colors only/livespec — Ensure everything is aligned:
- Structure check: Validates Projects table and project.md files, fixes issues if found
- Spec validation: Checks spec format, test coverage, test type matches
- Auto-actions: Promote completed plan specs, archive completed plans
- Reports: Creates sync report in
livespec/sync/with errors, warnings, and suggestions - Circuit breaker: Stops after 20 errors to avoid wasting time on broken state
- Partial sync: For large projects, offers scoped sync (by project, feature, or changed files)
When creating a new project from scratch (not just setting up Livespec in an existing codebase), you MUST gather requirements before implementation:
-
Prompt the user for (only what wasn't already specified):
- Programming language(s)
- Tech stack and frameworks
- Package manager preference
- Testing framework preference
- Any architectural constraints or preferences
-
For JavaScript/TypeScript projects: Recommend
bunas package manager and test runner — its integrated, extremely fast tests synergize well with Livespec's test-linked approach. Present this as a recommendation, not a requirement. -
Document decisions in the project's
project.mdunder a "Tech Stack" section -
NEVER assume defaults — always confirm choices with the user first
You MUST run this checklist before starting work:
- Read
project.mdfor conventions and domain context - Read relevant specs in
livespec/projects/[project]/ - If unclear, ask clarifying questions before scaffolding
Stay spec-aware during all development:
- Before coding: Check if relevant specs exist in
livespec/projects/[project]/ - While coding: If behavior changes, note that specs may need updating
- After coding: Propose spec updates if behavior diverged
You MUST create a plan before implementing any non-trivial feature. Do not ask "want me to add this?" — create the plan first, present it, then implement after approval.
-
Create plan:
livespec/plans/active/[plan-name]/- Write
plan.mdwith summary, why, what, tasks - Create draft specs in
plans/active/[plan-name]/specs/
- Write
-
Get approval: NEVER start implementation until plan is approved
- Share plan with user for approval
- Clarify any ambiguities before proceeding
-
Implement: Work through tasks, mark progress with
- [x] -
Update specs: Promote draft specs to
projects/[project]/, update existing specs -
Archive: When all tasks complete, move plan to
plans/archived/YYYY-MM-DD-[plan-name]/
- Bug fixes (restore existing spec behavior)
- Typos, formatting, comments
- Small enhancements within existing specs
- Test additions for existing specs
- Dependency updates (non-breaking)
- Configuration changes
Skipping a plan does NOT mean skipping specs. Even for small changes, you MUST:
- New behavior → Add scenario to relevant spec
- Changed behavior → Update existing scenario
- New tests → Add
@specreference linking to scenario
The only exceptions are pure refactors (no behavior change) and documentation-only changes.
When implementing new features or changing behavior, you MUST add corresponding tests:
- Every new scenario → Add a test with
@specreference before considering implementation complete - Changed behavior → Update existing tests to match new behavior
- NEVER mark a feature as done without test coverage
Tests are not optional. A feature without tests is an incomplete feature.
You MUST verify:
- Specs added/updated for any new or changed behavior
- Tests added with
@specreferences - Type checking, linting, and tests pass (if configured)
NEVER consider a task complete without all three.
When sync finds mismatches:
- Determine which is correct (spec or code)
- If spec is correct → fix code
- If code is correct → update spec
- Document the decision in the sync plan
Code behavior not documented in specs:
Synccreates draft spec proposal- Review if behavior is intentional
- If intentional → promote draft to main specs
- If unintentional → consider removing code
Scenario declares Testing: e2e but:
- No test found → sync reports missing
- Test found in unit files → sync reports type mismatch
Remember: Specs are living. Code evolves. Keep them in sync.