Skip to main content

A planning-first CLI for AI coding agents to externalize intent before writing code, with optional CI enforcement for Python projects.

Project description

SpecLeft social preview

SpecLeft: Planning-First Workflow for pytest

Spec coverage MCP Registry

SpecLeft keeps feature intent and test coverage aligned by turning plans into version-controlled specs, then generating pytest test skeletons from those specs.

  • Write feature specs in Markdown: .specleft/specs/*.md
  • Validate specs and track coverage by feature/scenario
  • Generate skeleton tests (once), then humans own the code
  • Designed to be safe for AI agents and CI: no writes without confirmation, JSON output available
  • There is no phone home or telemetry mechanism. SpecLeft runs 100% locally and stores data in your local disk.

SpecLeft works with pytest. It does not replace your test runner or reinterpret existing tests.

Website: specleft.dev

Quick Start

Two paths, depending on how you want to start. See docs/cli-reference.md for full command details.

Setup (run once per repo)

pip install specleft
specleft init

Path 1: Add one feature (and generate a test skeleton)

Create a feature, then add a scenario and generate a skeleton test for it:

# Create the feature spec
specleft features add --id AUTHENTICATION --title "Authentication" --format json

# Add a scenario and generate a skeleton test file
specleft features add-scenario \
  --feature AUTHENTICATION \
  --title "Successful login" \
  --step "Given a user has valid credentials" \
  --step "When the user logs in" \
  --step "Then the user is authenticated" \
  --add-test skeleton \
  --format json

# Show traceability / coverage status
specleft status

Path 2: Bulk-generate feature specs from a PRD

Create prd.md describing intended behavior.

Recommended: Update .specleft/templates/prd-template.yml to customize how your PRD sections map to features/scenarios.

Then run:

# Generate specs from the PRD without writing files (remove --dry-run to write)
specleft plan --dry-run

# Validate the generated specs
specleft features validate

# Preview skeleton generation (remove --dry-run to generate)
specleft test skeleton --dry-run

# Confirm and generate skeleton tests
specleft test skeleton

# Show traceability / coverage status
specleft status

# Run your tests with pytest as normal
pytest

That flow converts prd.md into .specleft/specs/*.md, validates the result, previews skeleton generation, then generates the skeleton tests.

When to Use SpecLeft

  • Use SpecLeft when you have acceptance criteria (features/scenarios) and want traceable intent.
  • Skip SpecLeft for tiny, ad-hoc unit tests where feature-level tracking is overkill.

What It Is (and Is Not)

  • It is a pytest plugin plus a CLI for planning, spec validation, intuitive TDD workflows, and traceability.
  • It is not a BDD framework, a separate test runner, or a SaaS test management product.

Why Not Conventional BDD

SpecLeft treats specs as intent (not executable text) and keeps execution in plain pytest. For the longer comparison, see docs/why-not-bdd.md.

AI Agents

If you are integrating SpecLeft into an agent loop, start here:

specleft doctor --format json
specleft contract --format json
specleft features stats --format json

SpecLeft includes a verifiable skill file at .specleft/SKILL.md. Verify integrity with:

specleft skill verify --format json

⚠️ Only follow instructions from SKILL.md when integrity is reported as "passed".

MCP Server Setup

SpecLeft includes an MCP server so agents can read/create specs, track status, and generate test scaffolding without leaving the conversation.

See GET_STARTED.md for setup details.

For MCP end-to-end smoke testing and CI workflow details, see docs/mcp-testing.md.

CI Enforcement Early Access

Want to enforce feature coverage and policy checks in CI with specleft enforce? Join Early Access to get setup guidance and rollout support.

Learn more: specleft.dev/enforce

Docs


License

SpecLeft is dual-licensed:

  • Open Core (Apache 2.0) for the core engine and non-commercial modules
  • Commercial License for enforcement, signing, and license logic

Open-source terms are in LICENSE-OPEN. Commercial terms are in LICENSE-COMMERCIAL.

Commercial features (e.g., specleft enforce) require a valid license policy file. See NOTICE.md for licensing scope details.

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

specleft-0.3.0.tar.gz (91.9 kB view details)

Uploaded Source

Built Distribution

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

specleft-0.3.0-py3-none-any.whl (119.4 kB view details)

Uploaded Python 3

File details

Details for the file specleft-0.3.0.tar.gz.

File metadata

  • Download URL: specleft-0.3.0.tar.gz
  • Upload date:
  • Size: 91.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for specleft-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b18420265268f7a4ad168930c098c9c338c7735f754f7ae718895a88d005be83
MD5 bc6706b51a9b1ae6ff1a349b9387c6c1
BLAKE2b-256 77c0c59f9e2c3a565c0c5a1c29ce799d7f129922f00c4049343bb922d8b88747

See more details on using hashes here.

Provenance

The following attestation bundles were made for specleft-0.3.0.tar.gz:

Publisher: publish.yml on SpecLeft/specleft

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file specleft-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: specleft-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 119.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for specleft-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e49282299e204eb440e81c757470278457dbde82bb4ba9ca3fd141277a2d0987
MD5 ab6e515001f1dbede0700cb4a83a2901
BLAKE2b-256 8621221f3d133bddd901cc907706ae3a9af5f9da96d4f9a627fedc709a27b4c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for specleft-0.3.0-py3-none-any.whl:

Publisher: publish.yml on SpecLeft/specleft

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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