Machine-readable specs that link intent to code, with tooling to surface drift
Project description
Project Spec
Machine-readable specs that link intent to code, with tooling to surface drift.
Software is full of implicit knowledge—what the system should do versus what it does. This gap becomes critical when AI agents enter the picture: an agent can't distinguish between a test that's wrong and a test that's protecting something important. Without explicit intent, agents silently regress functionality, drift from requirements, and lose context between sessions.
Project Spec solves this by declaring intent in YAML specs, linking those declarations bidirectionally to code via markers, and running reconciliation to surface gaps.
Read the manifesto → for the full philosophy and motivation.
Prerequisites
- Python 3.10+
Installation
# Install from source (PyPI coming soon)
git clone https://github.com/codewithcheese/projectspec.git
pip install ./projectspec[validation]
Quick Start
# Run reconciliation on the example project
cd projectspec/examples/taskflow
projectspec reconcile
Example output:
Reconciliation complete: 3/5 features OK
(1 planned features skipped)
spec/capabilities/auth.yaml:
user-authentication/password-reset: [ERROR] Path does not exist
→ tests/api/test_password_reset.py
Unlinked files (not referenced in any spec):
src/api/routes/teams.py
The output shows:
- OK - Features where all linked files exist
- ERROR - Missing implementation or test files
- WARNING - Missing documentation files
- Planned - Features with
status: planned(skipped) - Unlinked - Files not referenced by any spec
What You Get
- Schema validation - Specs validated against JSON Schema defined in KindDefinitions
- File existence checking - Verify
implementedIn,testedIn,documentedInpaths exist - Coverage verification - Match
@implements,@tests,@documentsmarkers to acceptance criteria - Relationship graphs - Track dependencies, detect cycles, validate entity references
- JSON output - Machine-readable results for CI integration (
--format json) - Custom kinds - Define domain-specific entity types (not just Capability/Feature)
- GitHub Action - Run reconciliation and spec review on PRs with comments and labels
CI Integration
Add ProjectSpec checks to your GitHub workflow:
# .github/workflows/projectspec.yml
name: Projectspec
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: codewithcheese/projectspec/.github/actions/projectspec@main
On PRs, this posts a comment summarizing spec changes and adds severity labels (spec-info, spec-warning). See the CI Integration Guide for configuration options.
How It Works
┌─────────────────┐
│ SPEC FILES │ ← Human-controlled source of truth
│ (yaml) │
└────────┬────────┘
│
│ declares
▼
┌─────────────────┐ ┌─────────────────┐
│ CAPABILITIES │ ───► │ IMPLEMENTATION │
│ (what it does) │ │ (code, tests, │
│ │ ◄─── │ docs) │
└─────────────────┘ └─────────────────┘
│ │
└────────┬───────────────┘
│
▼
┌─────────────────┐
│ RECONCILIATION │ ← Surface drift, resolve intentionally
│ (diff spec vs │
│ reality) │
└─────────────────┘
Code links back to specs via markers:
"""
@implements feature:auth/login
- User can log in with email and password
- Invalid credentials return 401
"""
def login(email: str, password: str) -> Token:
...
Adding Specs to Your Project
-
Create spec directory structure:
your-project/ ├── spec/ │ ├── kinds/ # Copy from examples or define your own │ │ ├── capability.yaml │ │ └── feature.yaml │ └── capabilities/ # Your specs go here │ └── auth.yaml └── src/ -
Write your first spec:
apiVersion: projectspec/v1alpha1 kind: Feature metadata: name: auth/login spec: status: implemented acceptance: - User can log in with email and password - Invalid credentials return 401 implementedIn: - src/auth/login.py testedIn: - tests/test_auth.py
-
Add markers to your code:
# src/auth/login.py """ @implements feature:auth/login - User can log in with email and password - Invalid credentials return 401 """
-
Run reconciliation:
projectspec reconcile
Core Concepts
Spec as contract - The spec is a machine-readable agreement, not documentation that rots. Every statement is verifiable: "feature is implemented" → linked files exist.
Reconciliation - Drift between spec and reality is expected. The goal isn't to prevent drift—it's to surface it and resolve it intentionally.
Human authority over spec - Agents implement what specs say; changing specs requires human approval. This prevents agents from "solving" problems by redefining them away.
Documentation
Understand the concepts:
- About - Core principles and rationale
- Methodology - Reconciliation loop and workflow
- Schema Design - Why specs are structured this way
Reference:
- Spec Format - How to write spec files
- Entity Model - Entity categories and relationships
- Defining Kinds - How to create custom KindDefinitions
Working with specs:
- Agent Guidelines - How AI agents should interact with specs
- CI Integration - Add ProjectSpec checks to GitHub Actions
- Worked Example - The taskflow example explained
Status
This is an early exploration of the methodology. The format and tooling will evolve.
Current limitations:
- No watch mode for continuous reconciliation
- Limited adapter support (Python, Markdown)
- No IDE integration yet
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 projectspec-0.1.1.tar.gz.
File metadata
- Download URL: projectspec-0.1.1.tar.gz
- Upload date:
- Size: 56.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.2 cpython/3.12.12 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59081e3a76cbc74bd51d76738a58879ec9bfa58afa3f89e123460bc086c8c247
|
|
| MD5 |
cb97545721483b9560f024b06688437e
|
|
| BLAKE2b-256 |
684a446358b18b36d1091fbf7047ea12310b298a8e7cbcb819faed5a61c354d9
|
File details
Details for the file projectspec-0.1.1-py3-none-any.whl.
File metadata
- Download URL: projectspec-0.1.1-py3-none-any.whl
- Upload date:
- Size: 38.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.2 cpython/3.12.12 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07113d3b568d9f61ebaf7b7dc70c0f735ef94eed3996598c47a2bbd0dc5d12bf
|
|
| MD5 |
87ab94e4ab3dd3f9737e6fdbf144cb4a
|
|
| BLAKE2b-256 |
4c6da37bb46f987de29a59152f5ed707727a797477f18f43ca72a2cb23f1a93b
|