When you run /memory in
Claude Code, it will open a menu that shows you every memory file currently
loaded in this session.
Researching /memory
You can find some
details on /memory at How Claude remembers your project https://code.claude.com/docs/en/memory [1]
Let’s run the /memory command and see what we get.
|
> /memory |
The first thing you will see here is the “Auto-memory” setting. It defaults to on.
What does this mean?
If this is set to “on” it might save memories from your
current session in the ~/.claude/projects/<your-project>/memory/
folder
Looking at what I have on my machine the <your-project> is a folder named
after the path where you are running Claude
For example I have ~/.claude/projects/-tmp/memory which means
it was saved when I ran claude in my /tmp folder
If I look in here I see a few memory files MEMORY.md and setup_fast_mode_indicator.md
The main file here is the MEMORY.md file. Claude will create/edit these sometimes based on what you are having Claude do. In my own case it does not seem to happen often. I have 62 project folders and only 5 have memory folders.
I need to do some more research to better understand this.
Let me walk down this one by one…
First one
- User memory Saved in ~/.claude/CLAUDE.md
This is talking about using your memory file located at ~/.claude/CLAUDE.md
In my case right now this file does not exist so… there is nothing to load… I think this just references it here to say you could persist memory to this file if you wanted to.
Let me do that and see if the prompt changes.
I am going to run this prompt
|
Create my personal user-level memory file at `~/.claude/CLAUDE.md`. If the file doesn't exist, create it with a clean basic structure. Add the following personal preferences: ## My Preferences ###
General Rules ###
Communication Style ###
Code Quality - Write
clean, readable code over clever code |
OK now let me run /memory again
|
> /memory |
The text did not change… seems odd to me
OK I can select it and press enter and it will open the CLAUDE.md file it referenced.
Hmmm let me set up a more robust example…
A more Robust example
OK let’s set up a better test. But first let’s walk through some isms.
- When you start Claude code it will load several memory files
- The first one it will load is User memory file which is located at ~/.claude/CLAUDE.md (this will apply to any instance of Claude you are running on your system)
- The next memory(ies) will be loaded from the ~/.claude/rules folder. Here you can put several Markdown files that can have unique names
- The next memory(ies) will be loaded from the local directory or any directory above it. This file must be called CLAUDE.md. As an example you could have a CLAUDE.md file in the base of your git repo. And/or you could also have the file in a .claude directory so .claude/CLAUDE.md
- Next you have Project memory which are memories auto created/edited/saved by Claude and placed in ~/.claude/projects/<your-project>/memory/
- Last you load Agent Memory user scope and project scope
- One special case!! Any memory file can reference another file using the @filename Any file referenced like this does not need to be a Markdown but it needs to be text
OK I think I understand the rules well enough now so let’s
make an example.
1. Confirm you have a ~/.claude/CLAUDE.md file (it not make one)
|
> cat ~/.claude/CLAUDE.md |
2. Put a memory file in the ~/.claude/rules folder
|
> mkdir ~/.claude/rules |
Put this in it
|
# Git Workflow - Use
conventional commit messages (e.g., `feat:`, `fix:`, `refactor:`) |
3. Create a folder structure and place some CLAUDE.md files in it.
|
> mkdir -p /tmp/one_dir/two_dir/three_dir |
Now create the CLAUDE.md files
|
> vi /tmp/one_dir/.claude/CLAUDE.md |
Place the following in it
|
# General Coding Rules ## Core
Principles - Write
clean, readable code over clever code ## Code
Quality ##
Error Handling |
I am going to lazy copy this to the next directory
|
> cp /tmp/one_dir/.claude/CLAUDE.md
/tmp/one_dir/two_dir/.claude/CLAUDE.md |
Then for the final one
|
> vi
/tmp/one_dir/two_dir/three_dir/.claude/CLAUDE.md |
Place this in it
|
# Project Memory ##
Reference Data - **US States**: See @us_states.json (contains state name, capital, and population for all 50 states) ##
Rules |
You can see here it references another memory file
@us_states.json
Now let’s create that file
|
> vi
/tmp/one_dir/two_dir/three_dir/.claude/us_states.json |
And place the following in it
|
[ {"state":
"Alabama", "capital": "Montgomery",
"population": 5108468}, |
OK now lets go the final folder and start claude
|
> cd /tmp/one_dir/two_dir/three_dir/ |
Now run /memory
|
> /memory |
Now what do we see?
We see the User memory as expected but below that we now see the ~/.claude/rules/git-workflow.md file
And after that we see the different CLAUDE.md files that are
being taken in that are higher up in the directories from where we started
/tmp/CLAUDE.md
/tmp/one_dir/.claude/CLAUDE.md
/tmp/one_dir/two_dir/.claude/CLAUDE.md
If I scroll down further I can see the .claude/CLAUDE.md in the folder I started Claude code in and I can see the memory file it references us_states.json
After that I see project memory, then auto-memory and finally any memory folders attached to any agents I have created locally or that happen to be in the project I am in.
OK neat I think I am getting this.
Final Thoughts
I need to do some more research on this…
But the walk away is you can put information that you want
to persist between sessions in your memory files (Typically CLAUDE.md files).
There is a structure to it, some are on your user level in ~/.claude and some
can be on the project level. Running
/memory will show you what was loaded.
I do need to do some more research on creating useful
memories, but I think that if you pre-populate your local memory files you can
get a big boost in doing your daily tasks.
In the same vein if you make good Memory files in a project you can help
everyone get their job done better when running Claude from within a project.
… The research goes on…
References
[1] How Claude
remembers your project
https://code.claude.com/docs/en/memory
Accessed 07/2026
No comments:
Post a Comment