Impact Analysis

Understanding how changes ripple through your codebase using dependency analysis and graph traversal

Why Impact Analysis Matters

Changing code is risky. A seemingly simple modification can break:

  • Direct importers that rely on your API
  • Transitive dependencies several layers removed
  • Test files that assume certain behavior
  • Build processes that depend on file structure

Impact analysis makes the invisible visible, turning uncertainty into confidence.

The Impact Analysis Tool

The impact-analysis tool performs multi-hop blast radius analysis:

codemap impact-analysis src/auth/login.ts --depth 3

This command reveals:

  1. Direct impact (hop 1): Files that import login.ts
  2. Secondary impact (hop 2): Files that import the hop 1 files
  3. Tertiary impact (hop 3): Files that import the hop 2 files

Dependency Traversal

The traverse tool follows dependency chains in both directions:

Forward Traversal

Follow what a file imports - see everything it needs to function:

codemap traverse src/app.ts --direction forward

Reverse Traversal

Follow what imports a file - see your blast radius for changes:

codemap traverse src/utils/format.ts --direction reverse

Impact Analysis Workflow

Before Making Changes

  1. Identify the target file
  2. Run impact analysis with depth 3
  3. Review the blast radius
  4. Check reverse dependencies
  5. Examine critical importers

During Refactoring

  1. Traverse forward to see dependencies you might break
  2. Traverse reverse to see files that might break
  3. Group affected files for tracking
  4. Label impacted files for testing

Impact Analysis Tools

ToolPurposeBest For
impact-analysisMulti-hop blast radiusUnderstanding full change impact
traverseFollow dependency chainsExploring dependency trees
get-dependenciesSingle-hop relationshipsQuick dependency checks

Best Practices

  • Always check impact before breaking changes
  • Use depth 3 as default to catch most transitive dependencies
  • Group large refactorings to track all affected files together
  • Label for testing priority - mark hop 1 files as critical
  • Re-verify after changes to ensure impact matches expectations
⚠️Depth vs Performance

While deeper analysis (depth 4+) provides more complete impact data, it can be slow on large codebases. For quick checks, use depth 2. For critical refactoring, use depth 3.

🚨Breaking Changes

Files marked as hop 1 (direct importers) are guaranteed to break if you change the public API. Always review these carefully before making breaking changes.