Skip to content

KB

KB is a local-first knowledge system built for AI-assisted development. It gives you a CLI and runtime for storing durable facts, querying them by intent, and keeping project knowledge close to your code.

kb submit "Auth tokens expire after 15 minutes, not 24 hours"
kb query "token expiry policy"
kb invalidate "Auth tokens expire after 24 hours" "Auth tokens expire after 15 minutes, not 24 hours"

Why KB?

Every project accumulates decisions, constraints, and tribal knowledge that lives in Slack threads, PR comments, and people’s heads. KB gives that knowledge a home with a queryable structure — so your AI agent (or you) can retrieve the right context before making a change.

Store durable facts — not ephemeral chat history. Facts are versioned in Git alongside your code.

Query by intentkb query understands what you’re asking, not just what words you typed.

Hybrid retrieval — SQLite full-text search + vector-style ranking returns relevant docs even when phrasing differs between the query and the stored fact.

Knowledge graph — entities and relationships are extracted automatically, so you can ask “what depends on X?” and get a traversal, not just a keyword match.


Quick Start

1. Install

Install the latest published release:

npm install -g https://github.com/rosenjcb/kb/releases/latest/download/kb-cli-node22.tgz
command -v kb

Or build and install from source:

pnpm install
pnpm run check
npm run install:global
command -v kb

KB expects Node 22+ in the shell that runs kb.

2. Configure your LLM

KB auto-detects whichever API key is in your environment (ANTHROPIC_API_KEY, OPENAI_API_KEY). To set a provider explicitly:

kb config set llm.provider anthropic

3. Set a knowledge base

kb use myproject            # use for this session
kb use --default myproject  # persist as the default base

Each base stores its SQLite index under ~/.kb/sessions/<base>/.

4. Bootstrap from your docs

kb init

kb init reads your README, CLAUDE.md, and other project docs, then runs a multi-pass LLM pipeline to produce a set of focused, retrieval-ready fact documents. Takes 1–3 minutes for a typical repo.

5. Start using intent commands

kb query "how does authentication work?"
kb submit "OAuth tokens are short-lived; use the refresh endpoint after 15 min"
kb invalidate "passwords are hashed with MD5" "passwords are hashed with bcrypt"

Daily Workflow

# Before making a change — pull relevant context
kb query "topic I'm about to touch"

# After a decision — record it
kb submit "we chose option B because option A required a schema migration"

# Repair stale knowledge
kb invalidate "the queue is strongly consistent" "the queue is eventually consistent"

Original Documents

Source files collected directly from the repository during kb init. These reflect the raw project documentation.

Knowledge Graph

View the published entity graph extracted from your KB:

Autogenerated Docs

LLM-synthesized documents produced by kb init and stored in the knowledge base.