Memory provides persistent context across Claude Code sessions by storing and retrieving project decisions, user preferences, and coding conventions from a local JSON file. When a new session starts, stored memories load automatically so previously established patterns carry forward without re-explanation.
.claude/memories/project_memory.json (created automatically on first memory save).claude/memories/ directory/plugin install yldrmahmet/claude-never-forgets).claude/memories/project_memory.json using the Read tool. Parse the JSON structure containing timestamped memory entries. See ${CLAUDE_SKILL_DIR}/references/implementation.md for the full retrieval workflow./remember command or through automatic capture of conversation signals.hooks/stop_cleanup.py./memories command| Error | Cause | Solution |
|---|---|---|
| Memory file not found | First session or file deleted | Initialize a new memory file at .claude/memories/project_memory.json with an empty JSON structure |
| Conflicting memories | Multiple entries contradict each other | Apply the most recent memory; suggest cleanup via /forget to remove outdated entries |
| Invalid memory format | File corrupted or manually edited with syntax errors | Back up the existing file, recreate with valid JSON structure, restore recoverable entries |
| Permission denied | File or directory lacks read/write permissions | Check file permissions on .claude/memories/; request necessary access or use an alternative storage location |
Automatic preference recall across sessions:
Session 1:
User: "Always use Vitest instead of Jest for this project"
→ Stored to project_memory.json
Session 2:
User: "Add tests for the auth module"
→ Memory loaded: "use Vitest instead of Jest"
→ Test files created with Vitest syntax automatically
Manual memory management:
/remember "This project uses Tailwind CSS v4 with the Vite plugin"
/remember "Deploy to Cloudflare Workers, not Vercel"
/memories # Lists all stored memories with timestamps
/forget "Vercel" # Removes the Vercel-related memory
Tool rejection captured as correction:
set -euo pipefail
User declines a suggested `npm install` action
→ Memory stored: "User prefers pnpm over npm"
→ Future sessions use pnpm automatically
${CLAUDE_SKILL_DIR}/references/implementation.md -- Step-by-step guide for accessing, applying, updating, and resolving memory conflicts${CLAUDE_SKILL_DIR}/references/errors.md -- Detailed error scenarios with recovery procedures/remember [text] -- Add a new memory entry manually/forget [text] -- Remove a matching memory from storage/memories -- Display all currently stored memories with timestamps