A knowledge sidecar for Claude Code
Project description
keephive
A knowledge sidecar for Claude Code. It captures what you learn, verifies it stays true, and surfaces it when relevant.
Claude Code forgets everything between sessions. keephive rides alongside it using hooks, an MCP server, and context injection to give it persistent, verified memory.
Install
uv tool install keephive
keephive setup
Requires uv. This installs from PyPI, registers the MCP server, and configures Claude Code hooks.
Via pip:
pip install keephive
keephive setup
From source:
git clone https://github.com/joryeugene/keephive.git
cd keephive && uv tool install . && keephive setup
Stay up to date
hive up # upgrade in place (recommended)
uv tool upgrade keephive # manual alternative; run keephive setup after
Run keephive setup again after upgrading manually to sync hooks and the MCP server registration to the new binary path.
Quick start
hive # status at a glance
hive r "FACT: Auth service uses JWT with RS256" # remember something
hive v # verify stale facts
hive go # launch interactive session
hive todo # open TODOs
After a few sessions, hive shows what your agent has learned:
$ hive
keephive v0.13.0
● hooks ● mcp ● data
4 facts (4 ok) | 12 today | 8 yesterday | 2 guides | 48K
1 open TODO(s):
[today] Add rate limiting to the /upload endpoint.
Today:
~ [10:42:15] FACT: Auth service uses JWT with RS256, tokens expire after 1h.
~ [10:38:01] DECISION: Chose Postgres over SQLite for multi-user support.
~ [09:15:44] INSIGHT: The retry logic in api_client.py silently swallows 429s.
[09:12:30] DONE: Migrate user table to new schema.
Active draft: slot 1 · "api testing todo list..." (47 words) -> hive nc
hive go (session) | hive l (log) | hive rf (reflect) | hive help
How it works
keephive uses the three extension points Claude Code exposes:
- Hooks fire on events (session start, conversation compact, user prompt). They capture insights and inject context without any agent action.
- MCP server gives Claude Code native tool access (
hive_remember,hive_recall, etc.) so the agent can read and write memory directly. - Context injection surfaces verified facts, behavioral rules, stale warnings, matching knowledge guides, and open TODOs at the start of every session via the SessionStart hook's
additionalContextfield.
The loop
capture --> recall --> verify --> correct
^ |
+---------------------------------+
- Capture: The PreCompact hook extracts FACT/DECISION/TODO/INSIGHT entries when conversations compact. It reads the full transcript, classifies insights via LLM, and writes them to today's daily log.
- Recall: Captured entries surface automatically at the next session start via context injection.
hive rcsearches all tiers directly;hiveshows current state. - Verify: Facts carry
[verified:YYYY-MM-DD]timestamps. After 30 days (configurable), they are flagged stale.hive vchecks them against the codebase with LLM analysis and tool access. - Correct: Invalid facts get replaced with corrected versions. Valid facts get re-stamped. Uncertain facts get flagged for human review.
Memory tiers
| Tier | Path | Purpose |
|---|---|---|
| Working memory | ~/.claude/hive/working/memory.md |
Core facts, loaded every session |
| Rules | ~/.claude/hive/working/rules.md |
Behavioral rules for the agent |
| Knowledge guides | ~/.claude/hive/knowledge/guides/ |
Deep reference on specific topics |
| Daily logs | ~/.claude/hive/daily/YYYY-MM-DD.md |
Append-only session logs |
| Archive | ~/.claude/hive/archive/ |
Old daily logs after gc |
Hooks
| Hook | Trigger | What it does |
|---|---|---|
| SessionStart | New session | Injects memory, rules, TODOs, stale warnings |
| PreCompact | Conversation compacts | Extracts insights from transcript, writes to daily log |
| PostToolUse | After Edit/Write | Periodic nudge to record decisions |
| UserPromptSubmit | User sends prompt | Periodic nudge to record decisions |
Commands
| Command | Short | What |
|---|---|---|
| Capture | ||
hive remember "text" |
hive r "text" |
Save to daily log |
hive t <text> |
Quick-add a TODO | |
hive note |
hive n |
Multi-slot scratchpad ($EDITOR) |
hive n todo |
hive 4 todo |
Extract action items from a note slot |
| Recall | ||
hive status |
hive / hive s |
Status overview |
hive recall <query> |
hive rc <query> |
Search all tiers |
hive log [date] |
hive l |
View daily log; hive l summarize for LLM summary |
hive todo |
hive td |
Open TODOs with ages |
hive todo done <pat> |
Mark TODO complete | |
hive knowledge |
hive k |
List/view knowledge guides |
hive prompt |
hive p |
List/use prompt templates |
hive ps |
Active sessions, project activity, git state | |
hive session [mode] |
hive go |
Launch interactive session |
hive standup |
hive su |
Standup summary with GitHub PR integration |
hive stats |
hive st |
Usage statistics |
| Verify | ||
hive verify |
hive v |
Check stale facts against codebase; auto-corrects |
hive reflect |
hive rf |
Pattern scan across daily logs |
hive audit |
hive a |
Quality Pulse: 3 perspectives + synthesis |
| Manage | ||
hive mem [rm] <text> |
hive m |
Add/remove working memory facts |
hive rule [rm] <text> |
Add/remove behavioral rules | |
hive edit <target> |
hive e |
Edit memory, rules, todos, etc. |
hive skill |
hive sk |
Manage skill plugins |
| Maintain | ||
hive doctor |
hive dr |
Health check |
hive gc |
hive g |
Archive old logs |
hive setup |
Register hooks and MCP server | |
hive update |
hive up |
Upgrade keephive in-place |
Features in depth
Log Summarize
hive l summarize pipes today's log entries to claude-haiku and prints 3-5 bullet-point highlights. Useful after long sessions before compaction.
Smart Recall
hive rc <query> uses an SQLite FTS5 index over all daily logs and the archive for ranked full-text search. Run hive gc to rebuild the index. Falls back to grep if the index is absent.
Notes
hive n is a multi-slot scratchpad. Each slot persists across sessions, auto-copies to clipboard on save, and can be initialized from a prompt template (hive n <template>). Use hive n.2 or hive 2 to switch to slot 2 and open it in $EDITOR.
hive n todo (or hive 4 todo for slot 4) scans the active slot for action items. Both plain text lines and bullet points from a ## todo section become candidates; items over 120 characters are skipped as observations. For a single item, you get a yes/no prompt. For multiple items, your $EDITOR opens with the candidates — delete lines you don't want, save and quit to confirm.
hive 4 "text" appends text directly to slot 4 without opening an editor. Use bare-digit commands with a quoted string to capture quick notes mid-session.
Edit
hive e <target> opens files in $EDITOR. Targets: memory, rules, todo (with diff-on-save), CLAUDE.md, settings, daily log, notes. Run hive e with no arguments to see all targets.
Sessions
hive go launches an interactive Claude session with your full keephive context pre-loaded.
| Command | What |
|---|---|
hive go |
General session with full memory and warnings |
hive session todo |
Walk through open TODOs one by one |
hive session verify |
Check stale facts against the codebase |
hive session learn |
Active recall quiz on recent decisions |
hive session reflect |
Pattern discovery from daily logs |
hive session <prompt> |
Load a custom prompt from knowledge/prompts/ |
Reflect
hive rf scans daily logs for recurring patterns across multiple days. When it finds a theme, hive rf draft <topic> generates a knowledge guide from the matching entries. This is how scattered daily notes become structured reference material.
Audit
hive a runs three parallel LLM analyses on your memory state (fact accuracy, data hygiene, strategic gaps), then synthesizes them into a quality score with actionable suggestions.
Standup
hive su generates a standup summary from recent daily log activity and optionally includes GitHub PR data.
Stats
hive st shows usage statistics with per-project breakdown, session streaks, and activity sparklines.
Prompts
hive p lists reusable prompt templates stored in knowledge/prompts/. Use them to start notes (hive n <template>) or launch custom sessions (hive session <template>).
MCP tools
All commands are also available as MCP tools for Claude Code to call directly:
hive_remember, hive_recall, hive_status, hive_todo, hive_todo_done, hive_knowledge, hive_knowledge_write, hive_prompt, hive_prompt_write, hive_mem, hive_rule, hive_log, hive_audit, hive_recurring, hive_stats, hive_fts_search, hive_standup, hive_ps
Configuration
| Variable | Default | Description |
|---|---|---|
HIVE_HOME |
~/.claude/hive |
Data directory |
HIVE_STALE_DAYS |
30 |
Days before a fact is flagged stale |
HIVE_CAPTURE_BUDGET |
4000 |
Characters to extract from transcripts |
ANTHROPIC_API_KEY |
(unset) | Enables LLM features inside Claude Code sessions. Never needed from a terminal. |
NO_COLOR |
(unset) | Disable terminal colors |
LLM features
TL;DR: If you have Claude Code, you pay nothing extra. Ever.
keephive calls claude -p, which runs under your existing Claude Code subscription. ANTHROPIC_API_KEY is never checked from a terminal or a hook — you cannot accidentally bill yourself.
The API path exists for one specific case: running LLM commands (hive a, hive v, etc.) inside a Claude Code session rather than from a separate terminal. That is the only time ANTHROPIC_API_KEY is consulted.
Two tiers
| Tier | When active | Cost |
|---|---|---|
claude -p subprocess |
Terminal or hooks (default, always) | Free — Claude Code subscription |
| Direct Anthropic API | Inside Claude Code + ANTHROPIC_API_KEY set |
Paid — per-call billing |
Hooks (PreCompact, etc.) run without the CLAUDECODE environment variable, so they always take the free subprocess path regardless of whether ANTHROPIC_API_KEY is present in your shell.
LLM-powered commands
| Command | Model | When to use |
|---|---|---|
hive a (audit) |
3× haiku + 1× sonnet | Intentional quality check |
hive v (verify) |
sonnet + tools, multi-turn | Validating stale facts |
hive rf analyze/draft |
haiku | Pattern discovery |
hive su (standup) |
haiku | Daily standup generation |
hive l summarize |
haiku | End-of-session summary |
hive dr (doctor) |
haiku, optional | Duplicate TODO detection |
| PreCompact hook | haiku | Automatic on compaction — always free |
hive a and hive v are the heavyweight operations. Use them intentionally.
Free commands (no LLM)
hive r, hive rc, hive s, hive todo, hive t, hive m, hive rule, hive e, hive n, hive k, hive p, hive st, hive l (without summarize), hive gc, hive sk, and all hooks except PreCompact.
Disable automatic LLM calls
Set HIVE_SKIP_LLM=1 to skip the PreCompact hook's extraction step. SessionStart never calls an LLM.
Development
uv run pytest # all tests
uv run pytest -m llm -v -o "addopts=" # LLM E2E tests (slow, real API calls)
uv run pytest -x # stop on first failure
See CLAUDE.md for architecture details.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keephive-0.13.0.tar.gz.
File metadata
- Download URL: keephive-0.13.0.tar.gz
- Upload date:
- Size: 105.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ece3aafb1b6adf021c3e82610ff8d9cd677e40d1ca116e35243db90db9ce8ea
|
|
| MD5 |
7c5861d2b5925ec2b8cc8b57193bbc7d
|
|
| BLAKE2b-256 |
f740161d0ca360e466c84ae6736fc82200225d88939eec484e099b9f98fbb733
|
File details
Details for the file keephive-0.13.0-py3-none-any.whl.
File metadata
- Download URL: keephive-0.13.0-py3-none-any.whl
- Upload date:
- Size: 129.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3f442c3037113c2ada2fe86436364e60d1dea15b40cc69c2002855a65c75981
|
|
| MD5 |
ba78b2f648493b928172a6fad041ecac
|
|
| BLAKE2b-256 |
b98cfe7779add0c0a933bb0abf79cce38c13b402ce62c520a47fc97c67ca7513
|