Skip to content
Arxo Arxo

Fixing Cycles

This guide walks you through identifying and breaking circular dependencies. For refactoring patterns, see Refactoring Patterns. For an overview, see Circular Dependencies.

  1. Identify the largest cycle

    Terminal window
    arxo analyze --format json | jq '.results[] | select(.id=="scc") | .data[] | select(.key=="scc.max_cycle_size") | .value.v'
  2. Examine cycle details

    Terminal window
    arxo analyze --format json | jq '.ui_schemas.scc.scc_details[] | select((.nodes | length) > 1)'
  3. Review cycle-cut candidates

    • Start with the edge with lowest call_count
    • This represents the weakest coupling
  4. Apply a refactoring pattern — see Refactoring Patterns

  5. Verify the fix

    Terminal window
    arxo analyze # Should show reduced cycle count

For pragmatic refactoring:

  1. Start with small cycles - 2-node cycles are easier to fix
  2. Fix high-churn files first - Use git history to find frequently changed files
  3. Focus on the largest cycle - Breaking a 56-node cycle has massive impact
  4. Use cycle-cut candidates - Start with suggested edges (lowest effort)