Skip to main content

Agentic spec-to-code builder: turn a SPEC.md into an installable, tested package.

Project description

spek logo

spek

Turn a SPEC.md into an installable, tested Python package.

spek is a small LLM-powered coding agent. You write a markdown file describing what you want, point spek at it, and a few minutes later there's a working Python package on disk that builds and passes its own tests.

For the design rationale and a worked example end-to-end, see Here is how I built a simple coding agent.

Requirements

  • Python 3.11+
  • uv (recommended) or pip
  • A running Docker daemon — spek runs every shell command and file write inside a sandboxed container. If Docker isn't running, spek build refuses to start.
  • An Anthropic API key in the environment (ANTHROPIC_API_KEY).

Install

The PyPI distribution is spek-cli; the binary is still spek:

uv tool install spek-cli      # recommended: isolated, on $PATH
# or:
pip install spek-cli

Verify:

spek --help

Configure credentials

spek looks for .env in the current directory or any ancestor of the spec file. Copy the template and fill it in:

cp .env.example .env
$EDITOR .env                  # paste your ANTHROPIC_API_KEY

You can also override the model:

ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_MODEL=claude-sonnet-4-6        # optional
ANTHROPIC_BASE_URL=https://api.anthropic.com   # optional, for proxies

Quick start

Two commands:

spek init my-project                           # scaffold SPEC.md skeleton
$EDITOR my-project/SPEC.md                     # describe what you want
spek build my-project/SPEC.md \
  --workdir my-project --confirm-plan          # run the agent

When the run finishes green, my-project/ contains a normal Python project (pyproject.toml, src/, tests/) you can use immediately:

cd my-project
uv run pytest                                  # tests pass
uv run <your-cli> --help                       # the binary you specified

A real example

The repo ships with a worked example at examples/weather-tool/SPEC.md:

spek build examples/weather-tool/SPEC.md --workdir /tmp/weather

A run produces a working weather-converter CLI with 27 tests passing. The full session log and final plan are described in BLOG.md.

CLI

spek --help

usage: spek [-h] {init,build} ...

  init     Scaffold an empty SPEC.md and .spek/.
  build    Run the agent against a SPEC.md spec.

Useful spek build flags:

Flag What it does
--workdir DIR (required) Directory for the package; bind-mounted at /work inside the container.
--fresh Wipe .spek/ before starting. Use after significant spec changes so the agent re-plans from scratch.
--confirm-plan Pause after the plan phase and require approval (or edit) of .spek/plan.md. Recommended.
--max-steps N Cap on tool calls. Default 120.
--max-seconds N Wall-clock cap. Default 1800.
--quiet Suppress progress output. The journal still records every event.

What spek writes

Everything is scoped to the working directory. After a successful run:

<workdir>/
├── SPEC.md                   # your input (untouched)
├── pyproject.toml            # generated
├── src/...                   # generated
├── tests/...                 # generated
└── .spek/
    ├── journal.jsonl         # full event log (resume + audit)
    ├── plan.md               # the plan (numbered checklist)
    └── command_config.json   # build/test/lint commands the agent uses

There is no global state and no ~/.config/spek. Wipe .spek/ and the next run starts from scratch.

Development

make install       # uv-managed venv with dev extras
make test          # pytest
make lint          # ruff + black --check
make typecheck     # mypy strict
make build         # sdist + wheel into ./dist

Full target list: make help.

License

MIT.

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

spek_cli-0.1.1.tar.gz (875.8 kB view details)

Uploaded Source

Built Distribution

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

spek_cli-0.1.1-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

Details for the file spek_cli-0.1.1.tar.gz.

File metadata

  • Download URL: spek_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 875.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for spek_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bf95d9db1d5a3d40fa108e70470bc504f3ab9bcbe32aa760c9874959b8d730cc
MD5 064cbd8c54d8090ec4da4c2330d572fe
BLAKE2b-256 c245d940b706de53590e162a9265f81cf3a85e436cd8e4d420112bc59f168d43

See more details on using hashes here.

File details

Details for the file spek_cli-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spek_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 47.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for spek_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f135dd11acdf771dbb9d8cca98944591e812360424d52c2496581b6f00134e7
MD5 f22c50fad7683c95e0effa32c4b52999
BLAKE2b-256 5cdfeb20320dd1fb4b90a2d6f39678af1c990870cb1b70e457c38c21066f03c0

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