Skip to main content
Claude Mem can automatically generate CLAUDE.md files in your project folders. Each file contains a timeline of recent activity in that directory, giving Claude immediate awareness of what work has been done and where — without needing to search for it.
This feature is disabled by default. Enable it in ~/.claude-mem/settings.json.

How it works

When you work with Claude Code in a project, Claude Mem tracks which files are read and modified. After each observation is saved, it automatically:
  1. Identifies unique folder paths from the touched files
  2. Queries recent observations relevant to each folder
  3. Generates a formatted activity timeline
  4. Writes it to CLAUDE.md in that folder, inside <claude-mem-context> tags
Files are written atomically using a temp file and rename pattern, so partial writes cannot occur if the process is interrupted. Updates happen asynchronously and do not block the main workflow.

What gets generated

Each folder’s CLAUDE.md contains a “Recent Activity” section with a markdown table:

Table column reference

Type indicators

Preserving your own content

The auto-generated section is wrapped in <claude-mem-context> tags. Any content you write outside these tags is preserved when the file is regenerated.
You can add folder-specific instructions for Claude, architectural notes, or naming conventions — they will never be overwritten.

Project root exclusion

The project root (folders containing a .git directory) is excluded from auto-generation. Root CLAUDE.md files typically contain project-wide instructions you’ve written manually, and auto-generating at the root risks overwriting important documentation. Subfolders are where folder-level context is most useful.
Git submodules — which have a .git file rather than a directory — are correctly detected and are not excluded. They receive auto-generated context like any other subfolder.

Enabling the feature

1

Open your settings file

Edit ~/.claude-mem/settings.json. The file is created automatically on first run.
2

Add the setting

3

Save the file

Changes take effect immediately — no worker restart needed.
If the settings file doesn’t exist yet, create it with only the settings you want to change. Claude Mem uses defaults for any missing settings.

Manually regenerating context

To regenerate all folder CLAUDE.md files from the database:
This is useful after importing observations from another machine, recovering from a database issue, or wanting to refresh all folder context from scratch.

Cleaning up generated files

The regenerate script includes a --clean mode to strip auto-generated content:
Cleanup behavior:
  1. Finds all CLAUDE.md files recursively
  2. Strips <claude-mem-context>...</claude-mem-context> sections
  3. Deletes files that become empty after stripping
  4. Preserves files that have content outside the generated tags
This is useful for preparing a clean branch before opening a PR, resetting folder context, or removing generated files before sharing code.

Git integration

Whether to commit these files is your choice. Consider the trade-offs:
Pros:
  • Team members see folder-level context and recent activity
  • New contributors can understand what happened where
  • Code reviewers get additional context about recent changes
  • Creates a historical record of work patterns in the repo
Cons:
  • Adds frequently-changing files to your repository
  • Can create noise in diffs and commit history
  • Different team members may generate different content

Gitignore patterns

To exclude subfolder CLAUDE.md files while keeping your root file:
To ignore all CLAUDE.md files everywhere:
Solo developers: Keep files local (gitignore) for personal context, or commit them if you work across multiple machines. Teams: Discuss which approach works for your workflow. Committing is most valuable when onboarding is frequent. Before merging PRs: Use cleanup to remove generated files from the diff:

Worktree support

When you’re working in a git worktree, context is automatically gathered from both the parent repository and the worktree directory. Observations about shared code remain visible regardless of which worktree you’re in. Claude Mem detects worktrees automatically. No configuration is needed, and the feature has no effect if you’re not using worktrees.

Configuration

All settings including folder context options

Export and import

Move memory data between machines