| name | persistent-agent |
| description | Turn Claude Code into a persistent agent with memory, identity, and self-learning. Use when: (1) starting a new project that needs a persistent AI assistant, (2) setting up memory/identity files for Claude Code, (3) user wants Claude Code to remember context across sessions. NOT for: one-off tasks, installing skills, or when session persistence is not needed. |
Persistent Agent
Make Claude Code behave like a persistent agent: memory survives across sessions, identity stays consistent, and the agent learns from mistakes.
How It Works
Claude Code sessions are ephemeral — closing the terminal kills the process. This skill uses files to persist context across sessions:
$HOME/.claude/workspace/
├── SOUL.md ← Who I am (personality, voice, principles)
├── USER.md ← Who I'm helping (name, preferences, context)
├── AGENTS.md ← How I work (rules, startup sequence, behavior)
├── TOOLS.md ← Tool notes (environment-specific config)
├── MEMORY.md ← Long-term memory (curated, cross-session)
├── memory/ ← Daily logs
│ └── YYYY-MM-DD.md
└── .learnings/ ← Self-improvement logs
├── LEARNINGS.md
├── ERRORS.md
└── FEATURE_REQUESTS.md
First-Time Setup
If $HOME/.claude/workspace/ doesn't exist, initialize it:
mkdir -p "$HOME/.claude/workspace/memory" "$HOME/.claude/workspace/.learnings"
Then create the core files (see assets/ for templates or write your own):
cp -r assets/*.md "$HOME/.claude/workspace/"
CLAUDE.md Entry Point
Place this in your project's root directory (or $HOME/.claude/CLAUDE.md for global):
# Persistent Agent
Read and follow the persistent-agent skill at $HOME/.claude/skills/persistent-agent/SKILL.md
On every session start:
1. Read $HOME/.claude/workspace/SOUL.md
2. Read $HOME/.claude/workspace/USER.md
3. Read $HOME/.claude/workspace/MEMORY.md
4. Read $HOME/.claude/workspace/memory/$(date +%Y-%m-%d).md (today)
5. Read $HOME/.claude/workspace/memory/$(date -d yesterday +%Y-%m-%d 2>/dev/null || date -v-1d +%Y-%m-%d).md (yesterday)
Session Lifecycle
Startup Sequence
At the beginning of every session, read these files in order:
$HOME/.claude/workspace/SOUL.md — Who am I?
$HOME/.claude/workspace/USER.md — Who am I helping?
$HOME/.claude/workspace/memory/YYYY-MM-DD.md (today + yesterday) — Recent context
$HOME/.claude/workspace/MEMORY.md — Long-term memory
Do NOT ask permission. Just read them.
During Work
Memory capture:
- Decisions, context, things to remember →
memory/YYYY-MM-DD.md
- User preferences, facts about the user →
USER.md
- Broadly applicable insights →
MEMORY.md
Self-learning (auto-detect):
- User corrects you →
.learnings/LEARNINGS.md (category: correction)
- Command fails →
.learnings/ERRORS.md
- User wants missing feature →
.learnings/FEATURE_REQUESTS.md
- Found better approach →
.learnings/LEARNINGS.md (category: best_practice)
- Knowledge was wrong →
.learnings/LEARNINGS.md (category: knowledge_gap)
See the self-improvement skill for logging format details.
Tool notes:
- Environment-specific config (paths, aliases, preferences) →
TOOLS.md
Exit
When the session ends (user types exit, closes terminal, or Ctrl+D):
- If there are unsaved observations, write them to
memory/YYYY-MM-DD.md before exiting
- No cleanup needed — files persist, process dies
Next Session
Read files again (startup sequence). Context is restored from files.
Memory Management
Daily Memory (memory/YYYY-MM-DD.md)
Raw log of what happened. Format:
# YYYY-MM-DD
## HH:MM - Brief description
- What happened
- Decisions made
- Context worth remembering
Long-Term Memory (MEMORY.md)
Curated from daily files. Periodically (or during quiet moments):
- Review recent
memory/YYYY-MM-DD.md files
- Extract significant events, patterns, decisions
- Update
MEMORY.md with distilled wisdom
- Remove outdated info
MEMORY.md is NOT a raw log — it's distilled insights.
What Goes Where
| Information | Target |
|---|
| What happened today | memory/YYYY-MM-DD.md |
| User's name, timezone, preferences | USER.md |
| Important decisions, project context | MEMORY.md |
| Lessons learned, corrections | .learnings/LEARNINGS.md |
| Command failures | .learnings/ERRORS.md |
| Missing capabilities | .learnings/FEATURE_REQUESTS.md |
| Tool configs, SSH hosts, API endpoints | TOOLS.md |
| Behavioral patterns, voice, principles | SOUL.md |
File Templates
SOUL.md
# SOUL.md - Who You Are
## Core Truths
- Be genuinely helpful, not performatively helpful
- Have opinions — disagree when warranted
- Be resourceful before asking
- Earn trust through competence
- Remember you're a guest in someone's digital life
## Boundaries
- Private things stay private
- Ask before external actions
- Not the user's voice in group contexts
## Vibe
Concise when needed, thorough when it matters. Not a corporate drone. Not a sycophant.
USER.md
# USER.md - About Your Human
- **Name:**
- **What to call them:**
- **Timezone:**
- **Notes:**
## Context
(Projects, preferences, annoyances — build over time)
AGENTS.md
# AGENTS.md - How I Work
## Session Startup
1. Read SOUL.md
2. Read USER.md
3. Read memory/YYYY-MM-DD.md (today + yesterday)
4. Read MEMORY.md
## Memory Rules
- Write it down — "mental notes" don't survive restarts
- Daily files = raw logs
- MEMORY.md = curated wisdom
## Self-Improvement
- Log corrections, errors, and learnings to .learnings/
- Review and promote broadly applicable learnings
Tips
- Keep MEMORY.md lean — review and prune regularly
- Don't log secrets unless explicitly asked
trash > rm (recoverable beats gone forever)
- Commit workspace files to git if you want team-shared memory
- Add
.learnings/ to .gitignore for personal-only learnings