README
¶
kb
Zero-DB, git-anchored project memory for AI coding agents.
Stop CLAUDE.md and AGENTS.md from rotting. Keep living domain specs in plain Git-tracked Markdown, catch spec-to-code drift via Git, isolate old postmortems, and aggregate multi-repo workspaces — in a single static Go binary.
English · Русская документация · llms.txt
Install in 10 Seconds
# macOS & Linux — interactive TUI installer (downloads verified release binary)
curl -fsSL https://raw.githubusercontent.com/mdwitr0/kb/main/install.sh | bash
# Homebrew (macOS & Linux)
brew install mdwitr0/tap/kb && kb setup
# Go toolchain
go install github.com/mdwitr0/kb/cmd/kb@latest && kb setup
# Agent Skills registry (skills.sh)
npx skills add mdwitr0/kb
Headless install for dotfiles, Dockerfiles, or CI:
curl -fsSL https://raw.githubusercontent.com/mdwitr0/kb/main/install.sh | bash -s -- --yes --lang en
Sound Familiar?
Every team using Claude Code, Codex, Cursor, OpenCode, Windsurf, or Pi hits the same four walls after a few weeks:
- The 2,000-line
CLAUDE.md/AGENTS.mdgraveyard. Every bug adds another warning. Nobody deletes obsolete rules. Half your context budget disappears before the agent reads a single source file — andCLAUDE.md,AGENTS.md, andGEMINI.mddrift apart. - Postmortem poisoning. An agent runs
rg "timeout"acrossdocs/, lands onoutage-2026-10.md, and treats last autumn's broken config as today's production contract. - Silent spec-to-code drift. Someone refactors
VerifyHMACSignatureinpay.goand merges the PR. The Markdown spec still describes last month's signature format, so the next agent writes broken webhook code. - Multi-repo / microservice split-brain. Your workspace has 35 service repos, each with a dusty
README.mdfrom 2024 that contradicts how the platform works today.
Vector RAG and MCP memory servers try to solve this by adding Docker containers, SQL/graph databases, background daemons, and embedding API keys — turning plain documentation into opaque state you cannot git diff in a pull request.
How kb Fixes It — With Plain Markdown & Git
kb keeps every piece of project memory as regular Markdown files inside your repository and enforces structure with fast CLI gates (< 40 ms, zero daemons, zero external APIs):
- Git-anchored drift detection (
anchors+verified_at): Every domain spec points to real files or Go/TS/Python/Rust symbols (services/billing/pay.go#VerifyHMACSignature) and stampsverified_at: YYYY-MM-DD.kb checkflags deleted symbols (anchor-symbol-missing) and commits touching anchored code afterverified_at(code-drift). - Hot canon vs. cold archive: Active truth lives in
kb/specs/andkb/decisions/. Historical postmortems and closed delta specs live inarchive/(automatically added to.rgignore), invisible toripgrepandkb findunless--archiveis requested explicitly. - Root aggregation across nested
.gitsubrepos: In umbrella workspaces with dozens of service repos,kb findwalks upward across.gitboundaries to the rootkb.yaml.kb subprojectsandkb checkverify every subrepo is covered in rootkb/specs/and install priority rules so agents trust rootkb/over stale local subprojectREADME.mds — without modifying files inside subproject git trees. - Hard byte budgets & symlinked root mirrors:
CLAUDE.mdstays short (AGENTS.mdandGEMINI.mdsymlink to it),kb/INDEX.mdis auto-generated from frontmatter, andkb checkfails pre-commit if files exceed configured budgets.
flowchart LR
A["Agent starts in root or nested subrepo"] --> B["CLAUDE.md / AGENTS.md<br/>(short, symlinked, budgeted)"]
B --> C["kb find 'webhook retry'<br/>(< 40 ms, EN/RU stems + synonyms)"]
C --> D["kb/specs/*.md + kb/decisions/*.md<br/>(active truth only)"]
D -- "anchors + verified_at" --> E["kb check --strict<br/>(git log & symbol verification)"]
F["archive/reports & archive/features<br/>(.rgignore — cold history)"] -. "only with --archive" .-> C
How kb Compares
| Capability | Raw CLAUDE.md / AGENTS.md |
Fission-AI/OpenSpec |
steveyegge/beads (bd) |
Vector / Graph MCP Memory | kb |
|---|---|---|---|---|---|
| Primary job | Static bootstrap prompt | Change proposals & delta specs | Task graph & issue queue | Unstructured chat/doc recall | Living domain specs & drift-checked project memory |
| Storage | Single Markdown file | Plain Markdown | Dolt SQL / JSONL | Vector / Graph DB + daemon | Plain Markdown (git diff-able) |
| Detects code-to-doc drift | No | No | N/A (tracks tasks) | No | Yes (git log vs verified_at + #Symbol check) |
| Isolates old postmortems | No | Archives change folders | Closes issues | Often retrieves stale chunks | Yes (.rgignore + active-only kb find) |
| Multi-repo root override | Manual copy-paste | Per-repo | Per-repo / Dolt | External index | Built-in (kb subprojects + upward root walk) |
| Token-safe brownfield onboarding | Manual | Manual / slash cmd | N/A | Full-repo embedding | Built-in (kb onboard with token estimate) |
| Runtime dependencies | None | Node.js (npm) |
Go / Dolt | Docker + DB + API keys | Single static binary (0 runtime deps) |
Using
kb+Beadstogether: They solve orthogonal halves of agent memory. UseBeads(bd) for execution state (what tasks exist, what blocks what) andkbfor system knowledge (how billing, auth, and deployment work today, verified against Git).
60-Second Quickstart
1. Configure your AI coding agents (kb setup)
kb setup opens a keyboard-friendly TUI (supports both QWERTY and ЙЦУКЕН layouts out of the box) that detects installed harnesses and wires up the kb skill, /kb-onboard slash command, and root-precedence rules:
- Claude Code (
~/.claude/skills/kb+~/.claude/rules/kb.md+/kb-onboard) - OpenAI Codex (
~/.codex/skills/kb+~/.codex/AGENTS.md) - OpenCode (
~/.config/opencode/skills/kb+AGENTS.md) - Pi (
pi-coding-agent) (~/.pi/agent/skills/kb+APPEND_SYSTEM.md) - Antigravity (
agy) (~/.agents/skills/kb+~/.gemini/config/rules/kb.md) - Cursor / Windsurf / Cline (
~/.agents/skills/kb)
2. Initialize & onboard an existing codebase (kb init + kb onboard)
At your repository or multi-repo workspace root:
kb init --name my-platform --hook
kb onboard
kb onboard scans your workspace before invoking any LLM, prints the exact Markdown count and estimated input token cost, and lets you choose:
- Mode:
Docs-first(default — consolidates existing.mdfiles and moves dated postmortems toarchive/reports/without reading source code wholesale, saving tokens) orDeep audit(cross-checks undocumented code too). - Model & effort: Pick a fast, cheap model (e.g. Haiku / Flash / Mini) instead of burning flagship quota.
- Permissions:
Scoped(kb/+kb.yamledits only, default),Yolo(--yolo), orInteractive prompt.
Already inside an agent chat? Just tell your agent:
Run kb onboard --prompt and populate kb
Workspace Layout & Spec Format
my-platform/
├── CLAUDE.md # Short bootstrap (< 20 KB); AGENTS.md & GEMINI.md symlink here
├── kb.yaml # Domains, byte budgets, EN/RU synonyms, mirror config
├── kb/
│ ├── INDEX.md # Auto-generated map of active specs & decisions (kb index)
│ ├── inbox.md # Fast flock-safe scratchpad for facts discovered mid-task (kb note)
│ ├── specs/ # Living domain truth ONLY (overwritten in place, never dated logs)
│ │ └── billing.md
│ └── decisions/ # Architectural "why" & bans (status: active | superseded)
├── changes/ # Active feature deltas (ADDED / MODIFIED / REMOVED)
└── archive/ # Cold postmortems & synced deltas (hidden via .rgignore)
Each file in kb/specs/ carries lightweight YAML frontmatter:
---
title: "Billing & Webhooks"
domain: billing
kind: spec
status: active
triggers: ["billing", "webhook", "retry", "hmac"]
anchors:
- "services/billing/cmd"
- "services/billing/pay.go#VerifyHMACSignature"
verified_at: 2026-12-04
---
For every path in anchors, kb check locates the nearest .git repository (supporting both monorepos and nested multi-repo checkouts), verifies #Symbol still exists in source files, and compares the latest Git commit touching that path against verified_at.
CLI Reference
| Command | Description |
|---|---|
kb setup [--yes] [--lang en|ru] [--agents list] |
Interactive TUI installer (or headless setup with --yes) |
kb init [--lang en|ru] [--name <proj>] [--hook] |
Initialize kb skeleton, symlinks, .rgignore, and optional pre-commit hook |
kb onboard [--mode docs|deep] [--yolo] [--model <id>] [--prompt] |
Estimate token cost, pick model & permission tier, and migrate docs into kb/ |
kb find [--domain <id>] [--archive] <query> |
Search active canon sections (< 40 ms, EN/RU stemming + project synonyms) |
kb note [--domain <id>] <fact> |
Concurrency-safe (flock) one-line append to kb/inbox.md |
kb index |
Rebuild kb/INDEX.md from canon frontmatter and extra_canon globs |
kb check [--strict] [--quiet] |
Verify budgets, root symlinks, code anchors, git log drift, subproject coverage, and stray reports |
kb change new <slug> --domain <id> |
Scaffold a delta spec changes/<slug>/delta.md (ADDED / MODIFIED / REMOVED) |
kb change sync <slug> |
Verify verified_at update in kb/specs/<domain>.md, archive delta, and rebuild index |
kb subprojects |
Audit nested .git subprojects and check root kb/ anchor coverage |
kb status |
One-screen health summary (domains, docs, subproject coverage, errors, drift) |
kb version |
Print kb CLI version |
Tested on Small, Cheap Models (Not Just Frontier Opus)
Many agent conventions work only when an expensive frontier model follows 40 paragraphs of prose. kb includes a live end-to-end suite (make test-e2e) that spawns low-cost models (Claude Haiku, Gemini Flash-Lite) inside synthetic multi-repo sandboxes containing:
- stale local
CLAUDE.mdfiles inside nested microservice repos that contradict rootkb/specs/; - archived incident postmortems with decoy port numbers and deprecated retry limits;
- concurrent
kb notewrites andcode-driftcommits.
Small models consistently resolve the active truth via kb find in a single tool call without reading archived decoys or trusting outdated local READMEs.
(And yes — kb dogfoods itself: browse kb.yaml, kb/INDEX.md, and kb/specs/ right in this repo.)
Development
make build # Build ./bin/kb
make test # Unit tests with -race
make lint # go vet + golangci-lint
make test-e2e # Live E2E agent suite in temporary sandboxes