Persistent knowledge base for Claude Code. Every Claude instance reads from and writes to this repo, compounding knowledge across sessions.
Claude Code is stateless — each session starts fresh. This repo gives it long-term memory:
- Hooks inject accumulated knowledge into every conversation automatically
- Rules (
memory.md) teach Claude how to maintain its own knowledge base - Knowledge files store learnings, project context, and session history
The result: Claude remembers your corrections, knows your codebase conventions, and builds on past work instead of starting from scratch.
├── memory.md # Global rule (symlinked to ~/.claude/rules/memory.md)
├── settings.json # Claude Code settings (symlinked to ~/.claude/settings.json)
├── setup.sh # Run once to create symlinks
├── hooks/
│ ├── session-start.sh # SessionStart: injects knowledge files into context
│ ├── post-compact-context.sh # Re-injects knowledge after context compaction
│ ├── pre-compact.sh # Reminds to save state before compaction
│ └── memory-reminder.sh # Stop: blocks exit if memory needs updating
├── scripts/
│ └── extract-knowledge-usage.sh # Analyze knowledge file reads from JSONL logs
└── knowledge/
├── active-context.md # Project index + status
├── session-log.md # Reverse-chronological work log
├── learnings.md # Accumulated patterns, corrections, & anti-patterns
└── projects/ # Per-project notes
├── <name>.md
└── archive/ # Completed projects
-
Clone this repo to your home directory:
git clone git@github.com:dg-builder/dg_claude_knowledge.git ~/dg_claude_knowledge -
Run the setup script to create symlinks:
cd ~/dg_claude_knowledge && ./setup.sh
-
Start a Claude Code session — the hooks will automatically inject knowledge context.
memory.mdis loaded as a global rule on every Claude Code session. It teaches Claude how to read and update the knowledge base.SessionStarthook injectsactive-context.md,learnings.md, and recentsession-log.mddirectly into the conversation — Claude doesn't need to read them manually.PreCompacthook reminds Claude to save important context before it gets compacted away.PostCompacthook re-injects durable knowledge after context compaction.Stophook blocks exit if substantive work was done without updating knowledge files.- Claude reads relevant project notes before starting work, updates all knowledge files during/after.
- Changes are committed and pushed to this repo for persistence across machines.
The included settings.json has minimal permissions and hooks pre-configured. You'll want to customize:
permissions.allow— Add tool permissions for your workflow (build commands, git operations, etc.)hooks— The knowledge hooks are pre-configured; add your own as neededenabledPlugins— Enable Claude Code plugins you use
active-context.md— Add your projects to the mapping tablelearnings.md— Will grow automatically as Claude learns your preferencesprojects/— Create<project-name>.mdfiles for each project you work on
See knowledge/projects/example-web-app.md for an example project file.
- Correct Claude aggressively — corrections get saved to
learnings.mdand persist across all future sessions - Keep files concise — the system has built-in growth limits to prevent bloat
- Commit often — Claude will commit/push knowledge updates, but you can also edit files directly
- Use project files for project-specific context; use
learnings.mdfor cross-project patterns only