How to Give Claude Code Memory
Paste this into your project's claude.md:
## Memory Management
When you discover something valuable for future sessions — architectural decisions, bug fixes, gotchas, environment quirks — immediately append it to .claude/memory.md
Don't wait to be asked. Don't wait for session end.
Keep entries short: date, what, why. Read this file at the start of every session.
This costs almost zero tokens and survives crashes, compaction, and new sessions. Works on both Claude Code and Code for Claude Desktop
For short term (“Claude forgot what we discussed yesterday”) use --continue in Claude Code to continue the previous session. In the Desktop version, you have an UI for this.
—
Edited: After publishing this, Anthropic introduced auto memory for Claude Code. Cowork doesn't have it yet.
The method above still works — and has one advantage auto memory doesn't: it creates memory files you can share across surfaces (Code / Cowork / Web) via GitHub.
—
Advanced: Structured Memory
Split into multiple files so Claude loads only what's relevant:
## Memory Management
Maintain a structured memory system rooted at .claude/memory/
### Structure
- memory.md — index of all memory files, updated whenever you create or modify one
- general.md — cross-project facts, preferences, environment setup
- domain/{topic}.md — domain-specific knowledge (one file per topic)
- tools/{tool}.md — tool configs, CLI patterns, workarounds
### Rules
1. When you learn something worth remembering, write it to the right file immediately
2. Keep memory.md as a current index with one-line descriptions
3. Entries: date, what, why — nothing more
4. Read memory.md at session start. Load other files only when relevant
5. If a file doesn't exist yet, create it
### Maintenance
When I say "reorganize memory":
1. Read all memory files
2. Remove duplicates and outdated entries
3. Merge entries that belong together
4. Split files that cover too many topics
5. Re-sort entries by date within each file
6. Update memory.md index
7. Show me a summary of what changed
Example of what my Claude Code writes to /memory/tools/docker.md
## Docker
- 2026-02-12: Must use `host.docker.internal` not `localhost` for DB connections from containers — spent 30 min debugging this
- 2026-02-13: Project Dockerfile needs `--platform=linux/amd64` on M1 Macs or builds silently produce broken images
- 2026-02-13: docker compose v2 uses `docker compose` (no hyphen) — old scripts with `docker-compose` fail on CI
—
An alternative only for Claude Code (.md format is often more than you need): github.com/thedotmack/c…
/plugin marketplace add thedotmack/claude-mem
/plugin install claude-mem