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 3This command reveals:
- Direct impact (hop 1): Files that import
login.ts - Secondary impact (hop 2): Files that import the hop 1 files
- 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 forwardReverse Traversal
Follow what imports a file - see your blast radius for changes:
codemap traverse src/utils/format.ts --direction reverseImpact Analysis Workflow
Before Making Changes
- Identify the target file
- Run impact analysis with depth 3
- Review the blast radius
- Check reverse dependencies
- Examine critical importers
During Refactoring
- Traverse forward to see dependencies you might break
- Traverse reverse to see files that might break
- Group affected files for tracking
- Label impacted files for testing
Impact Analysis Tools
| Tool | Purpose | Best For |
|---|---|---|
impact-analysis | Multi-hop blast radius | Understanding full change impact |
traverse | Follow dependency chains | Exploring dependency trees |
get-dependencies | Single-hop relationships | Quick 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
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.
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.