Give Your AI Agent Persistent Memory with ClawHub Skills
Learn how to give Claude Code persistent memory using the elite-longterm-memory, self-improving-agent, and ontology skills. Build an agent that remembers context across sessions.
Give Your AI Agent Persistent Memory with ClawHub Skills
Claude Code's default behavior is stateless. Every session starts from zero. The context window fills with the same project background, the same conventions, the same decisions — things the agent already "knows" from yesterday.
This isn't how senior developers work. A senior dev remembers your architecture decisions, your naming conventions, the bugs you've already fixed, and the direction you're heading. They don't need to be reminded every morning.
Three ClawHub skills — elite-longterm-memory, self-improving-agent, and ontology — give your agent the same kind of persistent context. This tutorial shows you how to install and configure each, and how to wire them together into a unified memory architecture.
The Memory Stack
Think of it as three layers:
| Layer | Skill | What It Stores |
|---|---|---|
| Episodic | self-improving-agent | What happened in past sessions, what worked, what didn't |
| Semantic | elite-longterm-memory | Facts about your project: architecture, conventions, decisions |
| Conceptual | ontology | Domain relationships and terminology specific to your codebase |
Each layer handles a different type of memory. Together, they produce an agent that knows your project the way a long-term team member does.
Layer 1: Elite Long-Term Memory
What It Does
elite-longterm-memory creates a persistent knowledge base from your conversations with Claude. When you explain your architecture, define a convention, or make a decision, the skill captures it and stores it in a structured format. Future sessions load relevant entries automatically.
Installation
clawhub install elite-longterm-memory
First Session Setup
After installing, run setup in your project:
/memory setup
This creates:
.claude/memory/knowledge.json— The knowledge store.claude/memory/index.json— The semantic search index.claude/memory/config.json— Configuration
Storing Knowledge
Tell the agent what to remember:
/memory save The auth system uses JWT tokens with a 24-hour expiry. Refresh tokens are stored in HttpOnly cookies and expire after 30 days. Never store tokens in localStorage.
Or teach it conventions:
/memory save Our API routes follow the pattern /api/v1/[resource]/[action]. Error responses always include a `code`, `message`, and optional `details` field. Success responses always include a `data` field.
Or capture architecture decisions:
/memory save We chose Zustand over Redux for state management on 2026-02-15. Reasoning: Redux was adding 600+ lines of boilerplate for minimal benefit. Zustand gives us the same capabilities with 80% less code. Decision was made by the team after a 2-week evaluation.
Automatic Loading
At the start of each session, the skill queries the knowledge store based on your current task and injects relevant entries. If you're working on auth, the JWT memory loads. If you're writing API routes, the API convention memory loads.
You control how much is loaded:
// .claude/memory/config.json
{
"auto_load": true,
"max_entries_per_session": 10,
"relevance_threshold": 0.65
}
Querying Memory Manually
/memory search auth
/memory search "API conventions"
/memory list --recent
Editing and Removing Entries
/memory edit [entry-id] New updated information here
/memory delete [entry-id]
Layer 2: Self-Improving Agent
The self-improving-agent skill handles episodic memory — what happened during past sessions and what the agent learned.
Installation
clawhub install self-improving-agent
Full setup and usage is covered in the self-improving agent tutorial. The key integration point: configure it to use the same memory directory as elite-longterm-memory:
// .claude/self-improve.config.json
{
"memory_store": ".claude/memory/reflections.json",
"share_context_with": ".claude/memory/knowledge.json"
}
With share_context_with set, the self-improving agent can reference factual memory when writing reflections. For example: "I initially implemented this the wrong way, but the JWT convention in memory clarified the approach."
Layer 3: Ontology
What It Does
ontology builds a domain model of your codebase: the concepts, their relationships, and the terminology your team uses. It's the most abstract layer — less about facts and events, more about meaning.
When your codebase uses "workspace" to mean a specific thing, or "subscriber" means something different from "user", the ontology skill captures those distinctions and ensures the agent never confuses them.
Installation
clawhub install ontology
Building Your Project Ontology
Start by generating an initial ontology from your codebase:
/ontology generate
The skill scans your project and produces a draft ontology:
{
"concepts": {
"User": {
"description": "An authenticated person with a ClawHub account",
"properties": ["id", "email", "github_username", "created_at"],
"related_to": ["Publisher", "Installation", "Review"],
"distinguished_from": "Creator (a User who has published skills)"
},
"Skill": {
"description": "A packaged Claude Code capability installable by Users",
"properties": ["name", "version", "type", "install_count", "rating"],
"types": ["command", "plugin", "agent"],
"related_to": ["Publisher", "Installation", "Review", "Category"]
},
"Installation": {
"description": "A record that a User has installed a specific Skill version",
"distinguished_from": "not the same as downloading — an Installation is active and managed"
}
}
}
Review and refine the generated ontology:
/ontology edit Skill The description should note that skills install to ~/.claude/commands/ or .claude/commands/ in the project root
/ontology add Creator A User who has published at least one Skill. Distinct from a User who only installs.
Runtime Impact
With the ontology active, when you ask the agent to "add a skill to a user's account", it knows you mean creating an Installation record — not modifying the User record. When you say "list the user's skills", it queries Installations, not a direct User.skills join.
This prevents an entire class of bugs that come from domain ambiguity.
Wiring the Stack Together
With all three skills installed, configure them to share context:
// .claude/memory/config.json
{
"stores": {
"knowledge": ".claude/memory/knowledge.json",
"reflections": ".claude/memory/reflections.json",
"ontology": ".claude/memory/ontology.json"
},
"session_load": {
"knowledge": true,
"reflections": true,
"ontology": true,
"max_total_entries": 15
}
}
Set a memory session summary at the end of long sessions:
/memory summarize-session
This writes a high-level summary of what was accomplished, decisions made, and any new conventions established. It's stored in the knowledge base and loaded in future sessions.
What the Agent Knows After One Week
Here's the kind of memory an agent accumulates after a week of active use:
From elite-longterm-memory:
- Your auth architecture (JWT + refresh tokens + HttpOnly cookies)
- API response format conventions
- Database schema decisions
- Team naming conventions
- Why you chose specific libraries
From self-improving-agent:
- That you prefer seeing the test file before the implementation
- That Server Components are your default for data fetching
- That you want TypeScript strictness enforced
- Which approaches have caused bugs in the past
From ontology:
- Domain-specific terminology
- Concept relationships
- What "user" vs "creator" vs "publisher" means in your system
Combined, a session that would start with 20 minutes of context-setting now starts immediately. The agent already knows your project.
Practical Session Start
With the memory stack configured, starting a Claude Code session looks like:
[Session start]
Loading memory context...
→ 4 knowledge entries (auth, API conventions, architecture, state management)
→ 3 recent reflections (test-first pattern, Server Components, TypeScript strict)
→ Ontology loaded (12 concepts)
Context loaded. Ready.
You open with:
Continue implementing the notifications feature we started yesterday
And the agent already knows:
- Your notification data model (from knowledge)
- That you want tests first (from reflections)
- The difference between User and Subscriber in your domain (from ontology)
No briefing required.
Storage and Privacy
All memory is stored locally in your project's .claude/memory/ directory. It never leaves your machine unless you explicitly share it (e.g., committing to a git repo for team sharing).
For team projects, commit the .claude/memory/ directory to share context across the team:
git add .claude/memory/
git commit -m "chore: share project memory context with team"
Each team member will have the shared knowledge base, but their own reflections (since reflections are personal workflow patterns).
Next Steps
- Set up the self-improving agent for the episodic memory layer
- Explore proactive agent patterns to use memory in automated workflows
- Browse all memory-related skills in the marketplace