thedotmack/claude-mem · warning
Error processing
Error message
Error processing ${relativePath} What it means
processFilesForCleanup wraps each cleanSingleFile call in try/catch. If cleanup of one CLAUDE.md throws (read/write errors, permission issues, malformed front-matter handling), this warning logs the relative path and error, increments errorCount, and processing continues with the remaining files.
Solutions
- Check permissions/ownership of the specific file in the log message
- Run with --dry-run first to see what would change without writing
- Fix or manually review the offending CLAUDE.md, then re-run cleanup
- Run the command as a user with write access to the repo
Example fix
// before npx claude-mem clean // after npx claude-mem clean --dry-run # inspect first, then run for real
Defensive patterns
Strategy: try-catch
Validate before calling
if (!existsSync(relativePath) || !statSync(relativePath).isFile()) { errorCount++; return; }
accessSync(relativePath, fsConstants.W_OK); Try / catch
try {
const result = cleanSingleFile(file, relativePath, dryRun);
} catch (e) {
logger.warn('CLAUDE_MD', `Error processing ${relativePath}`, { error: e instanceof Error ? e.message : String(e) });
errorCount++;
} Prevention
- Always dry-run first before destructive cleanup
- Run cleanup with write permission on the repo
- Handle symlinks/deleted files explicitly in iteration
- Review the per-file error log to fix one file at a time
When it happens
Trigger: cleanClaudeMd iterates CLAUDE.md files and cleanSingleFile throws for a specific file — unreadable file, write denied during non-dry-run deletion/cleanup, or an internal parsing exception in the cleanup logic.
Common situations: Files owned by another user; read-only mounts; symlinked or deleted files mid-run; hand-edited CLAUDE.md with content the cleaner cannot handle.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Error processing folder
- Failed to regenerate folder
- [uninstall] Could not read
- [uninstall] Could not read
- [uninstall] Could not read
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/a6c9117896b33f09.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/claude-md-commands.ts:430
function processFilesForCleanup(
filesToProcess: string[],
workingDir: string,
dryRun: boolean
): number {
let deletedCount = 0;
let cleanedCount = 0;
let errorCount = 0;
for (const file of filesToProcess) {
const relativePath = path.relative(workingDir, file);
try {
const result = cleanSingleFile(file, relativePath, dryRun);
if (result === 'deleted') deletedCount++;
else cleanedCount++;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
logger.warn('CLAUDE_MD', `Error processing ${relativePath}`, { error: errorMessage });
errorCount++;
}
}
logger.info('CLAUDE_MD', 'CLAUDE.md cleanup complete', {
deleted: deletedCount,
cleaned: cleanedCount,
errors: errorCount,
dryRun
});
return 0;
}
function cleanSingleFile(file: string, relativePath: string, dryRun: boolean): 'deleted' | 'cleaned' {
const content = readFileSync(file, 'utf-8');
const stripped = content.replace(/<claude-mem-context>[\s\S]*?<\/claude-mem-context>/g, '').trim();
View on GitHub (pinned to d8bc9755e7)