$npx -y skills add mdwitr0/kb --skill en --agent claude-code
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of En?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/mdwitr0-skill-1i9fg5i)
---
name: kb
description: "Zero-DB, git-anchored project memory and living spec system (kb.yaml / kb/). Stops CLAUDE.md and AGENTS.md bloat and documentation drift: instant active-canon lookup via kb find, diff-driven requirement & code/doc reconciliation via kb grill, multi-repo subproject aggregation, cold archive isolation, delta specs via kb change, and symbol-level git drift verification via kb check."
license: MIT
compatibility: "claude-code codex opencode cursor windsurf pi antigravity"
---
# Project Memory (`kb`)
Applies in any repository or multi-repo workspace where `kb.yaml` exists in the current or an ancestor directory.
## CLI Prerequisite
If `kb` is not in `PATH` yet (`command -v kb`), install the static binary first:
- macOS / Linux (curl): `curl -fsSL https://raw.githubusercontent.com/mdwitr0/kb/main/install.sh | bash -s -- --yes`
- Homebrew: `brew install mdwitr0/tap/kb`
- Go: `go install github.com/mdwitr0/kb/cmd/kb@latest`
## Nested Subprojects & Source-of-Truth Precedence (MANDATORY)
1. **Aggregate upward into the root:** In workspaces containing nested git repositories, all living domain specs live **exclusively in the root `kb/`** next to the root `kb.yaml`. Creating nested `kb.yaml` files inside subprojects is forbidden (`nested-kb-forbidden`). You do not need to modify files inside nested subprojects just to document them — place active invariants and code `anchors` into the root `kb/specs/`.
2. **Root `kb/` overrides stale local subproject docs:** When working inside a nested subproject whose local `CLAUDE.md` / `AGENTS.md` / `README.md` / `docs/` disagrees with the root `kb/`:
- use local subproject files **only** for local build/test commands (`Makefile`, `package.json`);
- for domain rules, limits, contracts, external APIs, and production topology, **always run `kb find "<query>"`** (it automatically resolves the ancestor `kb.yaml` across nested `.git` boundaries) and **follow the root `kb/`**, even if an untouched local file inside the subproject claims otherwise.
3. **Subproject coverage:** `kb subprojects` (and `kb check`) verifies that every nested git repository is covered by an anchor in the root `kb/specs/` (or explicitly listed under `ignore_subprojects` in `kb.yaml`).
## Lookup & Exact Service Context Before Reading Code
1. Run `kb find "<term or question>"` (domain filter: `--domain <id>`) or read the root `kb/INDEX.md` to understand which domain and service directory correspond to the user's words.
2. Once you identify the target service or package directory, run `kb context <path>` (e.g. `kb context services/billing`) — it deterministically returns the governing `kb/` specs, exact `code-drift` git commits touching `<path>` since `verified_at` (so you verify recent code changes when a spec lags), unmerged `kb/inbox.md` notes, and open `changes/` deltas for `<path>` only.
3. `kb find` returns only active canon (`kb/specs/`, `kb/decisions/`, runbooks) and skips `status: superseded` decisions and `archive/`.
4. **Do NOT pass `--archive`** (`kb find --archive "<query>"`) for questions about current behavior or active rules — use `--archive` only when explicitly asked about historical incidents, audits, or past reports. Files inside `archive/` are never active contracts.
## Recording Knowledge During Work
- Capture a verified production fact, external API quirk, or limit in one command without interrupting your flow:
`kb note --domain <id> "<verified fact and source>"`
- Manage domain rule changes via delta specs in the root workspace:
1. `kb change new <slug> --domain <id> --title "<title>"`
2. Fill `ADDED`, `MODIFIED`, or `REMOVED` in `changes/<slug>/delta.md`.
3. On release, fold the change into `kb/specs/<domain>.md`, run `kb stamp <domain>` (or `kb change sync <slug>`, which updates `verified_at` + `verified_commit` automatically), and archive the delta: `kb change sync <slug>`.
## Canon Hygiene
- `kb/specs/` describes **only current behavior**. Overwrite outdated behavior in place instead of appending dated changelog notes.
- Architectural rationale ("why") and bans belong in `kb/decisions/` (`kind: decision`). When superseded, set `status: superseded` and `superseded_by: <new-doc>`.
- Declare `anchors` in spec frontmatter (`path/to/file` or `path/to/file#Symbol`, including paths inside nested subprojects).
- Run `kb stamp <domain> && kb check` (or `kb index && kb check`) after verifying a spec against code. `code-drift` (`suspect`) means anchored code has commits after `verified_commit` (including merged feature branches and same-day commits) and the spec must be re-verified against code before re-stamping.
## Clarifying Requirements & Reconciling Drift (`kb grill`)
When the user wants to clarify business rules, audit a service/domain where docs, mental model, and code may have drifted apart, or run `/kb-grill`:
1. Run `kb grill --prompt "<user request>"` (or map the user's words to the exact service folder via `kb/INDEX.md` / `kb subprojects` and run `kb context <service-path>`).
2. Perform silent recon across the governing `kb/` spec(s), local docs, `code-drift` commits, and source code inside `<service-path>` — do NOT dump a generic code summary.
3. Ask **strictly one evidence-backed question per turn** citing exact `path:line` behavior and 2–3 numbered options, only where Docs != Code, Code != Code, or risky edge cases exist.
4. Separate confirmed answers into 3 buckets: verified current code behavior -> `kb/specs/<domain>.md`; rationale/bans -> `kb/decisions/`; places where current code violates business intent -> `kb change new <slug> --domain <domain>` (`changes/<slug>/delta.md` — never write unimplemented wishful rules into `kb/specs/`). Finish with `kb stamp <domain> && kb check --strict && kb status`.
## Initial Onboarding of an Existing Project (`kb onboard`)
When asked to onboard or migrate existing documentation of a repository into `kb`:
1. Run `kb onboard --prompt` (after `kb init` if `kb.yaml` is not created yet) to obtain the complete inventory of existing Markdown docs, dated reports, and nested git subprojects.
2. Read the discovered docs, verify claims against real code, configure real domains and synonyms in `kb.yaml`, write `kb/specs/<domain>.md` with code `anchors` covering all active subprojects (without modifying files inside nested subprojects), move dated reports into `archive/reports/`, and finish with `kb stamp --all && kb check --strict`.