Metadata-Version: 2.4
Name: spezi-kit
Version: 0.1.0
Summary: Check and manage the specs of a project: the spezi command and its MCP server.
Author: Frederik Beimgraben
License-Expression: MIT
Project-URL: Repository, https://github.com/frederikbeimgraben/spezi
Project-URL: Issues, https://github.com/frederikbeimgraben/spezi/issues
Project-URL: Changelog, https://github.com/frederikbeimgraben/spezi/releases
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: jsonschema>=4
Requires-Dist: mcp<3,>=2
Requires-Dist: pygls<3,>=2.1
Requires-Dist: pyyaml>=6
Requires-Dist: questionary>=2
Requires-Dist: rich>=13
Requires-Dist: rich-argparse>=1.8
Requires-Dist: tomlkit>=0.13
Dynamic: license-file

# Spezi

A starter kit for specs: the binding rules of a software project, one rule in one Markdown file.
Its command `spezi` checks and manages the specs of a project. The command comes as a Nix flake, as the package `spezi-kit` on PyPI and as a binary.

## What it does

- It gives each rule a fixed number, for example `000024`. Code and text refer to a rule with `(spec 000024)`, and to a rule of a different repository with `(spec github.com/<owner>/<repo>:000024)`. A reference can also name the rule at a tag, a branch or a commit: `(spec @v0.1.0:000024)` or `(spec github.com/<owner>/<repo>@v0.1.0:000024)`.
- It records the approval of each rule: `draft`, `approved`, `replaced` or `removed`.
- It makes each change start as a spec. Code starts after the owner approves the spec.
- It checks every spec in CI, and it writes the index.
- It gives agents an MCP server to read, find and create specs.

## Spec kinds

| Kind | ID | Folder | Holds |
| --- | --- | --- | --- |
| functional | `F` | `specs/requirements/functional/` | What the product must do. |
| non-functional | `NF` | `specs/requirements/non-functional/` | How well the product must do it. |
| protocol | `P` | `specs/protocols/` | One data format, with a JSON Schema and an example. |
| structure | `U` | `specs/structures/` | One UML diagram in Mermaid, with an element table. |
| style | `S` | `specs/style/` | How code and tests must look. |
| convention | `C` | `specs/conventions/` | How specs must look. |
| workflow | `W` | `specs/workflow/` | How people and agents must work. |
| agent | `A` | `specs/agents/` | What only an agent must do or must not do. |
| decision | `D` | `specs/decisions/` | One design decision with its alternatives. |

One rule tells which kind a rule gets (spec 000004).

## Layout of a project

| Path | Content |
| --- | --- |
| `specs/` | The rules of the project in the kind folders (spec 000051), and `README.md`, the index (spec 000007). |
| `specs/.upstream/<host>/<group>/.../<repo>/` | The rules of a different repository, for example of this kit (spec 000048). |
| `specs/.templates/` | The templates for a new spec (spec 000008). |
| `spezi.toml` | The settings, with the switches of the optional parts in `[features]` (spec 000078, 000084). |
| `spezi.lock` | The commit and the hash of each copy below `specs/.upstream/` (spec 000082). |
| `.claude/skills/spezi-*` | Skills for agents. |
| `.mcp.json` | The MCP server `spezi`. |
| `.github/workflows/spezi.yml`, `.gitlab/ci/spezi.yml` (included from `.gitlab-ci.yml`) or `.forgejo/workflows/spezi.yml` | The CI job. |
| `AGENTS.md`, `CLAUDE.md` | The rules for agents, written by `spezi install`, and the import `@AGENTS.md` (spec 000079). |

## Commands

There are three ways to run the command:

| Way | How |
| --- | --- |
| Nix | `nix run github:frederikbeimgraben/spezi/<commit> -- <command>` |
| pip | Python 3.13 or newer. `pipx install spezi-kit`, or `pip install spezi-kit` in a virtual environment, then `spezi <command>`. |
| Binary | Load `spezi-linux-x86_64`, `spezi-linux-arm64` or `spezi-windows-x86_64.exe` from the [releases](https://github.com/frederikbeimgraben/spezi/releases). Rename it to `spezi` (`spezi.exe` on Windows), make it executable with `chmod +x spezi` and put it in a folder of `PATH`. Then run `spezi <command>`. |

| Command | Effect |
| --- | --- |
| `check` | Checks the specs and the references to rules. It changes no file. |
| `install` | Loads each copy that does not agree with `spezi.lock`, writes each missing file of the kit, the index and `AGENTS.md`, then checks. It changes no version (spec 000083). |
| `init [<dir>] [--forge github\|gitlab\|codeberg]` | Asks for the settings and the known repositories to add, then adds the kit to a project. It writes no `flake.nix`. For a project with a `flake.nix`, it shows the lines to add (spec 000370). |
| `update [<repo> [<ref>]] [-r]` | Resolves the `ref` of each repository, or of one, again and replaces its copy. With `<ref>`, it first sets `ref` in `spezi.toml`. `<repo>` can be `kit`. For the kit, it also replaces the templates, the skills, the CI file and the MCP server entry. It tells the new commit for the input `spezi` of a `flake.nix` (spec 000300). |
| `add [<repo> [<ref>]] [--include <folder>]... [-r]` | Adds the copy of the rules of a different repository, at `<ref>` or at its tag with the highest version. Without `<repo>`, it offers the known repositories of `repositories/` (spec 000381). |
| `configure [<key> <value>]` | Changes `spezi.toml` in a menu, or sets one key such as `features.mcp false`, then installs (spec 000086). |
| `remove <repo>` | Removes the copy of a different repository, then installs (spec 000087). |
| `new <kind> <area>/<topic> <name> "<title>" --scope <path>... [--owner <login>]` | Makes a new spec from its template, with the next number and the paths of `scope`. |
| `resolve <id>` | Prints the path of a rule, for example `specs/conventions/specs/format/000017_spec-reference.md` for `000017`. |
| `show <id>` | Prints the full text of a spec. |
| `list [<kind>]` | Lists every rule, or only the rules of one kind. `<kind>` is a kind name or its letter, for example `functional` or `F`. |
| `search <text>` | Lists the rules that hold a text. |
| `setup-ide zed\|code` | Writes the extension of the language server for Zed or VS Code to `.zed/spezi/` or `.vscode/spezi/` (spec 000089). |
| `lsp` | Runs the language server on stdin and stdout. It shows the errors of the check at their line, and the rule of a reference in a hover (spec 000088). |
| `mcp` | Runs the MCP server on stdin and stdout. It has the tools `check`, `install`, `resolve`, `show`, `list`, `search`, `new`, `configure` and `remove`. |

Each command except `mcp` and `lsp` takes `--raw` for plain text with one line for each error, or `--json` for JSON (spec 000080). `spezi --version` prints the version of the program.

On a terminal, `init`, `add`, `update` and `configure` ask questions. `-y` takes the proposals instead, as does a run without a terminal (spec 000085). `add` and `update` also ask which upstreams of an upstream to copy, from its `spezi.lock`. `-r` takes each of them without a question. Without `-r`, a run without a terminal takes none. `init` takes each of them for the known repositories that the user chooses. `repo` in `spezi.toml` names the project, so that a cycle of upstreams stops (spec 000092).

A project runs the command at the commit of the kit in `spezi.lock`. `init` and `update` write this commit into the CI file. The entry in `.mcp.json` starts the command in the same way as the command that writes it: with Nix at the commit, with pip or pipx as `spezi`, and a binary on `PATH` as `spezi` (spec 000377).

## Add the kit to a project

```sh
cd <project-dir>
nix run github:frederikbeimgraben/spezi -- init
```

Without Nix, install the command with pipx or pip, or as a binary (see [Commands](#commands)), and run `spezi init`.

A project numbers its own rules from `000001`. For a project that has its own specs, follow the skill [spezi-adopt](https://github.com/frederikbeimgraben/spezi/blob/main/.claude/skills/spezi-adopt/SKILL.md).

## Contents of this repository

| Path | Content |
| --- | --- |
| `specs/conventions/specs/` | The conventions for specs. Read them first. |
| `specs/workflow/specs/` | The rules for the change process. |
| `specs/agents/` | The rules for agents. |
| `specs/requirements/` | The requirements of the command `spezi`. |
| `specs/.upstream/` | The copies of the upstreams. The copies of spezi-python and spezi-functional hold the code style. |
| `specs/structures/` | Two example structure specs. |
| `repositories/` | The list of the known repositories with rules (spec 000381). |
| `src/spezi/` | The command `spezi`. |
| `tests/` | The tests of the command. |
| `flake.nix` | The Nix flake with the package, the app and a dev shell. |

All text in this kit follows ASD-STE100 Simplified Technical English (spec 000025).
