A versioned documentation layer for AI-assisted development
Project description
spec
A versioned documentation layer for AI-assisted development. spec maintains a separate Git repository of contextual documentation that helps AI agents understand your codebase without polluting your main Git history.
Why spec?
- AI-Optimized Context: Structured documentation designed for LLM consumption
- Version-Controlled Memory: AI agents can learn from past attempts and decisions
- Isolated Git History: Documentation changes don't clutter your main repository
- Scoped Context Windows: Load only relevant documentation to fit within token limits
- Rich Terminal UI: Beautiful, colorful interface with progress indicators
- Modular Architecture: Clean, testable codebase built for extensibility
Installation
pip install spec-cli
Quick Start
# Initialize spec in your project
spec init
# Generate documentation for files
spec gen src/models.py # Single file
spec gen src/ # Directory
spec gen . # Current directory (all files)
# Track documentation changes
spec add .
spec commit -m "Document authentication flow"
# View documentation status
spec status
spec log
spec diff
Features
โ Core Features
- Project Initialization:
spec initcreates isolated Git repository structure - Documentation Generation:
spec gencreates structured documentation with templates - Version Control: Full Git workflow (
add,commit,status,log,diff) - Template System: Customizable documentation templates via
.spectemplate - File Filtering: Smart filtering with
.specignorepatterns - Rich Terminal UI: Beautiful interface with colors, progress bars, and styling
- Batch Processing: Generate documentation for entire directories
- File Type Detection: Support for 20+ programming languages and file types
- Conflict Resolution: Interactive handling of existing documentation
- Debug Mode: Comprehensive debugging with
SPEC_DEBUG=1 - Modular Architecture: Clean, maintainable codebase with 80%+ test coverage
๐ฎ Future Features
- AI Documentation Generation: Replace placeholder content with AI-generated documentation
- Git Hook Integration: Auto-generate documentation on code changes
- Enhanced CLI: Advanced options and configuration management
How It Works
spec creates two directories:
.spec/- A bare Git repository (like.git).specs/- Working tree containing documentation
Your documentation mirrors your project structure:
project/
โโโ .spec/ # Bare Git repo for versioning
โโโ .specs/ # Documentation working tree
โ โโโ src/
โ โ โโโ models/
โ โ โโโ index.md
โ โ โโโ history.md
โ โโโ api/
โ โโโ users/
โ โโโ index.md
โ โโโ history.md
โโโ .spectemplate # Customizable templates
โโโ .specignore # Ignore patterns
โโโ src/
โ โโโ models.py
โโโ api/
โโโ users.py
Each source file gets a documentation directory with:
index.md: Current understanding and specificationshistory.md: Evolution, decisions, and lessons learned
Commands
Core Commands
spec init- Initialize spec in current directoryspec gen <path>- Generate documentation for file(s) or directoryspec add <path>- Stage documentation changesspec commit -m "message"- Commit documentation changes
View Documentation
spec status- Show documentation statusspec log [path]- Show documentation historyspec diff [path]- Show uncommitted changesspec show <path>- Display documentation for a file (coming soon)
Future Commands
spec regen <path>- Regenerate documentation (preserves history)spec agent-scope [options]- Export scoped context for AI agents
Advanced Usage
Custom Templates
Create a .spectemplate file to customize documentation format:
index:
template: |
# {{filename}}
**Location**: {{filepath}}
**Purpose**: {{purpose}}
**Responsibilities**: {{responsibilities}}
**Requirements**: {{requirements}}
**Example Usage**: {{example_usage}}
**Notes**: {{notes}}
history:
template: |
## {{date}} - Initial Creation
**Purpose**: Created initial specification for {{filename}}
**Context**: {{context}}
**Decisions**: {{decisions}}
**Lessons Learned**: {{lessons}}
Environment Variables
Control spec behavior with environment variables:
SPEC_DEBUG=1- Enable debug output for troubleshootingSPEC_DEBUG_LEVEL=INFO|DEBUG|WARNING|ERROR- Set debug levelSPEC_DEBUG_TIMING=1- Enable operation timing
File Filtering
Use .specignore to exclude files from documentation generation:
# Ignore patterns
*.log
node_modules/
build/
*.min.js
Architecture
spec follows a clean, modular architecture built through a comprehensive refactoring:
Directory Structure
spec_cli/
โโโ cli/ # Command-line interface layer
โโโ core/ # Core business logic and workflow orchestration
โโโ git/ # Git operations abstraction
โโโ templates/ # Template system for documentation generation
โโโ file_system/ # File system operations and path handling
โโโ config/ # Configuration management
โโโ ui/ # Rich terminal UI components
โโโ file_processing/ # Batch processing and conflict resolution
โโโ exceptions.py # Custom exception hierarchy
โโโ logging/ # Debug logging and timing
Key Design Principles
- Single Responsibility: Each module has a clear, focused purpose
- Dependency Injection: Services are easily testable and mockable
- Clean Interfaces: Well-defined boundaries between layers
- Rich Terminal UI: Beautiful, colorful interface throughout
- Comprehensive Testing: 80%+ test coverage across all modules
Development Setup
This project uses Poetry for dependency management and uv for virtual environments:
# Create virtual environment with uv
uv venv
# Activate virtual environment
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
# Install dependencies with poetry
poetry install
# Run tests with coverage (80% minimum required)
poetry run pytest tests/unit/ -v --cov=spec_cli --cov-report=term-missing --cov-fail-under=80
# Run type checking
poetry run mypy spec_cli/
# Run linting and formatting
poetry run ruff check --fix .
poetry run ruff format .
# Run all pre-commit hooks
poetry run pre-commit run --all-files
Use Cases
For AI Development
- Provide rich context to AI coding assistants
- Track why certain approaches failed
- Maintain institutional knowledge across AI sessions
- Export scoped documentation for specific tasks
For Teams
- Onboard new developers with comprehensive docs
- Document architectural decisions and trade-offs
- Track technical debt and future improvements
- Maintain living documentation that evolves with code
For Code Review
- Understand the "why" behind implementations
- Review documentation changes alongside code
- Ensure specs stay synchronized with reality
- Track decision history and lessons learned
IDE Integration
Hide .spec/ and .specs/ directories in your IDE. For VSCode, add to workspace settings:
{
"files.exclude": {
".spec": true,
".specs": true
}
}
Install Testing Branch From Test PyPI
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ --pre spec-ai
Contributing
We follow a vertical slice development philosophy - implementing features completely through implementation, testing, and typing before moving on. See CLAUDE.md for detailed development guidelines.
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spec_ai-0.1.51.tar.gz.
File metadata
- Download URL: spec_ai-0.1.51.tar.gz
- Upload date:
- Size: 133.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f307c5679ab14892e8d29629fa11e4f1ea69ec13918d8a210f8e22c16cdb1214
|
|
| MD5 |
a03252f180c6fb0e0d8b90685969d5bc
|
|
| BLAKE2b-256 |
b502d5e02c40bbd465ddab993d9ad9a93cd74d95b94349ee0c15fe6e4610a956
|
Provenance
The following attestation bundles were made for spec_ai-0.1.51.tar.gz:
Publisher:
release.yml on Spenquatch/spec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spec_ai-0.1.51.tar.gz -
Subject digest:
f307c5679ab14892e8d29629fa11e4f1ea69ec13918d8a210f8e22c16cdb1214 - Sigstore transparency entry: 228087212
- Sigstore integration time:
-
Permalink:
Spenquatch/spec@ab552db4cb0c640169417ceea656546bd4eb8891 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Spenquatch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ab552db4cb0c640169417ceea656546bd4eb8891 -
Trigger Event:
push
-
Statement type:
File details
Details for the file spec_ai-0.1.51-py3-none-any.whl.
File metadata
- Download URL: spec_ai-0.1.51-py3-none-any.whl
- Upload date:
- Size: 174.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7272fecdda4d9a4592fa171f092edf63a0c714b7376e2a16368c43a42062d4f2
|
|
| MD5 |
eee46e292092cf37c7fae082163ccb57
|
|
| BLAKE2b-256 |
03b8ada13fdf483520969cf49512ae0e131a106fe64aa8c420c61db8d7c0df85
|
Provenance
The following attestation bundles were made for spec_ai-0.1.51-py3-none-any.whl:
Publisher:
release.yml on Spenquatch/spec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spec_ai-0.1.51-py3-none-any.whl -
Subject digest:
7272fecdda4d9a4592fa171f092edf63a0c714b7376e2a16368c43a42062d4f2 - Sigstore transparency entry: 228087216
- Sigstore integration time:
-
Permalink:
Spenquatch/spec@ab552db4cb0c640169417ceea656546bd4eb8891 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Spenquatch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ab552db4cb0c640169417ceea656546bd4eb8891 -
Trigger Event:
push
-
Statement type: