> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/jackdog668/claude-code/llms.txt
> Use this file to discover all available pages before exploring further.

# memory

> Edit Claude memory files (CLAUDE.md) to give Claude persistent instructions.

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
```

<Note>
  The editor is determined by the `$VISUAL` environment variable, then
  `$EDITOR`. If neither is set, a platform default is used.
</Note>

## 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.

| Priority | Location                                           | Scope                            |
| -------- | -------------------------------------------------- | -------------------------------- |
| 1        | Managed memory (e.g. `/etc/claude-code/CLAUDE.md`) | All users on the system          |
| 2        | `~/.claude/CLAUDE.md`                              | Your user account — all projects |
| 3        | `CLAUDE.md` in the project root                    | Project — checked into git       |
| 4        | `.claude/CLAUDE.md` in the project root            | Project — checked into git       |
| 5        | `.claude/rules/*.md` in the project root           | Project — 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
```

<Tip>
  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).
</Tip>

## Example memory file

```markdown CLAUDE.md theme={null}
# 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.
