Personal AI Infrastructure (PAI) — Memory & Context
Memory Model
File-based, append-mostly, with 15 typed subdirectories. No external database.
"Heavy bias toward plain text and Markdown. PAI avoids SQLite, Postgres, and other opaque stores wherever possible. Everything should be transparent and parsable — by you, by your DA, by rg, by anything else."
"Filesystem as context, no RAG. PAI has avoided RAG since June 2025."
MEMORY Directory Structure
~/.claude/PAI/MEMORY/
├── WORK/ # ISAs + project artifacts (auto-created by Algorithm)
├── KNOWLEDGE/ # Curated distilled knowledge
├── LEARNING/ # What went well, what didn't (auto-created by hooks)
├── RESEARCH/ # Research outputs
├── RELATIONSHIP/ # People, organization observations
├── REFERENCE/ # Reference material
├── RAW/ # Inbox (unprocessed)
├── SKILLS/ # Skill-specific artifacts
├── DATA/ # Data files
├── BOOKMARKS/ # Saved URLs
├── SCRATCHPAD/ # Temporary
├── AUTO/ # Auto-generated by hooks
├── VERIFICATION/ # Verification records
├── WISDOM/ # Distilled insights
└── PROJECT/ # Project-level state
Each directory ships empty with only a README.md describing what belongs there. Content accumulates automatically through normal PAI usage.
Persistence Scope
global — all memory is in ~/.claude/PAI/MEMORY/ (user-level, not project-level). Available across all projects and sessions.
Context Injection
Multiple hooks inject memory at session start:
LoadContext.hook.ts — loads relevant MEMORY content at session start
RestoreContext.hook.ts — restores context after compaction
At UserPromptSubmit, the Sonnet classifier hook (PromptProcessing.hook.ts) runs and injects MODE + TIER into additionalContext. The DA reads this and selects output format + algorithm tier accordingly.
Compaction Handling
PreCompact.hook.ts fires before compaction. PAI's approach:
- Preserve current state in MEMORY before context is lost
RestoreContext.hook.ts reloads relevant context after compaction
Cross-Session Handoff
Yes — MEMORY directory accumulates across all sessions. No explicit handoff documents (unlike Continuous Claude's YAML handoffs); context is re-loaded from files at each session start.
Learning Capture
Three hooks capture signals about session quality:
WorkCompletionLearning.hook.ts — captures what was accomplished and how
SatisfactionCapture.hook.ts — captures satisfaction signals (explicit ratings, sentiment, verification outcomes)
RelationshipMemory.hook.ts — captures observations about people mentioned
These feed MEMORY/LEARNING/ for future sessions and the Algorithm's self-improvement loop.
Search Mechanism
Full-text via ripgrep (rg) — PAI explicitly chose ripgrep over vector search/RAG:
"Rich text with cross-references, plus fast search like ripgrep, gives us everything people normally want from RAG — without the embedding complexity, the retrieval flakiness, or the loss of fidelity. Your filesystem is the index."
The ContextSearch skill provides 2-phase prior PAI work search. The commands /cs and context-search invoke it.
Memory Tiers (Three Types)
From README:
"Three tiers (WORK, KNOWLEDGE, LEARNING) plus a typed graph across people, companies, ideas, and research."
WORK = active/recent; KNOWLEDGE = curated; LEARNING = retrospective. The RELATIONSHIP directory forms the typed graph layer for people/orgs.
Comparison to ccmemory
| Dimension |
PAI |
ccmemory |
| Storage |
Flat files (markdown) |
Neo4j graph + Docker |
| Search |
ripgrep full-text |
Vector cosine + full-text |
| Injection trigger |
LoadContext hook (session start) |
SessionStart hook |
| Memory extraction |
Hooks (WorkCompletionLearning) |
Stop hook (LLM detection) |
| Scope |
15 typed directories |
9 typed node types |
| Cross-project |
Global (~/.claude/PAI/) |
Global (Docker volume) |
| RAG |
Explicitly rejected since June 2025 |
Vector-based recall |