claude-wiki
Installable Python package providing Claude Code hooks and a CLI for a personal knowledge base. It captures context from your AI coding sessions automatically, compiles it into a wiki of atomic, cross-linked articles, and feeds the relevant index back into your next session — so knowledge compounds instead of evaporating.
Adapted from Karpathy's LLM Knowledge Base architecture.
Features
- Automatic capture. Session hooks extract the meaningful turns of each Claude Code session into immutable daily logs — no manual note-taking.
- Compile to atomic articles. Daily logs are distilled by an LLM into one
article per concept, plus cross-cutting
connections/and filedqa/answers, each with YAML frontmatter and provenance backlinks.--max-logscaps the cost of a run. - Index-guided query (no RAG).
queryreads the catalog first, then answers from the KB — retrieval grounded in structure rather than embeddings. - Health checks.
lintruns structural checks (broken wikilinks, orphan pages, sparse articles, frontmatter schema, and catalog↔article completeness) and optional LLM contradiction checks, with--fixfor safe auto-repairs and machine-readable--jsonoutput and a stable exit-code contract for CI. - Topology & health monitoring.
graphreports the link topology — orphans, hubs, and connected components — so you can spot a fragmented KB at a glance;statusdiagnoses repository health with--jsonfor CI gating. - Obsidian-friendly output. Wikilinks, frontmatter, and a per-repo
{repo_name}.mdcatalog keep the vault clean for Graph view; a globalcore.mdregistry links every registered repo with[[owner/repo]]links. - Project or user mode. Keep the KB inside the repo (
.claude/knowledge/) or in an XDG user-wide vault;migratemoves data between modes with rollback. - Fast, non-fatal hooks. Handlers do only local I/O within the Claude Code timeout and offload LLM work to a backgrounded flush process; failures are logged, never fatal.
How it works
Claude Code session event
-> claude-wiki-hook <Event> (SessionStart / SessionEnd / PreCompact)
-> hook handler (fast local I/O) -> backgrounded flush -> daily/YYYY-MM-DD.md
claude-wiki compile
-> daily logs -> LLM -> kb_root/concepts/ · connections/ · qa/ + catalog
SessionStart hook -> injects catalog + recent daily log into next session
Daily logs are the append-only source of truth; the compiled wiki is LLM-owned and rebuilt from them. The catalog is the primary retrieval mechanism — the SessionStart hook injects it into each new session so context carries forward.
Install
With uv (recommended):
uvx claude-wiki init
From source in a clone of this repo:
uv sync --frozen
Requires Python 3.12+. No API key — LLM calls use Claude Code's own credentials.
Usage
Initialize a repository:
claude-wiki init
Daily commands:
claude-wiki compile [--all] [--file FILE] [--dry-run] [--continue-on-error] [--max-logs N] [--path PATH]
claude-wiki query "your question" [--file-back] [--json] [--path PATH]
claude-wiki lint [--structural-only] [--fail-on-warning] [--fix] [--threshold N] [--json] [--path PATH]
claude-wiki graph [--json] [--top N] [--path PATH]
claude-wiki status [--json] [--path PATH]
claude-wiki tags [--json] [--path PATH]
claude-wiki migrate [--dry-run] [--path PATH] [--kb-dir KB_DIR] [--daily-dir DAILY_DIR]
claude-wiki rename-catalog [--dry-run] [--path PATH]
query, lint, status, and graph accept --json for machine-readable
output and follow a stable exit-code contract. See the
CLI reference for every flag.
Hook entry points (called by Claude Code via .claude/settings.local.json by
default):
claude-wiki-hook SessionStart
claude-wiki-hook SessionEnd
claude-wiki-hook PreCompact
What claude-wiki init creates
my-project/
├── .claude-wiki.lock # per-repo config (machine-managed)
├── .claude/settings.local.json # repo-local hook registration (default)
└── .claude/daily/ # conversation logs (created on first flush)
Use claude-wiki init --global to write hooks to ~/.claude/settings.json
instead. Use claude-wiki init --path PATH to target a different repository
root, or --no-hooks to skip hook installation.
Configuration
.claude-wiki.lock fields:
{
"repo_name": "my-project",
"repo_owner": "local",
"layout_version": "2",
"kb_dir": "project",
"daily_dir": ".claude/daily",
"reports_dir": "reports",
"timezone": "UTC",
"compile_after_hour": 18
}
layout_versiontracks the internal directory-layout generation. New repositories use"2".kb_dirisproject(repo-relative.claude/knowledge/),user(XDG vault~/.local/share/claude-wiki-vault/<owner>/<repo>/), or a custom path.daily_dirdefaults to.claude/dailyin project mode and~/.local/share/claude-wiki-daily/<owner>/<repo>/in user mode.reports_diris deprecated; reports are written to the cache directory (<repo>/.claude/reports/in project mode).
Environment overrides: CLAUDE_WIKI_PROJECT_DIR (KB location),
CLAUDE_WIKI_STATE_DIR (machine state), CLAUDE_WIKI_CACHE_DIR (reports),
and CLAUDE_WIKI_DEBUG (verbose hook logging).
Documentation
- Full docs in
docs/— tutorials, how-to guides, and reference. CHANGELOG.mdfor release history.docs/adr/for architecture decisions.
Community
- Contributing — branch naming, PR checklist, dev setup.
- Code of Conduct — Contributor Covenant 2.1.
- Security policy — responsible disclosure.
Development
make dev # install with dev dependencies
make install-precommit # install git hooks (run once per clone)
make test # run pytest
make lint # ruff check
make format # ruff format + mdformat
make typecheck # mypy
make precommit # all pre-commit hooks
make all # full CI gate (format, lint, typecheck, test, precommit)
Metadata
Release files for claude-wiki 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| claude_wiki-1.0.0.tar.gz | 274.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| claude_wiki-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 365.4 kB
Release files / claude_wiki-1.0.0.tar.gz
| Download URL | claude_wiki-1.0.0.tar.gz |
|---|---|
| Size | 274.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f54c52e85763c69167b65fd37ab7e2a36cb3cbf63d9a2b2ec1bf818831a35ff8
|
|
BLAKE2b-256 checksum How to use checksums |
611ff5b64d1915cb4f8db4f91fe7ee0a48986302f80a463b735124bc72648daa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / claude_wiki-1.0.0-py3-none-any.whl
| Download URL | claude_wiki-1.0.0-py3-none-any.whl |
|---|---|
| Size | 90.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03b8c606bf15e39c7fb2ec62f3e6d8b4dbc3b7d8c79b3a77023b4b179714484b
|
|
BLAKE2b-256 checksum How to use checksums |
89a42c7499df3e5a9e574de933174936821792c07ae83d83a9ecb1d6b9f36c71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|