Specifications as a graph, in one file, in your Git repository.
Requirements, decisions, risks, tests – any types you define – with typed links between them. People edit them in a graphical editor in the browser. AI agents read them with queries and change them with commands. Every change is signed, and the history is Git.
specgraph is a requirements and traceability model. It is not a task or agent orchestrator. It holds what must be true, why, and how that is checked. It does not plan work, run agents or call a language model.
- Needs only Python,
gitandssh-keygen. No packages, no server, no database, no account. - Everything stays on your machine. MIT licence.
Version 0.6.0, an early version: it works for its author, on Windows with Python 3.13. Linux and macOS should work but are not checked. Nobody independent has reviewed the signing and the security: see Good to know.
You need Python and Git. No SSH key and no account: this only looks.
git clone https://github.com/terablade2001/specgraph.git
cd specgraph
pip install uv
python -m uv venv --python 3.13 .venv
Activate the environment, in every new terminal:
| Windows | Linux, macOS, Git Bash on Windows |
|---|---|
.venv\Scripts\activate |
source .venv/bin/activate (Git Bash: source .venv/Scripts/activate) |
Open the model that specgraph keeps of itself:
python sg.py --file specgraph-model.json serve --read-only
Your browser opens. Start with the diagrams in the folder Start here: double-click one. Ctrl+C in the terminal stops it.
See how things hang together. A link belongs to the model, so it appears on every diagram that shows both ends. Trace on an element shows what it leads to and what depends on it, across the whole model.
Find things. Search results are grouped by type, and everything on the diagram that was not found fades.
Check what is missing. The matrix sets any two types against each other. Coverage rules, such as "every approved requirement has a test", report gaps under Check.
Also: your own types, statuses and fields; diagrams on diagrams; folder locks; undo; merging of parallel work, item by item; history of every element in words. All of it is in the user guide.
Changes are signed with your SSH key, so it must be loaded in ssh-agent (one key only). In the folder of your repository, in a
terminal with the environment active (Windows: Git Bash):
eval "$(ssh-agent -s)"
ssh-add
python sg.py init
python sg.py install-hooks
git add specmodel.json .gitattributes
git commit -m "Start the model"
python sg.py serve
Copy sg.py and the folder specgraph/ into your repository first, or stay in this one to play. Others run install-hooks once
and send you their public key; you add them under Users. No key yet, or a message you don't understand:
setup in the user guide.
Agents ask the model through sg.py and never open the file: that is exact, cheap on tokens, and works at 10 000 elements. They
change it only with sg.py apply, which checks and signs like the editor. Tell them so, for example in your CLAUDE.md:
Specifications are in specmodel.json. Never open or edit that file. Read it with sg.py (sql, search, show,
trace, impact; AI labels when `sg.py ai status` shows some) and change it with sg.py apply,
as docs/AGENTS.md of specgraph says.
Then ask in plain words, for example on this project's own model:
| You ask | The agent uses |
|---|---|
| What breaks if we change REQ-STO-06? | impact, trace |
| Which approved requirements have no test? | sql (coverage, links) |
| Explain everything about protecting people from losing work | AI labels, then show |
| Do any decisions about locking contradict each other? | AI labels, links, notes |
| Add a requirement for X and link it to its feature | apply |
Words differ: "confirmation before deleting", "undo" and "atomic writes" are all about not losing work. The AI layer is an
optional second file, specmodel.ai.json, in which an agent notes the meaning of each element:
- Vocabulary – a short list of concepts, each with a definition ("Data loss protection: not losing work by accident …").
- Labels – 0 to 3 concepts per element.
- Findings – an agent reviews the specs concept by concept and reports duplicates, contradictions and gaps. You decide.
Labels find, specs answer: they lead the agent to the right elements, and it then reads those. specgraph itself never calls a language model; you start the agent you like. On a test model of 1 000 elements, agents found 87% of the elements of a subject with labels, and 37% without (measurements).
See it in the editor. The tab AI Layer shows the labels, rules and findings of an element. A click on a concept lists its elements, and everything else on the diagram fades.
What to run, and when. These are rules of thumb, not measurements.
| When | How often | Say to your agent | |
|---|---|---|---|
| Build the vocabulary | The model has its main subjects, from about 50–100 elements. Smaller models rarely need it | Once | "Build the AI vocabulary with sg.py ai todo --vocab" |
| Check the vocabulary | A new subject came in, agents find no fitting concept, or one concept fits almost everything | Before a release, or when the model grew by about a quarter | "Check whether the AI vocabulary still fits" |
| Label | sg.py ai status shows unlabelled or stale above 0 |
After a batch of changes, before you merge the branch | "Label what is new or stale with sg.py ai todo" |
| Review the specs | Labels are up to date | Before a release, or after big changes | "Review the specs with sg.py ai review" |
- A label pass only asks for new and changed elements, so it is small. Changing a concept makes its labels stale: change the vocabulary rarely, and before labelling.
- Use a strong model for the vocabulary and reviews. A cheaper one is enough for labels.
- Cost: about 470K tokens for the first pass over 1 000 elements, afterwards only the changes.
- The agent writes a file of operations; you read it and apply it with your key:
sg.py ai apply --ops-file FILE --model NAME. The vocabulary and findings need an administrator. Then commit the two*.ai.*files.
Everything in detail, for you and your agent: docs/AGENTS.md.
- Made with AI. Claude (Anthropic) wrote much of the code and documentation. The maintainer directs and reviews the work but cannot guarantee to have understood or verified every line. Claude's own account: AI-Disclaimer.md. "As is", without warranty (LICENSE).
- For people who trust each other. Signatures and hooks show accidents and changes made outside the tool. Someone who may push can also change the tool or the history: protect the branch if you need more. What the signatures prove and do not prove: ADR-003 in docs/ADRS.md.
- Security. The editor listens only on your machine, needs a one-time token and never runs content of a model. The tool never reads a private key. The security review covers 0.6.0.
- Repositories you do not trust.
serve --read-onlystarts no program that such a repository names. Other commands start none of the known ones, but Git itself obeys the settings in its.gitfolder: do not work in an unpacked or shared one you do not trust. A clone made by you is fine. - Hooks can be skipped. Run
python sg.py audit --allnow and then; it checks the whole history. - Never edit the model file by hand. If it happens:
git checkout -- specmodel.json, orpython sg.py adoptto take responsibility for the change.
| docs/GUIDE.md | User guide: setup, editor, branches, checks, several models |
| docs/AGENTS.md | For AI agents: reading, changing, labelling, reviewing |
| docs/FORMAT.md | The file format |
| docs/ADRS.md | Decisions and their reasons |
| CHANGELOG.md | What changed |
specgraph-model.json |
specgraph's own specifications, with diagrams and AI labels |
specmodel.example.json |
A small example: a library app, 26 elements |




