Skip to main content
The /memory slash command opens a file selector that lets you choose and edit a CLAUDE.md memory file in your configured editor. Memory files give Claude persistent instructions that are automatically included at the start of every session.
/memory
The editor is determined by the $VISUAL environment variable, then $EDITOR. If neither is set, a platform default is used.

How memory works

Claude Code loads memory from several locations in order. Each file’s content is prepended to the system prompt before the session starts.
PriorityLocationScope
1Managed memory (e.g. /etc/claude-code/CLAUDE.md)All users on the system
2~/.claude/CLAUDE.mdYour user account — all projects
3CLAUDE.md in the project rootProject — checked into git
4.claude/CLAUDE.md in the project rootProject — checked into git
5.claude/rules/*.md in the project rootProject — per-rule files
Claude also walks parent directories up to the filesystem root, loading any CLAUDE.md files it finds along the way. Additional directories passed with --add-dir are scanned for CLAUDE.md files using the same rules.

Selecting a memory file

When you run /memory, a dialog presents the available memory files. Select one to open it in your editor. If the file does not yet exist it is created automatically.
/memory
Use ~/.claude/CLAUDE.md for instructions that apply to every project (coding style preferences, tool preferences, etc.) and CLAUDE.md in a project root for project-specific context (architecture notes, conventions, frequently used commands).

Example memory file

CLAUDE.md
# Project conventions

- All new files must have a JSDoc comment at the top.
- Run `npm test` before marking a task complete.
- Prefer functional React components over class components.

## Directory layout

- `src/` — application source
- `tests/` — unit and integration tests
- `scripts/` — one-off helper scripts (not imported by the app)

Excluding memory files

Files can be excluded via the claudeMdExcludes setting if you want Claude to ignore specific CLAUDE.md files in certain paths.

The /memory command inside a session

Run /memory at any time during an interactive session to edit memory files without restarting. Changes take effect the next time a new session is started.

Build docs developers (and LLMs) love