User Memory
Module: Memory & Context | Lesson: 3 of 4 | Time: ~10 minutes
What You Will Learn
- What the
~/.claude/directory is and what it contains - How auto-memory works and what Claude saves automatically
- How to use the
/memorycommand to browse saved memories - How to set up a user-level CLAUDE.md for global preferences
- How to create personal rules that apply across all projects
Prerequisites
- Completed Project Memory with CLAUDE.md
The ~/.claude/ Directory
In the previous lesson, you learned about project-level memory with CLAUDE.md files. But what about preferences that apply to every project you work on? That is where your user-level configuration comes in.
Claude Code stores your personal settings in a hidden folder called ~/.claude/ in your home directory.
On Windows, ~ refers to your user home folder, which is typically C:\Users\YourName. So ~/.claude/ is C:\Users\YourName\.claude\. You can navigate there in File Explorer if you want to see the files directly.
Inside ~/.claude/, you will find several things:
| File or Folder | Purpose |
|---|---|
CLAUDE.md | Your global preferences (applies to ALL projects) |
rules/ | Personal rule files (applies to ALL projects) |
projects/ | Auto-saved memories organized by project |
settings.json | Claude Code configuration settings |
Auto-Memory: Claude Learns Automatically
One of Claude Code's most helpful features is auto-memory. As you work with Claude, it automatically notices patterns and saves useful information for future sessions.
For example, if you repeatedly correct Claude about your preferred indentation style, it may save a note like:
User prefers 4-space indentation in Python files
These automatic learnings are stored in the ~/.claude/projects/ folder, organized by project. You do not need to do anything to enable this — it happens automatically.
You will not see a big notification every time Claude saves something. It happens quietly in the background. The best way to see what Claude has learned is to use the /memory command.
The /memory Command
The /memory command lets you browse and manage what Claude has remembered:
You: /memory
This opens an interactive view where you can:
- See all saved memories for the current project
- Edit memories to correct anything wrong
- Delete memories you do not want
- Add new memories manually
This is a great way to check what Claude knows about you and your projects, and to clean up anything that is outdated or incorrect.
User-Level CLAUDE.md: Global Preferences
While each project has its own CLAUDE.md, you can also create one that applies to every project. This is your user-level CLAUDE.md, located at ~/.claude/CLAUDE.md.
This is perfect for personal preferences that you want everywhere:
# My Global Preferences
## Communication Style
- Explain things in simple terms
- Always show examples with your explanations
- When editing files, briefly explain what you changed and why
## Code Style (All Projects)
- Use descriptive variable names (not single letters)
- Add comments for complex logic
- Prefer readability over cleverness
## General Rules
- Always ask before deleting files
- Show me the diff before committing to Git
- If a task will take many steps, outline the plan first
Creating Your User-Level CLAUDE.md
You can ask Claude to create it:
You: Create a user-level CLAUDE.md at ~/.claude/CLAUDE.md with my
global preferences. I prefer simple explanations, descriptive
variable names, and I want you to always show diffs before
committing.
Or create it manually by opening the file in any text editor.
- User-level (
~/.claude/CLAUDE.md): Applies to every project. Put personal preferences here. - Project-level (
CLAUDE.mdin your project root): Applies to one project. Put project-specific details here.
If they conflict, the project-level file takes priority for that project.
Personal Rules with ~/.claude/rules/
Just like projects can have .claude/rules/ for path-specific instructions, you can create personal rules in ~/.claude/rules/ that apply across all your projects.
For example, you could create ~/.claude/rules/python-style.md:
---
description: My Python code style preferences
globs: "**/*.py"
---
- Use type hints for all function parameters and return values
- Use f-strings instead of .format() or % formatting
- Follow PEP 8 naming conventions
This rule would apply every time Claude works with Python files in any of your projects.
How All the Memory Layers Work Together
Here is the complete picture of how Claude's memory system layers together:
Session starts in ~/projects/my-website/frontend/
1. ~/.claude/CLAUDE.md (your global preferences)
2. ~/.claude/rules/*.md (your global rules, if files match)
3. ~/projects/my-website/CLAUDE.md (project instructions)
4. ~/projects/my-website/.claude/rules/*.md (project rules, if files match)
5. ~/projects/my-website/frontend/CLAUDE.md (subdirectory instructions)
6. Auto-memories from ~/.claude/projects/ (automatic learnings)
7. Current conversation context (what you say in this session)
Each layer adds information. They stack on top of each other, with more specific layers taking priority when there are conflicts.
You do not need all these layers right away. Most people start with just a project CLAUDE.md and add more as needed. A user-level CLAUDE.md is worth setting up early if you have strong preferences about how Claude communicates.
Try It Yourself
Let us explore your user-level memory:
- Open Claude Code in any project folder.
- Run
/memoryto see what Claude has already remembered about you and your projects. If you have been using Claude Code for a while, you might be surprised how much it has picked up. - Check for a user-level CLAUDE.md:
Does ~/.claude/CLAUDE.md exist? If so, what's in it? - Create or update your user-level CLAUDE.md if it does not exist:
Create ~/.claude/CLAUDE.md with these global preferences:
- Explain things simply, I'm learning
- Use descriptive variable names in code
- Always show me what you're about to change before doing it
- Prefer step-by-step approaches for complex tasks - Close Claude Code and reopen it. Notice that Claude now follows your global preferences from the very first message.
What You Learned
- The
~/.claude/directory stores your global Claude Code configuration and memories. - Auto-memory lets Claude save learnings automatically as you work together.
- The
/memorycommand lets you browse, edit, and manage saved memories. - A user-level CLAUDE.md (
~/.claude/CLAUDE.md) sets global preferences for all projects. - Personal rules (
~/.claude/rules/) apply path-specific instructions across all projects. - Memory layers stack: user-level, then project-level, then subdirectory-level, with more specific layers taking priority.
How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.