Skip to content
Arxo Arxo

check_cycles

Quickly check for circular dependencies (import cycles) in your codebase. This tool uses Strongly Connected Components (SCC) analysis to detect cycles without running a full architecture analysis.

ParameterTypeRequiredDescription
project_pathstringYesAbsolute or relative path to the project root directory

Returns a JSON summary with cycle statistics.

{
"scc": {
"component_count": "number", // Number of SCC components (higher is healthier)
"cycle_count": "number", // Number of actual cycles
"max_cycle_size": "number", // Size of the largest cycle (0 = no cycles)
"total_nodes_in_cycles": "number" // Total modules trapped in cycles
},
"violations_count": "number" // Policy violations triggered by cycles
}
max_cycle_sizeInterpretation
0✅ No circular dependencies detected
2⚠️ Simple two-module cycle (e.g., A imports B, B imports A)
3-10⚠️ Moderate cycle complexity
>10🚨 Complex circular dependency — difficult to refactor
  • cycle_count — Number of distinct cycle groups. A value of 0 means no cycles.
  • component_count — Number of SCC components. In acyclic graphs this is close to total module count.
  • total_nodes_in_cycles — Sum of all modules participating in any cycle. Useful for estimating refactoring scope.

Request:

{
"project_path": "."
}

Response:

{
"scc": {
"component_count": 183,
"cycle_count": 0,
"max_cycle_size": 0,
"total_nodes_in_cycles": 0
},
"violations_count": 0
}

Request:

{
"project_path": "/path/to/project"
}

Response:

{
"scc": {
"component_count": 175,
"cycle_count": 2,
"max_cycle_size": 5,
"total_nodes_in_cycles": 8
},
"violations_count": 1
}

Interpretation:

  • 2 distinct cycle groups exist
  • The largest cycle involves 5 modules
  • 8 modules total are trapped in cycles
  • 1 policy violation triggered (likely scc.max_cycle_size > 0)

Use this tool as the first step in a multi-step architecture check:

1. check_cycles → if max_cycle_size > 0, proceed to step 2
2. get_hotspots → identify which modules are in cycles
3. suggest_refactors → get recommendations for breaking cycles

See Workflows: Quick health check for a full example.

ErrorCauseSolution
missing required parameter: project_pathproject_path not providedInclude project_path in request
No such file or directoryInvalid project pathVerify path exists and is accessible
scc metric not in resultsEngine failed to compute SCCCheck project structure and language support
  • Speed: 1-5 seconds for most projects (uses the quick preset internally)
  • Caching: Does not use cache (intentionally — always fresh for pre-commit checks)
  • Scalability: Handles projects with 10k+ files efficiently
Terminal window
# Fast cycle check (same as check_cycles)
arxo analyze --preset quick --format json | jq '.results[] | select(.id=="scc")'
# Or use the dedicated cycles command (if available)
arxo cycles