A planning-first CLI for AI coding agents to externalize intent before writing code, with optional CI enforcement for Python projects.
Project description
SpecLeft — Planning-First CLI for Python
A planning buffer for AI coding agents — externalize intent before writing code.
SpecLeft lets teams capture intended behaviour as feature specs (.specleft/specs/*.md) before implementation, then optionally enforce that intent in CI.
Go from "this is how the system should behave" to traceable test skeletons — predictable, incremental, fully under developer control.
SpecLeft does not replace pytest.
It does not reinterpret your tests.
It does not mutate your code unless you explicitly say yes.
Quick Start
Create a prd.md describing the intended behaviour of your system, then run:
pip install specleft
specleft plan
This converts prd.md into feature specifications under .specleft/specs/
without writing code or tests.
For AI Coding Agents
SpecLeft provides a planning and safety layer for autonomous execution.
Before acting, SpecLeft provides machine-verifiable guarantees by running:
specleft contract --format json
See AI_AGENTS.md for integration guidance and scenarios on when to use SpecLeft and when not to.
SpecLeft also includes CLI commands to create feature specs and append scenarios directly from the terminal.
See specleft features add and specleft features add-scenario in docs/cli-reference.md.
What problem does SpecLeft solve?
Most teams already have:
- feature specs (Jira, ADO, docs, wikis etc.)
- automated tests (pytest in this case)
- CI pipelines
What they don’t have is alignment.
Specs drift. Tests drift. Coverage becomes guesswork. New contributors find it hard to know what behaviour is expected vs accidental.
SpecLeft closes that gap by making feature intent visible, executable, and version-controlled, without forcing you into BDD frameworks or heavyweight process.
When to Use SpecLeft
| Your Situation | Use SpecLeft? | Why |
|---|---|---|
| Building new feature with acceptance criteria | ✅ Yes | Track coverage by feature |
| Have existing tests, need visibility | ✅ Yes | Add specs retrospectively |
| Writing unit tests for utilities | ❌ No | Too granular for spec tracking |
| Need to generate test scaffolding | ✅ Yes | Skeleton generation built-in |
| Want BDD-style Gherkin | ⚠️ Maybe | SpecLeft uses simpler Markdown |
| Have Jira/ADO stories to track | ✅ Yes | Specs mirror story structure |
Quick Decision:
- Do you have feature stories/scenarios to track? → Use SpecLeft
- Are you just writing ad-hoc unit tests? → Use plain pytest
What SpecLeft is (and is not)
SpecLeft is
- A pytest plugin
- A CLI for generating test skeletons from Markdown specs
- A step-level tracing layer for understanding system behaviour
- A local-first, self-hosted reporting tool
SpecLeft is not
- A BDD framework
- A test runner
- A codegen tool that rewrites your tests
- A test management SaaS
You stay in control.
Why we're not a conventional BDD test tool?
BDD tools are well-established and solve a real problem — but they make trade-offs that don’t fit many modern teams.
Here’s the practical difference.
General BDD model
- Specs are the tests
- Behaviour is executed through step-definition glue
- Runtime interpretation of text drives execution
- Tests live outside your normal test framework
- Refactoring behaviour often means refactoring text + glue
This works well when:
- QAs own specs
- Developers implement glue
- The organisation is committed to BDD ceremony
It breaks down when:
- Tests are already written
- Developers want code-first workflows
- Specs are evolving, incomplete, or exploratory
- Teams want gradual adoption
SpecLeft’s model
- Specs describe intent, not execution
- Tests remain native pytest functions
- Skeletons are generated once, then owned by humans
- No runtime interpretation of text
- No glue layer to maintain
In short:
| BDD Tool | SpecLeft |
|---|---|
| Specs executed at runtime | Specs generate skeleton test |
| Text-driven execution | Code-driven execution |
| Glue code required | Plain pytest |
| Heavy ceremony | Incremental adoption |
| All-in or nothing | Opt-in per test |
SpecLeft is not “BDD without Gherkin Given/When/Then”. It’s TDD with better alignment and visibility.
Core ideas (read this first)
- Specs describe intent, not implementation
- Skeleton tests encode that intent in code
- Skeletons are human-owned after generation
- Nothing changes unless you explicitly approve it
SpecLeft is designed to be boringly predictable.
Installation
pip install specleft
No config files required. No test changes required.
SpecLeft Agent Contract
SpecLeft is designed to be safely operated by autonomous agents.
Guaranteed invariants:
- No files are written without explicit confirmation or flags
- All commands support machine-readable JSON output
- All validation errors are explicit and actionable
- Missing behaviour is skipped, never failed
- CLI exit codes are meaningful and stable
SpecLeft commands are safe to:
- run repeatedly
- embed in agent loops
- execute in CI without side effects
Agent-Safe by Design
SpecLeft includes an explicit Agent Contract defining safety, determinism, and control guarantees for autonomous systems.
Agents may safely embed SpecLeft in execution loops without risk of unexpected file mutation or CI failure.
Quick Start Workflow for AI Agents
If you're an AI agent evaluating SpecLeft for a project:
Workflow for AI Agents
If you're an AI agent evaluating SpecLeft for a project:
# 1. Install and verify
pip install specleft
specleft doctor --format json
# 2. Review the agent contract
specleft contract --format json
# 3. Check current feature state
specleft features stats --format json
# 4. Ensure a PRD exists (required for planning)
# (Assumes prd.md is present in the repo root)
# 5. Generate feature specs from the PRD
specleft plan
# This will create files like:
# .specleft/specs/feature-auth.md
# 6. Example: feature specification (single file per feature)
mkdir -p .specleft/specs
cat > .specleft/specs/feature-auth.md << EOF
# Feature: Authentication
## Scenarios
### Scenario: Successful login
priority: high
- Given a user has valid credentials
- When the user logs in
- Then the user is authenticated
EOF
# 7. Validate feature specs
specleft features validate --format json
# 8. Preview test skeleton plan (no files written)
specleft test skeleton --dry-run --format json
# 9. Generate test skeletons (optionally --skip-preview if you don't want interactive confirmation)
specleft test skeleton
# 10. Identify the next scenario to implement
specleft next --format json
# 11. Implement application code and tests
# (agent or human implementation)
# 12. Track progress
specleft status --format json
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
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 specleft-0.2.1.tar.gz.
File metadata
- Download URL: specleft-0.2.1.tar.gz
- Upload date:
- Size: 80.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cab2efbfe8d64df2ad3ebc0786aa27490c84c6161bbcd0fb7cbd4723f1d36f42
|
|
| MD5 |
371c27158f4c19c7e3451a6522c06333
|
|
| BLAKE2b-256 |
1dcd610dd09cb703e8cb76c4a9aeb398dbf0878d9ad7d2fd2152c83099853eab
|
Provenance
The following attestation bundles were made for specleft-0.2.1.tar.gz:
Publisher:
publish.yml on SpecLeft/specleft
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
specleft-0.2.1.tar.gz -
Subject digest:
cab2efbfe8d64df2ad3ebc0786aa27490c84c6161bbcd0fb7cbd4723f1d36f42 - Sigstore transparency entry: 938690757
- Sigstore integration time:
-
Permalink:
SpecLeft/specleft@a64a807e9df5cf9498a6a0aad3d368b5a9ca7fa2 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/SpecLeft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a64a807e9df5cf9498a6a0aad3d368b5a9ca7fa2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file specleft-0.2.1-py3-none-any.whl.
File metadata
- Download URL: specleft-0.2.1-py3-none-any.whl
- Upload date:
- Size: 101.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b06afb1aaecc3e6970a34f614a461038259399cee5315ffc2802575fdc47e36
|
|
| MD5 |
9493a00c3181f1c83a34447186eafcc5
|
|
| BLAKE2b-256 |
bc476e0fd1d4b6ac848c9c4eb7493665716ec9c54dbc6b1e7f8c59b9e1620ec5
|
Provenance
The following attestation bundles were made for specleft-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on SpecLeft/specleft
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
specleft-0.2.1-py3-none-any.whl -
Subject digest:
1b06afb1aaecc3e6970a34f614a461038259399cee5315ffc2802575fdc47e36 - Sigstore transparency entry: 938690771
- Sigstore integration time:
-
Permalink:
SpecLeft/specleft@a64a807e9df5cf9498a6a0aad3d368b5a9ca7fa2 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/SpecLeft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a64a807e9df5cf9498a6a0aad3d368b5a9ca7fa2 -
Trigger Event:
release
-
Statement type: