The Core Concept
A MemPalace specialist agent is an AI role — code reviewer, system architect, security analyst, ops engineer — that maintains its own dedicated palace wing and a personal diary written in AAAK format. Unlike a general-purpose AI that starts each session without context, a specialist agent reads its diary before beginning work. It enters each session knowing every relevant pattern it has identified, every decision it has participated in, and every problem it has seen before.
The agent builds genuine expertise over time. A code reviewer that has processed 200 pull requests over three months carries a concrete record of every recurring bug pattern, every near-miss, and every architectural concern it raised. That history is small in token terms but significant in practical value.
How the Mechanism Works
Each agent is defined by a JSON file in ~/.mempalace/agents/. The file specifies the agent's name, its focus domain, its assigned wing in the palace, and the diary format to use. The CLAUDE.md configuration file for your project does not need to list agents individually — it only needs a single line that tells Claude to check for them at runtime:
You have MemPalace agents. Run mempalace_list_agents to discover them.This single line stays constant regardless of whether you have one agent or fifty. Claude discovers agents dynamically by calling the MCP tool, which means adding a new agent never requires editing CLAUDE.md.
Configuring Your Agents
Create a JSON file for each agent role in ~/.mempalace/agents/:
{
"name": "reviewer",
"focus": "code quality, security vulnerabilities, recurring bug patterns",
"wing": "wing_reviewer",
"diary_format": "aaak"
}
The focus field is a plain-text description of what the agent pays attention to. The agent reads this at session start so it knows what to look for. The wing field assigns a dedicated palace wing — the agent's memories are isolated from general palace content, which keeps search results clean.
Create one file per domain. There is no limit on agent count:
reviewer.json ← code quality, security, bug patterns architect.json ← design decisions, ADRs, system tradeoffs ops.json ← deployments, incidents, infrastructure changes security.json ← vulnerability findings, compliance issues performance.json ← bottlenecks, profiling results, optimisations
What Happens During a Session
When Claude starts a session in a project using MemPalace agents, the sequence is automatic:
- Claude reads CLAUDE.md and sees the agent discovery line
- Claude calls
mempalace_list_agentsand receives the list of configured agents - For the current task — say, a code review — Claude calls
mempalace_diary_read("reviewer", last_n=10) - The diary returns the reviewer's last 10 entries in AAAK format, giving Claude a concrete record of recent findings
- Claude performs the review with that accumulated context available — it knows what patterns the reviewer has seen before
- After the review, Claude calls
mempalace_diary_write("reviewer", entry)to record the session's findings - The next session begins with that entry in the diary
Diary Entry Format
Diary entries are written in AAAK — compact, pipe-delimited, readable by any LLM. A typical entry captures: identifier, finding type, specific location, contextual note, severity.
# Code reviewer findings PR#42|auth.bypass|missing.middleware.check|pattern:3x.this.quarter|★★★★ PR#51|n+1.query|posts.endpoint|eager.load.fix.applied|★★★ PR#58|hardcoded.secret|config.js:line.34|moved.to.env|★★★★★ # Architect decisions ADR#12|graphql.adopted|concurrent.write.req+10GB.dataset|2026-01-15|Maya.approved ADR#15|redis.cache.added|p95.latency.420ms→38ms|load.test.2026-02-20|unanimous # Ops incidents and deployments INC#08|db.cpu.spike|missing.index.on.user_id|p0.resolved.30min|2026-02-14 DEPLOY#27|auth-service.v2.3.canary|zero.errors.after.2h|full.rollout.approved
The format is intentionally flexible — the agent writes what is useful to read back later, not what fits a rigid schema. The AAAK pipe-delimiter structure ensures tokens are used efficiently without sacrificing readability.
Example Agent Configurations
# architect.json { "name": "architect", "focus": "system design decisions, architectural tradeoffs, ADRs, technical debt", "wing": "wing_architect", "diary_format": "aaak" } # ops.json { "name": "ops", "focus": "deployments, incidents, infrastructure changes, on-call patterns", "wing": "wing_ops", "diary_format": "aaak" }
Cost Comparison with Letta
| Factor | MemPalace Agents | Letta |
|---|---|---|
| Monthly cost | $0 | $20–200/month |
| Annual cost | $0 | $240–2,400/year |
| Infrastructure | Local — nothing to host | Cloud — managed for you |
| Agent count limit | No limit | Scales with plan |
| CLAUDE.md complexity | One line, never changes | Configuration-per-agent |
| Data privacy | Never leaves your machine | Cloud-hosted |
| Enterprise support | Community only | Yes |
Practical Tips
- Keep focus areas narrow and specific. "Security vulnerabilities in authentication and session handling code" will produce more useful diary entries than "security." Specificity helps the agent know what to notice and what to record.
- Match last_n to the task. Reading
last_n=5is fast and sufficient for routine tasks. Readinglast_n=20provides richer historical context for major decisions — use it when that context will materially affect the outcome. - Let agents cross-reference the main palace. An agent can search not only its own wing but the full palace. A security agent investigating an auth issue can call
mempalace_search("auth token handling", wing="wing_security")to pull from its own history, or omit the wing filter to search across everything. - Review diary entries occasionally. AAAK entries are designed to be read by both the AI and the developer. Reviewing them periodically can surface patterns that neither you nor the AI consciously noticed accumulating.