claude-memory-compiler
```markdown
What this skill does
```markdown
---
name: claude-memory-compiler
description: Give Claude Code an evolving memory that captures sessions, extracts decisions and lessons via the Claude Agent SDK, and compiles everything into structured cross-referenced knowledge articles.
triggers:
- set up claude memory compiler
- give claude code persistent memory
- capture my coding sessions automatically
- compile my claude conversations into a knowledge base
- set up session hooks for claude code
- install llm knowledge base for my project
- make claude remember decisions across sessions
- auto-capture claude code session transcripts
---
# Claude Memory Compiler
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
Claude Memory Compiler gives Claude Code a persistent, evolving memory. Claude Code hooks automatically capture conversation transcripts at session end or pre-compaction. A background process using the Claude Agent SDK extracts decisions, lessons, and patterns, appending them to daily logs. A compiler then organizes those logs into structured, cross-referenced knowledge articles — no vector database or RAG required at personal scale.
Inspired by [Karpathy's LLM Knowledge Base](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) architecture.
---
## Installation
### Option 1 — Tell your AI agent
```
Clone https://github.com/coleam00/claude-memory-compiler into this project.
Set up the Claude Code hooks so my conversations automatically get captured
into daily logs, compiled into a knowledge base, and injected back into
future sessions. Read the AGENTS.md for the full technical reference.
```
### Option 2 — Manual setup
```bash
# Clone into your project root
git clone https://github.com/coleam00/claude-memory-compiler .claude-memory
cd .claude-memory
# Install dependencies (requires uv)
uv sync
# Copy hooks config into your project's Claude settings
cp .claude/settings.json ../.claude/settings.json
# Or merge the hooks block into an existing .claude/settings.json
```
### Dependency requirements
- Python 3.10+
- [`uv`](https://github.com/astral-sh/uv) package manager
- Claude Code (with Max, Team, or Enterprise subscription — no separate API credits needed)
---
## How It Works
```
Conversation
-> SessionEnd / PreCompact hooks
-> flush.py (Claude Agent SDK extracts knowledge)
-> daily/YYYY-MM-DD.md
-> compile.py (after 6 PM or manually)
-> knowledge/concepts/, connections/, qa/
-> SessionStart hook injects index.md into next session
-> cycle repeats
```
### Hook events used
| Hook | Purpose |
|------|---------|
| `SessionEnd` | Primary capture — fires when a session closes |
| `PreCompact` | Safety net — fires before mid-session compaction |
| `SessionStart` | Injects the knowledge index into each new session |
---
## Key Commands
```bash
# Compile new daily logs into knowledge articles
uv run python scripts/compile.py
# Ask a question against the knowledge base
uv run python scripts/query.py "Why did we switch from SQLite to Postgres?"
# Ask + save the answer back into the knowledge base
uv run python scripts/query.py "What auth strategy are we using?" --file-back
# Run all 7 health checks (broken links, orphans, contradictions, staleness)
uv run python scripts/lint.py
# Run only free structural checks (no LLM calls)
uv run python scripts/lint.py --structural-only
```
---
## Directory Structure
```
your-project/
├── .claude/
│ └── settings.json # Hook configuration
├── daily/
│ └── YYYY-MM-DD.md # Raw daily session logs
├── knowledge/
│ ├── index.md # Master index (injected at session start)
│ ├── concepts/ # Structured concept articles
│ ├── connections/ # Cross-reference articles
│ └── qa/ # Q&A articles saved with --file-back
└── scripts/
├── flush.py # Session capture + extraction
├── compile.py # Daily logs -> knowledge articles
├── query.py # Index-guided retrieval
└── lint.py # Knowledge base health checks
```
---
## Configuration — `.claude/settings.json`
```json
{
"hooks": {
"SessionEnd": [
{
"command": "uv run python scripts/flush.py",
"cwd": "${workspaceFolder}"
}
],
"PreCompact": [
{
"command": "uv run python scripts/flush.py --pre-compact",
"cwd": "${workspaceFolder}"
}
],
"SessionStart": [
{
"command": "uv run python scripts/inject.py",
"cwd": "${workspaceFolder}"
}
]
}
}
```
If you already have a `.claude/settings.json`, merge only the `hooks` block — don't overwrite existing settings.
---
## Code Examples
### Manually flush a transcript
```python
# scripts/flush.py is called automatically by hooks, but you can invoke it directly
import subprocess
result = subprocess.run(
["uv", "run", "python", "scripts/flush.py"],
capture_output=True,
text=True
)
print(result.stdout)
```
### Programmatic query
```python
# Query the knowledge base from your own scripts
import subprocess
import sys
def query_knowledge_base(question: str, save_back: bool = False) -> str:
cmd = ["uv", "run", "python", "scripts/query.py", question]
if save_back:
cmd.append("--file-back")
result = subprocess.run(cmd, capture_output=True, text=True)
return result.stdout
answer = query_knowledge_base("What database migration strategy are we using?")
print(answer)
```
### Trigger compilation manually
```python
import subprocess
def compile_knowledge():
"""Compile all unprocessed daily logs into knowledge articles."""
result = subprocess.run(
["uv", "run", "python", "scripts/compile.py"],
capture_output=True,
text=True
)
if result.returncode != 0:
print("Compile error:", result.stderr)
else:
print(result.stdout)
compile_knowledge()
```
### Run lint checks programmatically
```python
import subprocess
def lint_knowledge_base(structural_only: bool = False) -> dict:
cmd = ["uv", "run", "python", "scripts/lint.py"]
if structural_only:
cmd.append("--structural-only")
result = subprocess.run(cmd, capture_output=True, text=True)
return {
"passed": result.returncode == 0,
"output": result.stdout,
"errors": result.stderr
}
report = lint_knowledge_base(structural_only=True)
print(report["output"])
```
---
## Daily Log Format (`daily/YYYY-MM-DD.md`)
Each flush appends an entry like:
```markdown
## Session — 2026-04-10 14:32
### Decisions
- Switched auth from JWT to session cookies to simplify SSR compatibility.
### Lessons Learned
- `prisma migrate dev` resets the shadow DB on every run — use `--skip-generate` in CI.
### Patterns Identified
- All new API routes follow the `app/api/[resource]/route.ts` convention.
### Gotchas
- The `useRouter` hook from `next/navigation` behaves differently in Server Components — always import from the correct package.
```
---
## Knowledge Article Format (`knowledge/concepts/`)
Compiled articles use structured markdown:
```markdown
# Authentication Strategy
**Last Updated:** 2026-04-10
**Related:** [[Session Management]], [[API Security]]
## Summary
We use session cookies (not JWTs) for authentication to simplify SSR compatibility with Next.js App Router.
## Key Decisions
- Chose session cookies over JWTs on 2026-04-08 after discovering JWT refresh complexity with RSC.
## Lessons
- Always import `useRouter` from `next/navigation` in client components, never from `next/router`.
## Open Questions
- Should we add refresh token rotation for long-lived sessions?
```
---
## Automatic Compilation Trigger
`flush.py` checks local time after each session. If it is **after 6 PM**, it automatically triggers `compile.py` to process that day's logs. This means no manual scheduling is needed for end-of-day compilation.
To compile at any time:
```bash
uv Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.