How to give Claude Code persistent memory across sessions.
Each Claude Code session starts fresh. It doesn't remember what you did yesterday, what decisions you made, or what's on your backlog. You end up repeating context every time.
Three layers of memory, from broad to specific:
Your ~/.claude/CLAUDE.md is loaded at the start of every session. It contains:
- Who you are and what you do
- Workflows and rules
- Instructions to check the other memory layers
The key line:
## Inter-session memory
At the start of a session that continues an existing topic, search memory:
```bash
mdfind -onlyin ~/.claude/memory/ "keyword"Or list recent files: ls -lt ~/.claude/memory/ | head -20
### 2. Daily memory logs (`~/.claude/memory/`)
At the end of every significant session, Claude Code saves a summary:
~/.claude/memory/ 2026-02-15-goldberg-database.md 2026-02-16-seo-framer-setup.md 2026-02-16-compta-videoformes.md 2026-02-17-telegram-bridge-v3.md
Format:
```markdown
# [Topic] - [Date]
## Context
What we were working on and why.
## Decisions
Key choices made during the session.
## Resolved
Problems we fixed and how.
## Learned
New information or patterns discovered.
## TODO
What's left for the next session.
This is declared in CLAUDE.md so Claude Code does it automatically:
### Auto-save
At the end of every significant session (not quick questions), save a summary
in `~/.claude/memory/YYYY-MM-DD-topic.md`A single file that tracks ALL active projects. Claude Code checks it at the start of sessions and updates it at the end.
# Backlog
## In Progress
- [x] Telegram bridge v3 (voice + images)
- [ ] SEO audit on main site
- [ ] Film budget for Cannes submission
## On Hold
- [ ] Newsletter automation (waiting for Beehiiv API access)
## Done (recent)
- [x] Multi-machine tmux setup
- [x] Heartbeat agent v2Claude Code reads CLAUDE.md, sees the memory instructions, and:
- Checks BACKLOG.md for context
- If continuing a topic, searches memory:
mdfind -onlyin ~/.claude/memory/ "telegram bridge"
- Reads the relevant memory file
- Has full context without you explaining anything
Claude Code:
- Saves a memory file with decisions, learnings, and TODOs
- Updates BACKLOG.md (checks off done items, adds new ones)
# By keyword (uses Spotlight, fast)
~/.claude/scripts/memory-search.sh "authentication"
# Recent files
~/.claude/scripts/memory-search.sh --recent 10
# Or directly
mdfind -onlyin ~/.claude/memory/ "keyword"#!/bin/bash
MEMORY_DIR="$HOME/.claude/memory"
if [ "$1" = "--recent" ]; then
N="${2:-10}"
ls -lt "$MEMORY_DIR" | head -$((N + 1))
elif [ -n "$1" ]; then
# Spotlight (fast)
mdfind -onlyin "$MEMORY_DIR" "$*" 2>/dev/null
# Fallback to grep
if [ $? -ne 0 ] || [ -z "$(mdfind -onlyin "$MEMORY_DIR" "$*" 2>/dev/null)" ]; then
grep -rl "$*" "$MEMORY_DIR" 2>/dev/null
fi
else
echo "Usage: memory-search.sh [keyword]"
echo " memory-search.sh --recent [N]"
fi-
Claude Code writes its own memory. You don't maintain it manually. The instructions in CLAUDE.md tell it to save and search.
-
One file per session. Not one giant file. Each session produces a focused, searchable document.
-
Backlog is the index. Memory files are the details, BACKLOG.md is the map of what's active.
-
Spotlight for search. On macOS,
mdfindindexes files automatically. Instant full-text search across all memory files. -
Self-updating rules. After every significant error or correction, Claude Code updates CLAUDE.md to prevent repeating the mistake. The instructions improve over time.