Skip to content
Arxo Arxo

suggest_refactors

Get prioritized, actionable refactoring recommendations based on architecture analysis. This tool identifies specific opportunities to improve your codebase structure, such as breaking cycles, splitting hub modules, fixing layer violations, and reducing coupling.

ParameterTypeRequiredDescription
project_pathstringYesAbsolute or relative path to the project root directory
edge_filterstringNoOptional edge filter (reserved for future use)

Request:

{
"project_path": "."
}

Response:

Refactoring suggestions require full arxo. Analysis completed: 7 metrics in results.

The tool runs the risk preset and confirms analysis completed, but doesn’t return structured refactoring recommendations.

Expected Response (when fully implemented)

Section titled “Expected Response (when fully implemented)”

When implemented, this tool will return prioritized refactoring recommendations:

{
"recommendations": [
{
"priority": "Critical|High|Medium|Low",
"effort": "Low|Medium|High",
"category": "string",
"title": "string",
"description": "string",
"evidence": {
"modules": ["string"],
"metrics": {
"key": "value"
}
},
"steps": ["string"]
}
],
"recommendations_count": "number"
}
CategoryWhat it finds
Break circular dependenciesIdentifies lowest-weight edges to cut (e.g., barrel imports, type-only imports)
Split hub modulesSuggests splitting modules with high fan-in + fan-out into smaller, cohesive units
Fix layer violationsRecommends dependency inversion or adapter patterns for upward-reaching imports
Move misplaced modulesIdentifies modules with more connections to neighboring communities
Fix unstable dependenciesSuggests extracting interfaces when stable modules depend on unstable ones
Refactor high-churn hotspotsHighlights modules that change frequently and are tightly coupled
PriorityWhen to act
CriticalImmediate action — blocking issue (e.g., cycles preventing modular compilation)
HighAddress soon — significant technical debt or risk
MediumPlanned refactoring — improvement opportunity
LowOptional — minor improvements or optimizations
EffortTypical scope
Low1-4 hours — single module refactoring
Medium1-3 days — multiple modules, moderate complexity
High1-2 weeks — architectural change, many modules affected
{
"priority": "Critical",
"effort": "Low",
"category": "Break circular dependencies",
"title": "Break cycle between auth.ts and session.ts",
"description": "A 2-module cycle exists between auth and session. Breaking this cycle will enable modular compilation and reduce coupling.",
"evidence": {
"modules": ["src/core/auth.ts", "src/core/session.ts"],
"metrics": {
"scc.max_cycle_size": 2,
"ricci_curvature": -0.3
}
},
"steps": [
"Extract shared types to src/core/auth-types.ts",
"Make session.ts import from auth-types.ts instead of auth.ts",
"Verify no cycle with `arxo analyze --preset quick`"
]
}
{
"priority": "High",
"effort": "Medium",
"category": "Split hub modules",
"title": "Split utils.ts (fan-in: 42, fan-out: 18)",
"description": "utils.ts is a hub module with excessive dependencies. Split it into focused utilities to reduce coupling.",
"evidence": {
"modules": ["src/utils/utils.ts"],
"metrics": {
"centrality.module.max_fan_in": 42,
"centrality.module.max_fan_out": 18,
"centrality.module.betweenness_max": 0.62
}
},
"steps": [
"Extract string utilities to src/utils/string.ts",
"Extract array utilities to src/utils/array.ts",
"Extract date utilities to src/utils/date.ts",
"Update imports across codebase",
"Verify betweenness reduced with `arxo analyze --preset quick`"
]
}
{
"priority": "High",
"effort": "Medium",
"category": "Fix layer violations",
"title": "Domain layer importing from presentation layer",
"description": "Domain logic in src/domain/user.ts imports from src/presentation/formatters.ts, violating layer architecture.",
"evidence": {
"modules": ["src/domain/user.ts", "src/presentation/formatters.ts"],
"metrics": {
"layer_violations.violations_count": 1
}
},
"steps": [
"Move formatting logic to src/domain/user-formatters.ts",
"Update presentation layer to use domain formatters",
"Apply Dependency Inversion Principle",
"Verify no violations with `arxo analyze --preset ci`"
]
}

Until this tool is fully implemented in the MCP server, use the CLI:

Terminal window
# Get refactoring recommendations
arxo analyze --preset full --format json > results.json
# Extract refactoring recommendations
cat results.json | jq '.results[] | select(.id=="refactoring_recommendations")'
{
"id": "refactoring_recommendations",
"version": "1.0.0",
"values": {},
"findings": [
{
"title": "Break cycle between auth.ts and session.ts",
"severity": "error",
"evidence": [
{
"modules": ["src/core/auth.ts", "src/core/session.ts"],
"priority": "Critical",
"effort": "Low"
}
]
},
{
"title": "Split hub module utils.ts",
"severity": "warning",
"evidence": [
{
"module": "src/utils/utils.ts",
"fan_in": 42,
"fan_out": 18,
"priority": "High",
"effort": "Medium"
}
]
}
]
}

Use this tool to plan refactoring efforts:

1. get_hotspots → identify problem areas
2. suggest_refactors → get prioritized recommendations
3. Sort by priority (Critical → High → Medium → Low)
4. For each recommendation:
a. Assess effort vs impact
b. Create refactoring task/ticket
c. Implement steps
d. Verify improvement with check_cycles or analyze_architecture
5. Re-run suggest_refactors to see remaining issues

See Workflows: Hotspot detection and refactoring for context.

ErrorCauseSolution
missing required parameter: project_pathproject_path not providedInclude project_path in request
Refactoring suggestions require full arxoMCP server limitationUse CLI: arxo analyze --preset full
  • Current: 10-30 seconds (runs risk preset)
  • Expected (when implemented): 30-120 seconds (requires full preset with refactoring_recommendations)
Terminal window
# This is the only way to get full refactoring suggestions
arxo analyze --preset full --format json | jq '.results[] | select(.id=="refactoring_recommendations")'

To fully implement this tool in the MCP server:

  1. Add refactoring_recommendations metric to arxo-loader
  2. Expose structured recommendation data via the tool
  3. Support filtering by priority, effort, or category
  4. Cache recommendations by project state

The metric already exists in the Pro engine — it just needs to be wired into the MCP tool handler.