Tools

analyze_impact

Change risk assessment and blast radius analysis

The analyze_impact tool helps you understand the risk and scope of modifying a file. Before making changes, use it to see what other files would be affected and get a risk score that reflects the potential impact.

How It Works

Stellarion uses BFS (Breadth-First Search) graph traversal on the dependency graph to find all files that depend on the target file, both directly and transitively. It then calculates a risk score based on file importance, criticality, and the number of affected files.

When to Use

  • Before refactoring: Understand what might break before you start
  • Assessing risk of changes: Get a quantified risk score for modifications
  • Understanding blast radius: See how far changes might propagate
  • Planning safe modifications: Identify high-risk vs low-risk changes
  • Impact analysis for reviews: Understand the scope of a proposed change

Parameters

ParameterTypeRequiredDefaultDescription
pathstringYes-File path to analyze impact for
includeTransitivebooleanNotrueInclude indirect dependencies
includeCategoriesbooleanNofalseCategorize affected files by type
detectCircularbooleanNofalseCheck for circular dependencies
maxDepthnumberNo5Maximum depth for transitive analysis
excludeTestsbooleanNofalseExclude test files from analysis
excludeNodeModulesbooleanNotrueExclude node_modules from analysis

MCP Command Syntax

mcp__stellarion__analyze_impact path:src/core/engine.ts includeCategories:true detectCircular:true

Examples

Basic Impact Analysis

Natural Language:

What would be affected if I change src/services/auth.ts?

Direct MCP Call:

mcp__stellarion__analyze_impact path:src/services/auth.ts

Returns: All files that depend on auth.ts, directly and indirectly, with risk score


Categorized Impact

Natural Language:

Analyze the impact of changing src/db/connection.ts and group the affected files by type

Direct MCP Call:

mcp__stellarion__analyze_impact path:src/db/connection.ts includeCategories:true

Returns: Affected files grouped into components, services, utilities, and tests


Production-Only Impact

Natural Language:

What production files would be affected if I change this utility?

Direct MCP Call:

mcp__stellarion__analyze_impact path:src/utils/helpers.ts excludeTests:true

Returns: Only production file impact, excluding test files


Risk Assessment

Natural Language:

What's the risk of modifying src/core/engine.ts?

Direct MCP Call:

mcp__stellarion__analyze_impact path:src/core/engine.ts includeCategories:true detectCircular:true

Returns: Risk score with detailed breakdown of factors


Limited Depth Analysis

Natural Language:

Show me the immediate impact of changing this file (just direct dependencies)

Direct MCP Call:

mcp__stellarion__analyze_impact path:src/api/routes.ts maxDepth:1

Returns: Only directly dependent files, not transitive dependencies


Circular Dependency Check

Natural Language:

If I change this file, would it trigger any circular dependency issues?

Direct MCP Call:

mcp__stellarion__analyze_impact path:src/services/user.ts detectCircular:true

Returns: Impact analysis plus any circular dependencies in the impact chain

Output Format

Affected Files

FieldDescription
Direct dependentsFiles that directly import this file
Transitive dependentsFiles that indirectly depend on this file
Total affected countNumber of files that would be affected
Affected file listPaths of all affected files

Risk Score

A score from 0.0 to 1.0 calculated from multiple factors:

FactorWeightDescription
File importance+0.3Is it index.ts, main.ts, or app.ts?
Critical file+0.3Is it config, database, or auth related?
Affected countup to +0.4How many files depend on it?
Test file-0.3Test files reduce risk

Risk Levels

Score RangeLevelRecommendation
0.0 - 0.3LowSafe to modify with basic testing
0.3 - 0.5MediumReview carefully, test affected areas
0.5 - 0.7HighThorough testing needed, consider incremental changes
0.7 - 1.0CriticalExtra caution required, plan for regression testing

Categories (when requested)

Files are grouped into:

CategoryDescription
ComponentsUI components, React/Vue components
ServicesBusiness logic, API services
UtilitiesHelper functions, shared utilities
TestsTest files, spec files
ConfigurationConfig files, environment setup

Understanding Risk Scores

High Risk Indicators

  • Entry points (index.ts, main.ts, app.ts): Changes affect the entire application
  • Critical files (config, database, auth): Changes have security or stability implications
  • Many dependents: More files affected means more things can break

Low Risk Indicators

  • Test files: Changes don't affect production
  • Leaf nodes: Files that nothing else depends on
  • Isolated utilities: Self-contained helper functions

Tips for Impact Analysis

  1. Always check impact before major refactoring: Save yourself from unexpected breakages
  2. Use excludeTests: true for production impact: Focus on what matters for users
  3. High-risk files need more testing: Plan extra test coverage for high-score files
  4. Consider breaking up high-impact files: Files with 0.7+ risk might be doing too much
  5. Use categories to prioritize: Services and core components need more attention than utilities

Combining with Other Tools

  1. Impact + Quality: High-risk files with high complexity are priority targets for improvement
  2. Impact + Structure: Understand why a file has high impact by examining its dependencies
  3. Impact + Refactoring: Use impact scores to prioritize which refactoring opportunities to tackle first

Example Workflow

Before making changes:

# 1. Check impact
mcp__stellarion__analyze_impact path:src/core/auth.ts includeCategories:true

# 2. If high risk, check complexity
mcp__stellarion__analyze_quality type:complexity path:src/core/auth.ts

# 3. Understand dependencies
mcp__stellarion__analyze_structure type:dependencies path:src/core/auth.ts

# 4. Plan changes with full context