-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Description
When the current working directory (cwd) is already inside a subdirectory (e.g., frontend/), and claude-mem receives a relative file path like frontend/src/components/Header.jsx, it creates nested duplicate directories such as:
frontend/frontend/src/components/backend/backend/services/trencherrpg/mayor/rig/frontend/(recreating the entire path structure)
These directories only contain empty CLAUDE.md files with "No recent activity".
Steps to Reproduce
- Navigate to a project subdirectory:
cd /path/to/project/frontend - Perform file operations (Edit, Write) on files using relative paths that include the current directory name
- Observe nested directories being created:
frontend/frontend/,frontend/mayor/, etc.
Expected Behavior
claude-mem should either:
- Detect and reject paths that would create duplicate directory segments
- Normalize paths to prevent duplication before calling
mkdirSync
Actual Behavior
mkdirSync(folderPath, { recursive: true }) creates nested duplicate directories because the path validation in isValidPathForClaudeMd() doesn't check for duplicate path segments.
Suggested Fix
Add duplicate segment detection in claude-md-utils.ts:
function hasDuplicatePathSegments(resolvedPath: string): boolean {
const segments = resolvedPath.split(path.sep).filter(s => s && s !== '.' && s !== '..');
const seen = new Set<string>();
for (const segment of segments) {
if (seen.has(segment)) return true;
seen.add(segment);
}
return false;
}
// In isValidPathForClaudeMd(), add:
if (hasDuplicatePathSegments(resolved)) {
return false;
}Alternatively, compare the resolved path against common patterns like /frontend/frontend/, /backend/backend/, /src/src/ etc.
Environment
- claude-mem version: 9.0.2
- OS: macOS
- Claude Code version: 2.1.19
Workaround
Manually delete the orphan directories:
find . -type d \( -path "*/frontend/frontend" -o -path "*/backend/backend" \) -exec rm -rf {} + 2>/dev/nullReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels