Skip to content

HR-909/Compiled-Memory-Architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiled Memory Architecture

Permanent, Compounding Memory for Claude + Obsidian

Built by @HR-909 · Based on Karpathy's LLM-Wiki pattern · Powered by MemPalace + Claude Code


The Problem

Every time you start a new Claude conversation, it forgets everything.

You spend 10 minutes re-explaining your project. You paste the same context over and over. You hit token limits. You lose decisions made in previous sessions.

This architecture fixes all of that.


What This Is

A three-layer knowledge system where Claude maintains a self-compounding wiki from your raw notes — and remembers everything across every conversation, forever.

_raw/          ← Your sources (articles, PDFs, notes) — you collect, never modified
wiki/          ← Claude-compiled wiki — auto-generated, interlinked, compounding
Your folders/  ← Your project structure — augmented by AI, owned by you

The key insight (from Andrej Karpathy):

Instead of searching raw files on every query (RAG), compile knowledge once into an interconnected wiki. Every answer enriches the wiki. The system gets smarter with every session.


How It Works

You drop an article into _raw/inbox/
         ↓
/ingest  →  Claude reads it, identifies entities and concepts
         ↓
         Creates/updates pages in wiki/ with [[wikilinks]]
         ↓
         Logs the operation to wiki/log.md
         ↓
Next time you ask a question → Claude reads the compiled wiki
         ↓
         Gives a cited, synthesized answer in seconds
         ↓
         Updates the wiki with the new Q&A (compounding)

Result: Knowledge that genuinely accumulates. The system is smarter on day 100 than day 1.


Architecture at a Glance

Layer Folder Owner Purpose
Raw Sources _raw/ You Immutable archive of original content
Compiled Wiki wiki/ Claude Synthesized, interlinked knowledge base
Projects 10_Projects/ etc. You Active work, augmented by AI
Discovery MemPalace (local) Auto Semantic search, 96.6% recall, $0/month
Operator Claude Code AI Reads vault, runs commands, writes wiki
Interface Obsidian You Visual browser, graph view, editing

L1/L2 Cache Strategy

  • L1 (CLAUDE.md, ~600 tokens) — Critical rules loaded every session
  • L2 (wiki/, queried on demand) — Deep knowledge, zero idle token cost

This keeps startup context lean while giving Claude access to everything.


Provenance System

Every claim in the wiki is tagged for confidence:

Tag Meaning When to use
^[extracted] Direct from source Default — verbatim facts
^[inferred] Claude synthesis Connections across sources
^[ambiguous] Sources disagree Flag for your review
^[verified] You confirmed it Highest confidence

This prevents hallucinations from propagating silently.


Slash Commands

Command What it does
/ingest [folder] Compile any folder into the wiki
/query [question] Search compiled knowledge, get cited answers
/lint Find orphans, contradictions, stale content
/morning Daily briefing — priorities, open questions, status
/session-end [topic] Log session, update wiki, surface open questions

Setup Guide

Prerequisites

  • Mac or Linux (Windows: use WSL)
  • Obsidian installed
  • Claude Pro or Max subscription

Step 1 — Install Claude Code (5 min)

curl -fsSL https://claude.ai/install.sh | bash

# Open new terminal window, then authenticate
claude
# Follow browser login prompt

Step 2 — Install MemPalace (5 min)

pip3 install mempalace

If you get "command not found" after install:

# Find where pip installed it
python3 -m site --user-base

# Add to PATH (replace 3.x with your Python version)
echo 'export PATH="$HOME/Library/Python/3.x/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Step 3 — Clone Into Your Obsidian Vault (2 min)

# Navigate to your vault
cd /path/to/your/obsidian/vault

# Clone the template
git clone https://github.com/HR-909/memory-architecture-template.git .

# Or if vault already has files, copy manually:
# git clone https://github.com/HR-909/memory-architecture-template.git /tmp/template
# cp -r /tmp/template/. .

Step 4 — Personalize CLAUDE.md (15 min)

Open CLAUDE.md in Obsidian and fill in:

  • Your name and role
  • Your active projects
  • Your hard constraints (rules Claude must never break)
  • Your tech stack

This is the most important step. The more specific you are, the smarter Claude becomes.

Step 5 — Initialize MemPalace (5 min)

# In your vault directory
mempalace init .

# Follow the interactive prompts:
# - Remove fake entities detected
# - Add your real project names
# - Accept the room structure

# Index your existing content
mempalace mine .

Step 6 — Connect MemPalace to Claude Code (1 min)

claude mcp add mempalace -- python3 -m mempalace.mcp_server

Step 7 — Set Up Git Backup (5 min)

git init
git add .
git commit -m "Memory architecture initialized"

# Create private repo on GitHub and push
# (keep your vault private — this template is public)

Step 8 — First Test (5 min)

cd /path/to/your/vault
claude

Inside Claude Code:

Do you have access to MemPalace tools? List all tools available to you.

You should see MemPalace listed with ~29 tools.

Then drop an article into _raw/inbox/ and run:

/ingest

Watch your wiki build itself in real time.


Daily Workflow

Morning (2 min)

cd /path/to/vault
claude
/morning

Throughout the Day

Drop anything useful into _raw/inbox/:

  • Web articles (copy/paste)
  • PDFs (drag in)
  • Meeting notes (type directly)
  • Voice transcripts (paste)

Once Daily (5 min)

/ingest

Processes everything in inbox, compiles to wiki, auto-links.

End of Work Session

/session-end what-you-worked-on

Creates session log, updates wiki, surfaces open questions.

Every Sunday (15 min)

/lint

Review the health report. Fix contradictions, merge duplicates, update stale content.


Folder Structure

vault/
├── _raw/                    ← Layer 1: Immutable sources
│   ├── articles/            ← Processed web articles
│   ├── pdfs/                ← PDFs and documents
│   ├── transcripts/         ← Meeting notes, voice memos
│   ├── screenshots/         ← Visual references
│   └── inbox/               ← Drop zone (process with /ingest)
│
├── wiki/                    ← Layer 2: Claude-compiled
│   ├── entities/            ← People, companies, products
│   ├── concepts/            ← Ideas, patterns, frameworks
│   ├── sources/             ← One summary per ingested source
│   ├── syntheses/           ← Cross-cutting analyses
│   ├── questions/           ← Open questions to resolve
│   └── log.md               ← Append-only operation log
│
├── .claude/
│   └── commands/            ← Slash commands
│       ├── ingest.md
│       ├── query.md
│       ├── lint.md
│       ├── morning.md
│       └── session-end.md
│
├── 99_System/
│   └── Templates/           ← Note templates
│
├── CLAUDE.md                ← Master instructions (L1 cache)
├── mempalace.yaml           ← MemPalace configuration
└── .gitignore               ← Excludes personal data

Obsidian Plugins (Recommended)

Install these via Settings → Community Plugins:

Plugin Why
Templater Dynamic templates with dates
Dataview Query your vault like a database
Calendar Visual daily notes
Graph view Visualize wiki connections

Troubleshooting

"command not found: mempalace"

echo 'export PATH="$HOME/Library/Python/3.9/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

"command not found: claude"

source ~/.zshrc
# or open a new terminal window

MemPalace not showing in Claude Code

# Re-add the MCP connection
claude mcp add mempalace -- python3 -m mempalace.mcp_server
# Then restart claude

Wiki getting messy

/lint

Review the report and apply suggested fixes.

Want to undo a change

git log --oneline -10          # See recent changes
git checkout HEAD~1 -- wiki/   # Restore wiki to previous state

Evolving the Architecture

Everything is modular. You can:

  • Add new slash commands → create .md files in .claude/commands/
  • Add new MemPalace wings → edit mempalace.yaml
  • Change schema rules → edit CLAUDE.md
  • Swap MemPalace → replace with Mem0, ChromaDB direct, or Pinecone
  • Change editor → Obsidian, Logseq, VS Code — all work with plain markdown

The data is always just markdown files. Nothing locks you in.


Credits

This architecture is built on:


License

MIT — use freely, adapt for your needs, share with attribution.


Built and maintained by @HR-909

About

Permanent, compounding memory for Claude + Obsidian. Built on Karpathy's LLM-Wiki pattern + MemPalace + Claude Code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages