Companion repo for CC-013. Covers triggering memory, structuring MEMORY.md with index and topic files, and proving cross-session persistence shapes Claude behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
112 lines
2.7 KiB
Markdown
112 lines
2.7 KiB
Markdown
# Exercise 01: Trigger Memory
|
|
|
|
**Concept:** Auto Memory (CC-013)
|
|
**Level:** Basic
|
|
**Time:** ~10 minutes
|
|
|
|
---
|
|
|
|
## Objective
|
|
|
|
Tell Claude something to remember, verify the memory file was created,
|
|
and confirm it survives a new session.
|
|
|
|
This is your first hands-on contact with auto memory. No prior experience
|
|
with Claude Code memory required.
|
|
|
|
---
|
|
|
|
## Before You Start
|
|
|
|
Confirm you have:
|
|
|
|
- [ ] Claude Code v2.1.59 or later installed (`claude --version` prints a version)
|
|
- [ ] This repo cloned and open in Claude Code
|
|
- [ ] Started Claude Code in this directory (`claude`)
|
|
|
|
---
|
|
|
|
## Instructions
|
|
|
|
**Step 1:** Start Claude Code in this directory.
|
|
|
|
```bash
|
|
cd claude-code-auto-memory
|
|
claude
|
|
```
|
|
|
|
**Step 2:** Paste this prompt into Claude Code:
|
|
|
|
```
|
|
Remember that I prefer 2-space indentation and single quotes in TypeScript.
|
|
```
|
|
|
|
Claude will confirm the preference and save it to memory. You should see
|
|
a tool call to write a file under `~/.claude/projects/`.
|
|
|
|
**Step 3:** Find the memory file that was just created.
|
|
|
|
Paste this into Claude Code:
|
|
|
|
```
|
|
Where did you save that memory? Show me the path and the file contents.
|
|
```
|
|
|
|
Claude will tell you the exact path. It will be somewhere under:
|
|
|
|
```
|
|
~/.claude/projects/<project-hash>/memory/
|
|
```
|
|
|
|
The `<project-hash>` is a deterministic hash of the project directory path.
|
|
You can also find it yourself:
|
|
|
|
```bash
|
|
ls ~/.claude/projects/
|
|
```
|
|
|
|
Look for a directory that corresponds to this repo. Open the memory file
|
|
inside it and read what was saved.
|
|
|
|
**Step 4:** Start a new session and test recall.
|
|
|
|
In Claude Code, type `/clear` to start a fresh conversation. Then paste:
|
|
|
|
```
|
|
What are my TypeScript preferences?
|
|
```
|
|
|
|
Claude should recall 2-space indentation and single quotes without you
|
|
repeating them.
|
|
|
|
---
|
|
|
|
## Expected Output
|
|
|
|
After completing the steps above, you should see:
|
|
|
|
- A new file in `~/.claude/projects/<project-hash>/memory/` containing
|
|
your TypeScript preferences
|
|
- Claude confirming the memory was saved during Step 2
|
|
- After `/clear`, Claude recalling both preferences without any prompt
|
|
|
|
If Claude says it has no preferences on file, check that you are in the
|
|
same directory as Step 1. The project hash is derived from the directory
|
|
path, so a different working directory means a different memory store.
|
|
|
|
---
|
|
|
|
## What You Learned
|
|
|
|
- **"Remember" is the trigger:** Phrases like "remember that" or "save this"
|
|
cause Claude to write a memory file explicitly
|
|
- **Project-scoped storage:** Memories are stored per project, not globally,
|
|
so different projects have separate memory stores
|
|
- **Machine-local:** The memory files are on your machine only. They are not
|
|
in git and not shared across machines.
|
|
|
|
---
|
|
|
|
## Next
|
|
|
|
Ready to go further? Move to [Exercise 02: Structure Memory](./02-structure-memory.md).
|