Skip to main content

speccraft — trust-graded knowledge base CLI (init a .speccraft/ KB in a repo)

Project description

Speccraft

A trust-graded knowledge base your codebase carries with it — so agents (and you) build on what's ratified as true, not on guesses.

License: MIT Python 3.9+ No LLM required Claude Code Codex OpenCode


Speccraft turns a repo's scattered, half-lost knowledge — intent, invariants, the reasons behind decisions, the gotchas in your dependencies, the bugs nobody wrote down — into a cited, versioned, human-ratified knowledge base that lives inside the repo (.speccraft/) and stays honest as the code changes.

It's built for the hard case — an existing (brownfield) codebase whose design rationale has already evaporated — worked by AI coding sessions across Claude Code, Codex, and OpenCode. Every greenfield project is a brownfield project in six months; run it from day one and there's nothing to reconstruct later.

Cite or it didn't happen. Nothing becomes truth except through a human.

Contents


Why it exists

Every codebase knows things nobody wrote down: why a constant is 30, which alternative was rejected, that lapsed users still get paid features, that this dependency version has a known CVE. Code records the outcome of a decision, never the decision. AI agents, lacking that context, confidently repeat known mistakes and drift from intent.

Speccraft's answer is a grounded ratchet: seed a knowledge base from human-adjudicated truth, validate every change against it, and let error be caught rather than compound.

1Cite or it didn't happen
Every claim is pinned to path:line @<commit-sha>.
2Provenance is never blurred
Each fact is tagged by how it's known: derived (machine-harvested), inferred (agent hypothesis), elicited (your own words), decision (an ADR), external (dependency knowledge, sub-graded by source).
3Nothing becomes ratified except through a human
Agents propose; you rule. A fact's trust state moves pending → ratified → challenged, never silently.
4Deterministic before generative
Anything a regex or git can harvest is harvested by a no-LLM tool that cannot hallucinate; agents only interpret, and their output enters as an unratified hypothesis.

Quickstart

pipx install speccraft-cli
speccraft init /path/to/your-repo

Want unreleased main? pipx install git+https://github.com/swshukla/speccraft.git instead.

Requirements: python3, git. No API keys, no services, no LLM calls in the tooling itself — the harvesters are pure stdlib.

speccraft init scaffolds your-repo/.speccraft/, runs every harvester (pinned to your last code commit), installs the four speccraft-* procedures for Claude Code / Codex / OpenCode, wires AGENTS.md/CLAUDE.md, arms the git hooks, and writes KB-STATUS.md.

From there:

Step Action
1 Tune .speccraft/kbforge.yaml — set components and risk_paths (auth / money / truth-critical path patterns).
2 Run speccraft-interview in a Claude Code (or Codex/OpenCode) session — the one irreducibly human step; intent and invariants land in kb/normative/ and everything downstream grounds in it.
3 Run the extraction passes, then work through .speccraft/QUEUE.md with speccraft-ratify.
4 It's self-sustaining after that. Just build — each commit runs the ship loop, drift keeps citations honest, recall grounds each task.

Go deeper: speccraft/forge/README.md (full walkthrough) · speccraft/forge/SPEC.md (system reference) · speccraft/forge/workflow-execution.html (visual tour)


What it captures

Aspect How Provenance
Structure — routes, models, tests, churn, module map deterministic harvest derived
Product intent, stage, monetization founder interview elicited
Invariants (the rules that must always hold) founder interview elicited
Capability map — what's marketed vs what the code does agent extraction inferred
Data sources — what data already flows in agent extraction inferred
Integrations — why each 3rd-party exists, what's used, who depends on what agent extraction inferred
Assumptions & tradeoffs — recovered from code "scars" residue harvest → hypothesis cards derived + inferred
Consistency — contradictions, duplicates, proposed conventions harvest + classify derived + inferred
Dependencies + version-pinned best-practices / gotchas inventory + sourced cards derived + external
Decisions — captured at the moment a tradeoff is made ADR-lite lane decision
Findings — the consolidated bug / work list flows from rulings mixed

The steady-state loop

 session start
      │
      ▼
 speccraft-recall ─── ground in ratified truth
      │
      ▼
   build  ───────────  speccraft-decide (log tradeoffs)
      │                speccraft-diverge (on conflict)
      ▼
 git commit ─── pre-commit lane guard
      │
      ▼
 ship loop: drift → re-pin → re-harvest → kb: commit → KB-STATUS refresh
      │
      ▼
 speccraft-ratify ─── founder rules the queue, occasionally
      │
      ▼
 feeds the next session

Enforcement

A git pre-commit hook keeps machine-proposed and human-ratified knowledge distinguishable: commits touching the founder/machine lanes (kb/normative/, kb/derived/, ledger/) require an explicit flag — KB_RATIFY=1 (a human ruling) or KB_SHIPLOOP=1 (the automatic re-pin).

It's not a lock against an intruder — you own the repo — it's a signature: when a fact is ratified, the git history shows a human stood behind it, so an agent can run autonomously without quietly promoting its own guesses to truth. A post-commit hook runs the ship loop on every code commit.

Sessions write only QUEUE.md, kb/decisions/, kb/inferred/, and proposed rows in findings/. Everything else is founder/machine.


Layout

your-repo/.speccraft/
├── kbforge.yaml       product profile: repo, components, risk_paths
├── KB-STATUS.md       auto-refreshed briefing (pin, open queue, invariants)
├── QUEUE.md           the one adjudication queue — rulings are git commits
├── kb/
│   ├── derived/       machine-harvested, regenerated each commit (never hand-edited)
│   ├── inferred/      agent hypotheses (pending-ratification)
│   ├── normative/     ratified intent, invariants, conventions (human-only)
│   └── decisions/     ADR-lite, captured at decision time (append-only)
├── ledger/DIV-*.md    ruled divergences (fix-code / fix-model / accepted-deviation)
└── findings/FINDINGS.md   the consolidated bug / work list

Multi-tool

One source, three runtimes.

Claude Code Codex OpenCode
Rules file CLAUDE.md (imports AGENTS.md) AGENTS.md AGENTS.md
Procedures .claude/skills/ Agent Skills standard OpenCode commands
Git hooks identical identical identical

The git hooks enforce identically regardless of which tool — or which human — makes the commit.


License

MIT — do what you like with it.

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

speccraft_cli-0.1.1.tar.gz (88.2 kB view details)

Uploaded Source

Built Distribution

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

speccraft_cli-0.1.1-py3-none-any.whl (116.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: speccraft_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 88.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for speccraft_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3978872d736a563ddedd5eaa38ee796f0c4c8fa8bb7a1caf77f317856443c48f
MD5 37cd195c683efe121cda6a515585fb1d
BLAKE2b-256 953b77df590ae45a417af011a5e03575dd2e96a1a22a1cf4469e18ba77003d7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for speccraft_cli-0.1.1.tar.gz:

Publisher: publish.yml on swshukla/speccraft

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

File details

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

File metadata

  • Download URL: speccraft_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 116.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for speccraft_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69a2146d4eb99148f9c261eef6e9c0f768fd59b5f551b4959dacd29b926fda26
MD5 de1799c10829cceac4167a4dcd5df97c
BLAKE2b-256 7859433e58a2c4687513bbda30c29ccc944653aee3329d07b0105056c29a340d

See more details on using hashes here.

Provenance

The following attestation bundles were made for speccraft_cli-0.1.1-py3-none-any.whl:

Publisher: publish.yml on swshukla/speccraft

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