ruvnet / ruvnet/ruflo

Fix: Agents creating duplicate .claude-flow and .swarm folders in subdirectories

Open
#765 1 comment 0 reactions 0 assignees View on GitHub
agents bug
Dominant language
TypeScript
Stars
72.6k
Forks
8.6k
Avg merge
3d 3h
Merged PRs (30d)
85

Description

## Problem
Agents are creating duplicate `.claude-flow` and `.swarm` folders in subdirectories instead of using the main workspace root folders. This causes:
- Fragmented memory storage across multiple locations
- Agents not sharing state properly
- Increased disk usage with redundant folders
- Confusion about which folder contains the actual data

## Root Cause
The code was using `process.cwd()` to determine folder paths, which returns the current working directory. When agents operate in subdirectories, they create local folders instead of using the project root folders.

## Locations Affected
Multiple duplicate folders were found:
- `./docker/docker-test/.swarm`
- `./examples/litellm/.claude-flow`
- `./benchmark/.claude-flow`
- `./docs/.claude-flow`
- `./claude-flow-wiki/.claude-flow`
- And several others...

## Solution Implemented
Created a project root detection utility that:
1. Searches upward from any directory to find the main project root
2. Prioritizes the main claude-flow package root over subdirectory markers
3. Always returns paths relative to the true project root
4. Ensures all agents use the same `.claude-flow` and `.swarm` folders

## Files Modified
- Created: `src/utils/project-root.js` - New utility for project root detection
- Updated: `src/memory/sqlite-store.js` - Use project root instead of process.cwd()
- Updated: `src/memory/migration.js` - Use project root for paths
- Updated: `src/memory/shared-memory.js` - Use project root for database paths
- Updated: `src/memory/unified-memory-manager.js` - Use project root for config paths

## Testing
Verified that from any subdirectory, the utility correctly identifies the project root and returns the main workspace folders.

## Impact
- All agents will now use the same centralized folders
- Memory and state will be properly shared
- No more duplicate folder creation in subdirectories
- Consistent behavior regardless of where agents operate

Fixes #763

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.