detect_communities
Louvain community detection on import graph. Finds natural module groupings that often don't match folder names.
What it does
Uses Louvain community detection on the codebase import graph to identify natural module groupings. These often don’t match folder names.
A repo with a utils/ folder containing 40 files might have detect_communities find that 15 of those files form a tight community with services/auth/ — suggesting they should be moved or that the boundary between “auth” and “utilities” is artificial.
No native equivalent
Graph community detection requires structured data that no shell command produces. This is a capability that grep fundamentally cannot provide.
Output
Outputs communities with auto-generated names, file lists, cohesion scores, and modularity. Supports Mermaid diagrams for visual architecture reviews.
Use the resolution parameter: higher = more smaller communities, lower = fewer larger communities.
When to use
- Architecture reviews
- Identifying refactor candidates
- Documenting implicit domain boundaries
- Before
get_knowledge_map— communities are more actionable
Related tools
Benchmark note
This benchmark compares CodeSift against the closest practical native workflow an agent would use for the same task.
For some tools, that baseline is a direct shell equivalent such as rg or find.
For AST-aware, graph-aware, and LSP-backed tools, the baseline is a multi-step workflow rather than a strictly identical command.
Results should be read as agent-workflow comparisons: token cost, call count, and practical context efficiency.