.speccraft harness · signalcue

How a development session executes

One product repo carries its own trust-graded knowledge base in .speccraft/. Every coding session — Claude Code, Codex, or OpenCode — runs the same loop: ground in ratified truth, build, capture judgment, commit through the guard, and let the machine re-measure the world. Three parts: install the harness once, bootstrap the KB's judgment, then every session runs the steady-state loop.

briefrecall → build → decide/diverge → commit ⛔lane guardship loop: drift → re-pin → harvest → kb: commit → queue → founder ratifies → feeds next session
part i · installation

From bare repo to armed harness

Two entry points: kbforge-init.sh <repo> for a new product (runs P1–P4 end to end), session-kit/install.sh to re-arm a fresh clone. Everything mechanical; under an hour, mostly harvesters running.

PhaseWhat runsOutputFrequency
P0 · Toolingkb-forge lives centrally at ~/.speccraft/kb-forge (python3, git; optionally ruff)the product-agnostic factoryonce per machine
P1 · Scaffoldkbforge-init.sh /path/to/repo creates the .speccraft/ skeleton; human edits kbforge.yaml — components and risk_paths (the auth/money/truth patterns that deserve paranoia)lanes: kb/derived · inferred · normative · decisions, ledger/, QUEUE.mdonce per product
P2 · Mechanical seedseed0 + assume0 + dup0 — deterministic harvesters, no LLM, reading a git archive snapshot, never the working treekb/derived/ @ pin: routes, models, tests, churn, decision residue, duplicate candidatesminutes; re-runs every commit
P3 · Wire sessionsinstaller appends the AGENTS.md KB section (developers own the rest of the file), ensures CLAUDE.md → @AGENTS.md, installs the four speccraft-* procedures to .claude/skills/ + .agents/skills/ + .opencode/commands/, generates KB-STATUS.mdtracked — travels with every cloneonce per product
P4 · Arm the clonegit hooks (pre-commit lane guard, post-commit ship loop) + .claude/settings.local.json (Claude live hooks)untracked by design — git does not version hooksevery fresh clone / machine

An unarmed clone loses automation, not correctness: the KB, rules, and procedures are tracked and present; only the hooks need re-arming — until then, CI running the same lane check is the backstop.

part ii · kb building

The judgment bootstrap — where the KB earns its trust

Installation captures what a machine can know; this phase captures what only the creator knows. Human-paced, run once per product, in this order — deterministic harvest always precedes generative interpretation, and nothing enters ratified except through the founder.

B1

Interview the creator

founderagent

Short question rounds capture identity, stage, monetization, and the invariants — the facts no repo scan can produce. Answers land in the founder's own words as kb/normative/00-product-intent.md and 01-invariants.md (INV-1…5), provenance elicited: code changes can never invalidate them, only diverge from them.

B2

Extraction passes

agent

Agents read the repo only at the pin and draft the maps every future session will lean on: strategy rationale from docs, the capability map (marketing promises vs actual handlers), data sources ("do we already have this data?"), and integrations (why each exists, which vendor capabilities are used, who depends on what). Every claim cited path:line @pin; everything enters as pending-ratification.

B3

Assumption excavation

machineagent

Brownfield code has lost its tradeoffs; the residue hasn't. assume0 harvests the scars — frozen constants, timing values, swallowed exceptions, deleted files, reverts — and an agent turns the most decision-laden into hypothesis cards: assumption, evidence, implicitly rejected alternative, cost if wrong, and one question the founder can answer in a sentence.

B4

Consistency excavation

machineagent

dup0 + linters harvest candidates; an agent classifies them — contradiction, duplicate-debt, deliberate variation, or noise — and drafts proposed conventions. A norm binds only once ratified: rejected norms are recorded too, so no agent proposes them again.

B5

Confrontation & ratification

founder

The batches land in QUEUE.md as numbered, evidence-anchored questions — a sitting of twenty answers, not an essay. speccraft-ratify walks them: facts promote to ratified, hypotheses get killed on the record, divergences get ruled (fix-code | fix-model | accepted-deviation) into ledger/. From here the ratchet is closed: the steady-state loop below keeps the KB honest commit by commit.

part iii · steady-state execution

The seven stages of one unit of work

Stages 0–3 are the working session; stage 4 is the chokepoint; stages 5–6 run after the session, one automatic and one human-paced.

0

Session start — the briefing

hookagent

The agent opens in the repo and learns the KB exists before writing a line. Claude Code gets a live SessionStart injection; Codex and OpenCode read the same facts from AGENTS.md.speccraft/KB-STATUS.md, which the ship loop keeps current as of the last commit.

KB pin: 304da09 | last code commit: 304da09 (in sync)
Open adjudication items: 13 (.speccraft/QUEUE.md)
Ratified invariants: INV-1 immutable calls ledger · INV-2 hedged advice line · INV-3 signalcue.io · INV-4 best-effort alerts
1

Ground the task — speccraft-recall

agent

Before touching a module, the agent walks the memory palace: anchors on every KB fact are matched against the files about to change, returning facts in trust order. Ratified facts are restated as constraints in the plan. NO COVERAGE on a risk path is a stop sign — check the data-source and integration maps for existing capability, record the gap, then proceed.

$ python3 ~/.speccraft/kb-forge/recall.py --config .speccraft/kbforge.yaml \
    --files backend/worker/tasks/generate_velocity_whisper.py
[ratified        ] kb/normative/01-invariants.md  <- backend/worker/tasks
[pending-ratification] kb/inferred/08-consistency.md  <- backend/worker
2

Build — with facts arriving on contact

agenthook

Normal coding. In Claude Code, every Edit/Write on a product file fires a PostToolUse hook that injects the anchored facts for exactly that file — including into subagents, which prose instructions can't reach. Attempts to edit founder lanes are denied at edit time. Codex and OpenCode rely on the procedures plus the git guard downstream.

3

Judgment moments — speccraft-decide / speccraft-diverge

agent

speccraft-decide: the moment a tradeoff is made — a threshold fixed, a failure tolerated, an alternative rejected — it lands as an append-only ADR in .speccraft/kb/decisions/. "Arbitrary" is a valid rationale; invented ones are not. speccraft-diverge: if the task conflicts with a ratified fact, the conflicting part stops, the divergence is filed in QUEUE.md with evidence, and a TODO(speccraft-diverge #N) marks the hole. Sessions never self-ratify.

4

Commit — the chokepoint

git hook

The pre-commit lane guard runs for every tool and every human. Staged changes to kb/normative/, kb/derived/, or ledger/ are rejected unless the commit carries KB_RATIFY=1 (a founder ruling) or KB_SHIPLOOP=1 (the loop's own re-pin). Prose instructions can be ignored; this cannot.

$ git commit -m "feat: fix whisper tier gating"
KB lane guard: these staged paths are founder/machine lanes:
  .speccraft/kb/normative/01-invariants.md
Agents: unstage them and propose via .speccraft/QUEUE.md (speccraft-diverge).
5

Ship loop — the world gets re-measured

machine · no llmgit hook

Fires automatically on every code commit, backgrounded, deterministic. Order matters: drift runs against the old pin first — subtractive drift (cited lines changed → demote to challenged) and additive drift (new integrations, constants, swallowed exceptions the KB doesn't cover). Then seed0 re-pins, assume0/dup0 re-harvest residue, the status file refreshes, and the loop commits .speccraft/ as a kb: commit. Guards: KB-only commits never re-trigger it; worktree commits skip; a lockfile collapses bursts.

drift  pin 304da09 → last code commit <new> · stale citations → QUEUE, new surface → QUEUE
seed0  re-pin derived layer @ new sha (snapshot, never the dirty tree)
assume0/dup0  re-harvest decision residue + duplicate candidates
kb-status  refresh KB-STATUS.mdgit commit "kb: ship-loop re-pin @<sha>"
6

Adjudicate — speccraft-ratify

founder

Human-paced, not commit-paced. The founder walks QUEUE.md — divergences, confrontation batches, staleness flags — one item at a time, highest consequence first. Rulings land in their lanes: facts promote to kb/normative/, divergences to ledger/DIV-* with fix-code | fix-model | accepted-deviation, conventions gain scope. The commit carries KB_RATIFY=1, and every future session's stage 0 inherits the result. This is the only door into ratified truth.

enforcement model

Three layers, by guarantee strength

Instruction conflicts can degrade coverage; they can never degrade correctness — the guarantees don't live in prose.

LayerMechanismIf an agent ignores it
Guaranteesgit pre-commit lane guard · post-commit ship loop — fire for every tool and every humanIt can't. Commits to founder lanes are rejected; write-back runs regardless.
AwarenessAGENTS.md KB section (all three tools) · KB-STATUS.md auto-refreshed briefing · Claude SessionStart injectionFacts still arrive on contact (Claude) or at the git chokepoint; the agent just works less informed.
Proceduresspeccraft-recall · speccraft-decide · speccraft-diverge · speccraft-ratify — Claude skills, Codex prompts, OpenCode commands, one sourceCoverage loss: decisions go uncaptured, gaps unfiled — caught later by drift and excavation, at higher cost.
trust lifecycle

How a fact earns (and loses) authority

derivedmachine-harvested, certain at pin — regenerated, never argued with
pending-ratification ratifiedfounder ruling via QUEUE — the only promotion path
ratified challengeddrift or contradiction → re-verify or demote; never silently updated

Elicited facts (the founder's own words) are never invalidated by code changes — only flagged when new code diverges from them. Decisions are append-only; a reversal is a new record citing the old one.

tool matrix

Same loop, three agents

CapabilityClaude CodeCodex CLIOpenCode
Rules at session start CLAUDE.md → @AGENTS.md + live briefing injection AGENTS.md → KB-STATUS.md AGENTS.md → KB-STATUS.md
Procedures skills (.claude/skills/) /speccraft-* prompts /speccraft-* commands (.opencode/)
Facts injected on edit PostToolUse hook, incl. subagentsprocedure + git guardplugin port possible
Lane protection✓✓ edit-time deny + git guard git guard git guard
Write-back on commit ship loop ship loop ship loop
write lanes

Who may write where

LaneWriterContent
QUEUE.mdagents (append) · founder (rule)the one adjudication queue — divergences, gaps, batches, staleness
kb/decisions/agents · founderADR-lite tradeoffs, captured at decision time, append-only
kb/inferred/agentshypothesis drafts — always pending-ratification
kb/normative/founder only (KB_RATIFY=1)ratified intent, invariants, conventions
kb/derived/machine only (KB_SHIPLOOP=1)harvested facts @ pin — regenerated wholesale
ledger/founder only (KB_RATIFY=1)ruled divergences with revisit triggers