mempalace-ai-memory
```markdown
What this skill does
```markdown
---
name: mempalace-ai-memory
description: MemPalace is a local-first AI memory system using palace-structure retrieval and AAAK compression, achieving 96.6%+ recall on LongMemEval benchmarks.
triggers:
- set up AI memory for my project
- remember my conversations with Claude
- search my past AI chat history
- connect memory to my local LLM
- store and retrieve AI conversation context
- set up MCP memory server
- mine my chat exports for memory
- query what we decided about a topic
---
# MemPalace AI Memory System
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
MemPalace is a local-first AI memory system that stores all your AI conversations and makes them searchable with 96.6%+ recall. It organizes memory into a hierarchical "palace" structure (wings → rooms → closets → drawers) and uses AAAK — a lossless compression dialect — to deliver months of context in ~170 tokens. Runs entirely on your machine with no cloud API required.
---
## Installation
```bash
pip install mempalace
```
Verify install:
```bash
mempalace --version
mempalace status
```
---
## Initial Setup
### 1. Initialize a Palace
```bash
# Initialize for a specific project directory
mempalace init ~/projects/myapp
# This creates ~/.mempalace/palace/ with the wing/room/closet/drawer structure
# MemPalace auto-detects rooms (topics) from the project
```
### 2. Mine Your Data
Three mining modes:
```bash
# Mode: projects — code, docs, notes
mempalace mine ~/projects/myapp
# Mode: convos — Claude, ChatGPT, Slack exports
mempalace mine ~/chats/ --mode convos
# Mode: general — auto-classifies into decisions, preferences,
# milestones, problems, and emotional context
mempalace mine ~/chats/ --mode convos --extract general
```
Mining is a one-time operation per dataset. Re-run when you have new exports.
### 3. Verify
```bash
mempalace status
# Shows wings, rooms, and memory counts
```
---
## Key CLI Commands
| Command | Purpose |
|---|---|
| `mempalace init <path>` | Initialize palace for a project |
| `mempalace mine <path>` | Mine project files into memory |
| `mempalace mine <path> --mode convos` | Mine conversation exports |
| `mempalace mine <path> --mode convos --extract general` | Mine + classify |
| `mempalace search "<query>"` | Search all memories |
| `mempalace wake-up` | Output critical context (~170 tokens) for LLM injection |
| `mempalace status` | Show palace structure and memory stats |
---
## MCP Server (Claude, ChatGPT, Cursor)
Connect once and your AI uses memory automatically:
```bash
# Add MemPalace as an MCP server in Claude Code
claude mcp add mempalace -- python -m mempalace.mcp_server
```
After connecting, Claude gets 19 tools including `mempalace_search`. Users just ask naturally:
> *"What did we decide about auth last month?"*
Claude calls `mempalace_search` automatically — no manual commands needed.
### Available MCP Tools (subset)
- `mempalace_search` — semantic search across all memories
- `mempalace_wake_up` — load critical facts into context
- `mempalace_add_memory` — store a new memory from conversation
- `mempalace_list_wings` — list all people/projects in the palace
- `mempalace_list_rooms` — list rooms within a wing
---
## Python API
### Search Memories
```python
from mempalace.searcher import search_memories
results = search_memories(
query="why did we switch to GraphQL",
palace_path="~/.mempalace/palace",
top_k=5
)
for result in results:
print(result["content"])
print(result["source"]) # drawer path
print(result["score"]) # relevance score
```
### Store a Memory
```python
from mempalace.memory import store_memory
store_memory(
content="Decided to use PostgreSQL over MySQL for JSONB support.",
wing="myapp-project",
room="decisions",
palace_path="~/.mempalace/palace"
)
```
### Load Wake-Up Context
```python
from mempalace.wakeup import generate_wakeup
context = generate_wakeup(
palace_path="~/.mempalace/palace",
use_aaak=True # AAAK compression — ~170 tokens
)
# Inject into your local LLM's system prompt
system_prompt = f"You have access to the following memory context:\n{context}"
```
### Mine Conversations Programmatically
```python
from mempalace.miner import mine_directory
mine_directory(
source_path="~/chats/",
mode="convos",
extract="general", # decisions, preferences, milestones, problems
palace_path="~/.mempalace/palace"
)
```
---
## Local LLM Integration (Offline)
### Option 1: Wake-Up Injection
```bash
mempalace wake-up > context.txt
```
```python
import subprocess
context = subprocess.check_output(["mempalace", "wake-up"]).decode()
# Inject into Ollama / llama.cpp / any local LLM
import ollama
response = ollama.chat(
model="llama3",
messages=[
{"role": "system", "content": f"Memory context:\n{context}"},
{"role": "user", "content": "What did we decide about the database?"}
]
)
```
### Option 2: On-Demand Search → Prompt Injection
```python
from mempalace.searcher import search_memories
import ollama
query = "auth implementation decisions"
memories = search_memories(query, palace_path="~/.mempalace/palace", top_k=5)
memory_text = "\n\n".join(m["content"] for m in memories)
response = ollama.chat(
model="mistral",
messages=[
{
"role": "system",
"content": f"Relevant memory context:\n{memory_text}"
},
{"role": "user", "content": query}
]
)
print(response["message"]["content"])
```
---
## Palace Structure
```
~/.mempalace/palace/
├── wings/
│ ├── myapp-project/
│ │ ├── rooms/
│ │ │ ├── decisions/
│ │ │ │ ├── closet/ ← compressed summaries (fast AI reads)
│ │ │ │ └── drawers/ ← original verbatim files (never lost)
│ │ │ ├── auth/
│ │ │ └── billing/
│ │ └── halls.json ← connections between rooms
│ └── john-doe/
│ └── rooms/
│ └── preferences/
├── tunnels.json ← cross-wing connections
└── palace.json ← palace metadata
```
- **Wings** — a person or project
- **Rooms** — topics within a wing (auto-detected or custom)
- **Halls** — links between related rooms in the same wing
- **Tunnels** — links between rooms across different wings
- **Closets** — compressed summaries pointing to drawers (fast retrieval)
- **Drawers** — verbatim original content (never summarized or lost)
---
## AAAK Compression
AAAK is MemPalace's internal compression dialect — structured text readable by any LLM, no decoder needed.
```python
from mempalace.aaak import encode_to_aaak, decode_from_aaak
# Encode a large context block
aaak_text = encode_to_aaak(long_context_string)
# ~30x compression, zero information loss
# Decode back for human reading
original = decode_from_aaak(aaak_text)
```
AAAK is injected automatically in `wake-up` output when `--aaak` flag is used:
```bash
mempalace wake-up --aaak
# Returns ~170 tokens covering your full palace summary
```
---
## Common Patterns
### Pattern: Daily Conversation Mining
```python
import schedule
from mempalace.miner import mine_directory
def nightly_mine():
mine_directory(
source_path="~/Downloads/claude-exports/",
mode="convos",
extract="general",
palace_path="~/.mempalace/palace"
)
schedule.every().day.at("02:00").do(nightly_mine)
```
### Pattern: Search Before Answering
```python
from mempalace.searcher import search_memories
def answer_with_memory(user_question: str, llm_client) -> str:
# Retrieve relevant memories first
memories = search_memories(
query=user_question,
palace_path="~/.mempalace/palace",
top_k=5
)
context_blocks = [m["content"] for m in memories if m["score"] > 0.7]
context = "\n---\n".join(context_blocks)
return llm_client.complete(
system=f"Past context:\n{context}" if context else "",
user=usRelated 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.