This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Run all tests with coverage
pytest tests/ --cov=specpulse --cov-report=html --cov-report=term-missing
# Run specific test file
pytest tests/test_cli.py -v
# Run tests without coverage (faster)
pytest tests/ -v
# Run a single test function
pytest tests/test_cli.py::TestCLI::test_init_command -v# Format code with black
black specpulse/ tests/
# Lint with flake8
flake8 specpulse/ tests/
# Type checking with mypy
mypy specpulse/
# Run all quality checks
black specpulse/ tests/ && flake8 specpulse/ tests/ && mypy specpulse/# Build package
python -m build
# Install in development mode
pip install -e .
# Run CLI locally
python -m specpulse.cli.main --help
# Or use the shorthand
sp --help# Initialize a new project
python -m specpulse.cli.main init test-project
python -m specpulse.cli.main init --here # In current directory
# Validate project
python -m specpulse.cli.main validate
# Run diagnostics
python -m specpulse.cli.main doctor
# Sync project state
python -m specpulse.cli.main sync
# Decompose a specification
python -m specpulse.cli.main decompose 001SpecPulse is a specification-driven development framework that enforces a structured approach to software development through AI integration and constitutional principles.
-
CLI Layer (
specpulse/cli/main.py)- Entry point:
SpecPulseCLIclass - Commands: init, validate, doctor, sync, decompose
- Rich console output with animations and progress bars
- Entry point:
-
Core Engine (
specpulse/core/specpulse.py)SpecPulseclass: Template management and project initialization- Handles resource copying, command generation, and project structure
-
Validator (
specpulse/core/validator.py)Validatorclass: Validates specs, plans, and constitutional compliance- Enforces 9 immutable development principles
- Phase gates system for quality control
-
Utilities (
specpulse/utils/)Console: Rich terminal output with tables, animations, and color codingGitUtils: Git integration for version control
The framework generates AI commands in two formats:
Claude (.claude/commands/*.md):
- Markdown files with YAML frontmatter
- Arguments passed via
$ARGUMENTSto shell scripts - Example:
/sp-pulse feature-name→ executesscripts/sp-pulse-init.sh
Gemini (.gemini/commands/*.toml):
- TOML configuration files
- Arguments interpolated via
{{args}}placeholder - Same command structure as Claude
project/
├── specs/ # Feature specifications (001-feature/)
├── plans/ # Implementation plans (derived from specs)
├── tasks/ # Task breakdowns (T001, T002 or SERVICE-T001)
├── memory/ # Persistent state
│ ├── constitution.md # 9 immutable principles
│ ├── context.md # Current project state
│ └── decisions.md # Architecture Decision Records
├── templates/ # Customizable document templates
└── scripts/ # Shell scripts for AI execution
For complex specifications, the framework supports automatic decomposition:
- Creates service boundaries using Domain-Driven Design
- Generates API contracts (OpenAPI 3.0)
- Service-specific plans and tasks (AUTH-T001, USER-T001)
- Integration plans for service communication
All development follows 9 immutable articles:
- Library-First: Every feature must be modular
- CLI Interface: Text-based interaction only
- Test-First: Tests before implementation
- Specification as Source: Specs drive all development
- Direct Framework Usage: No unnecessary abstractions
- No Abstraction Layers: Simplicity over complexity
- Simplicity Enforcement: ≤3 modules per feature
- Complexity Tracking: Document exceptions
- Framework-First: Use existing solutions
Templates use Jinja2 for dynamic generation:
- Specification templates include
[NEEDS CLARIFICATION]markers - Plan templates have architecture and phase sections
- Task templates use complexity estimates (Simple/Medium/Complex)
- Decomposition templates for microservices and APIs
All AI commands execute Bash scripts:
sp-pulse-init.sh: Initialize featuressp-pulse-spec.sh: Create specificationssp-pulse-plan.sh: Generate planssp-pulse-task.sh: Break down taskssp-pulse-decompose.sh: Decompose into microservicessp-pulse-execute.sh: Execute tasks continuously
Scripts work cross-platform (Git Bash on Windows, native on Linux/macOS).
The /sp-execute command enables non-stop task completion:
/sp-execute # Execute next task and continue
/sp-execute all # Execute ALL pending tasks without stopping
/sp-execute T001 # Start from specific taskKey Features:
- NO STOPPING between tasks
- NO EXPLANATIONS until all done
- NO CONFIRMATIONS needed
- Automatic progression through entire task list
- Only stops when all tasks completed or blocked
Workflow Example:
/sp-pulse new-feature # Initialize
/sp-spec "description" # Create spec
/sp-plan # Generate plan
/sp-task # Break down tasks
/sp-execute all # Complete EVERYTHING!This enables maximum efficiency by eliminating context switching and maintaining flow state.
When AI executes commands like /sp-pulse, /sp-spec, etc., the following happens:
- Script Location: Scripts are copied to
project-root/scripts/ - Script Execution:
bash scripts/sp-pulse-init.sh [arguments] - Project Root Detection: Scripts automatically detect project root as parent of scripts/ directory
project-root/ # User's project directory
├── scripts/ # Shell scripts (copied from SpecPulse)
│ ├── sp-pulse-init.sh
│ ├── sp-pulse-spec.sh
│ ├── sp-pulse-plan.sh
│ └── sp-pulse-task.sh
├── templates/ # Template files (MUST have these exact names)
│ ├── spec.md # NOT spec-001.md
│ ├── plan.md # NOT plan-001.md
│ └── task.md # Correct name
├── specs/
│ └── 001-feature-name/ # Feature directory
│ ├── spec-001.md # First specification
│ └── spec-002.md # Updated specification
├── plans/
│ └── 001-feature-name/ # Same feature directory name
│ └── plan-001.md # Implementation plan
└── tasks/
└── 001-feature-name/ # Same feature directory name
└── task-001.md # Task breakdown
/sp-pulse user-auth→bash scripts/sp-pulse-init.sh "user-auth"/sp-spec→bash scripts/sp-pulse-spec.sh "001-user-auth"/sp-plan→bash scripts/sp-pulse-plan.sh "001-user-auth"/sp-task→bash scripts/sp-pulse-task.sh "001-user-auth"
The feature directory name (e.g., "001-user-auth") is passed to spec, plan, and task scripts.
ABSOLUTELY CRITICAL: The files in templates/ directory are TEMPLATES. They must NEVER be renamed or have their filenames changed:
templates/spec.md- MUST always remain asspec.mdtemplates/plan.md- MUST always remain asplan.mdtemplates/task.md- MUST always remain astask.md
These are SOURCE TEMPLATES that get COPIED to the appropriate directories with proper naming.
Creates the following structure:
specs/001-user-authentication/
└── spec-001.md (copied from templates/spec.md)
plans/001-user-authentication/
└── plan-001.md (copied from templates/plan.md)
tasks/001-user-authentication/
└── task-001.md (copied from templates/task.md)
- First spec:
specs/001-user-authentication/spec-001.md - Updates create:
spec-002.md,spec-003.mdetc. - NEVER modifies
templates/spec.md
Creates decomposition subdirectory:
specs/001-user-authentication/
├── spec-001.md
└── decomposition/
├── microservices.md (from templates/decomposition/microservices.md)
├── api-contracts/
│ └── *.yaml (from templates/decomposition/api-contract.yaml)
└── interfaces/
└── *.ts (from templates/decomposition/interface.ts)
Then creates service-specific plans:
plans/001-user-authentication/
├── auth-service-plan.md (from templates/decomposition/service-plan.md)
├── user-service-plan.md (from templates/decomposition/service-plan.md)
└── integration-plan.md (from templates/decomposition/integration-plan.md)
And service-specific tasks:
tasks/001-user-authentication/
├── auth-service-tasks.md (with AUTH-T001, AUTH-T002...)
├── user-service-tasks.md (with USER-T001, USER-T002...)
└── integration-tasks.md (with INT-T001, INT-T002...)
### ❌ NEVER DO THIS
- NEVER rename `templates/spec.md` to `templates/spec-001.md`
- NEVER rename `templates/plan.md` to `templates/001-plan.md`
- NEVER edit filenames in `templates/` directory
- NEVER modify files in `.claude/` or `.gemini/` directories
- NEVER edit scripts in `scripts/` directory unless fixing bugs
- NEVER create files directly in `templates/` directory
- NEVER confuse template files with working files
### Protected vs Editable Directories
**Protected (Read-Only after init):**
- `templates/` - Original template files (spec.md, plan.md, task.md)
- `scripts/` - Shell scripts (sp-pulse-*.sh)
- `.claude/commands/` - Claude command definitions
- `.gemini/commands/` - Gemini command definitions
**Editable (Working directories):**
- `specs/XXX-feature/` - Feature specifications (spec-001.md, spec-002.md)
- `plans/XXX-feature/` - Implementation plans (plan-001.md, plan-002.md)
- `tasks/XXX-feature/` - Task breakdowns (task-001.md, task-002.md)
- `memory/` - Project state (context.md, decisions.md)
## Important Notes
### Version Management
- Current version: 1.3.2 (in `pyproject.toml`)
- Version must sync between `pyproject.toml` and `setup.py`
- Use semantic versioning for releases
### Resource Handling
- Templates and scripts are copied from `specpulse/resources/`
- Never modify files in `.claude/` or `.gemini/` after initialization
- Templates in `templates/` are editable by users BUT filenames must stay the same
- Scripts in `scripts/` should remain executable
### Testing Coverage
- Comprehensive test suite in `tests/`
- Multiple test files for complete coverage
- Use pytest with coverage reporting
- Mock external dependencies (Git, filesystem)
### Console Features
- ASCII art banners for branding
- Progress bars for long operations
- Color-coded output (success=green, error=red, warning=yellow)
- Tables for structured data display
- Pulse animations for visual feedback