Skip to content

Bug: 50-120+ CLAUDE.md files created per session causing repository pollution #778

@murillodutt

Description

@murillodutt

Bug Description

During normal Claude Code sessions, the claude-mem plugin creates 50-120+ empty CLAUDE.md files throughout the project structure. This happens in virtually every directory that is accessed via Read, Glob, or Grep tools.

Environment

  • Claude-mem Version: Latest (installed via plugin)
  • Claude Code Version: Latest
  • Bun Version: 1.3.6
  • Operating System: macOS Darwin 25.2.0 (arm64)
  • Platform: darwin

Steps to Reproduce

  1. Start a Claude Code session with claude-mem plugin enabled
  2. Work normally - read files, search code, make edits
  3. After 30-60 minutes of work, run: find . -name "CLAUDE.md" -type f | wc -l
  4. Observe 50-120+ files created

Evidence from Real Session (2026-01-22)

# Files found after single session:
$ find . -name "CLAUDE.md" -type f ! -path "*/node_modules/*" | wc -l
56

# Locations affected:
oracle/server/api/**/*.md (15+ files)
oracle/server/db/CLAUDE.md
.claude/*/CLAUDE.md (10+ files)
docs/project/*/CLAUDE.md (6+ files)
cellm-core/*/CLAUDE.md (12+ files)
tests/*/CLAUDE.md (4+ files)
.github/workflows/CLAUDE.md
.git/CLAUDE.md  # <- Critical: inside git internals!

File Content (All Identical)

Every generated file contains only:

<claude-mem-context>
# Recent Activity

<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->

*No recent activity*
</claude-mem-context>

Impact

Issue Severity
Git status polluted with untracked files Medium
Risk of accidentally committing temp files Medium
Files created in .git/ directory break git operations High
Confusion between legitimate vs auto-generated files Medium
Disk space (minor: ~24KB/session) Low

Current Workarounds

We've implemented these mitigations in our workflow:

1. .gitignore rules

**/CLAUDE.md
!/CLAUDE.md
!/cellm-core/templates/CLAUDE.md

2. Pre-commit cleanup script

for f in $(find . -name "CLAUDE.md" -type f \
  ! -path "./CLAUDE.md" \
  ! -path "./cellm-core/templates/CLAUDE.md" \
  ! -path "*/node_modules/*" 2>/dev/null); do
  if grep -q "claude-mem-context" "$f" 2>/dev/null; then
    rm -f "$f"
  fi
done

Expected Behavior

  1. CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED=false should actually disable this feature
  2. .git/ directory should NEVER have files created inside it
  3. Option to specify allowlist/blocklist of directories
  4. Auto-cleanup of empty/inactive files at session end

Related Issues

Suggested Fix

Per issue #760, the fix should be straightforward:

// At start of updateFolderClaudeMdFiles() or call site
const settings = SettingsDefaultsManager.loadFromFile(SETTINGS_PATH);
const enabled = settings.CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED === 'true';
if (!enabled) return;

Additionally, add directory exclusion logic:

const EXCLUDED_DIRS = ['.git', 'node_modules', '.nuxt', '.output', 'dist', 'build'];
if (EXCLUDED_DIRS.some(dir => filePath.includes(`/${dir}/`))) return;

Documentation

We've created detailed analysis of this issue:

  • Root cause analysis
  • Impact assessment
  • Workarounds implemented
  • Verification commands

Happy to share if helpful for debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions