Skip to main content

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, documentedIn paths exist
  • Coverage verification - Match @implements, @tests, @documents markers 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

  1. 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/
    
  2. 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
    
  3. 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
    """
    
  4. 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:

Reference:

Working with specs:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

projectspec-0.1.1.tar.gz (56.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

projectspec-0.1.1-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

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

Hashes for projectspec-0.1.1.tar.gz
Algorithm Hash digest
SHA256 59081e3a76cbc74bd51d76738a58879ec9bfa58afa3f89e123460bc086c8c247
MD5 cb97545721483b9560f024b06688437e
BLAKE2b-256 684a446358b18b36d1091fbf7047ea12310b298a8e7cbcb819faed5a61c354d9

See more details on using hashes here.

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

Hashes for projectspec-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 07113d3b568d9f61ebaf7b7dc70c0f735ef94eed3996598c47a2bbd0dc5d12bf
MD5 87ab94e4ab3dd3f9737e6fdbf144cb4a
BLAKE2b-256 4c6da37bb46f987de29a59152f5ed707727a797477f18f43ca72a2cb23f1a93b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page