Calldiff: CLI tool to visualize call stack changes across git commits
Compare call flow differences across 22 programming languages.
1What is Calldiff?
Calldiff is a command-line tool that visualizes call stack differences between git commits. Similar to how git diff shows line-based changes, Calldiff displays changes in function call relationships. Supporting 22 programming languages, the tool is designed to help developers understand the impact of changes in large codebases through call hierarchy visualization.
2Key use cases
Calldiff operates in three main modes: diff mode shows call stack differences between commits, tree mode displays the call tree of specific functions, and reach mode lists all call paths from one function to another. It's particularly useful for verifying code behavior after major refactoring operations, providing insights beyond traditional line-based diffs.
3Language support
The tool supports popular languages like TypeScript, Python, Go, Rust, Java, C/C++, and C#, as well as niche languages including Haskell, Zig, and Solidity - totaling 22 languages. This comprehensive support enables consistent experience in polyglot projects. Language parsing is handled through Tree-sitter grammars that auto-download on first use.
4AI-assisted code review
Calldiff is designed to enhance code review processes with AI assistants. Its JSON output format is easily processed by AI agents, and it provides pre-made prompt templates for explaining changes. This feature aims to accelerate code review in large teams by providing structured call hierarchy data to automated review systems.
5Technical implementation
The tool uses Tree-sitter parsers for code analysis, performing static analysis to build call stacks (though it can't resolve dynamic calls). Grammars are cached in ~/.cache/calldiff/grammars on first use. It outputs colored ASCII trees by default (switching to colorless when piped), and supports machine-readable formats like JSON and YAML for integration with other tools.
6Installation and usage
Calldiff can be installed globally via npm with 'npm install -g calldiff'. Basic diff usage is 'calldiff diff main feature'. The --entry parameter focuses analysis on specific functions, while 'calldiff tree -e functionName' displays call trees. The tool also supports path filtering and maximum depth parameters for focused analysis of large codebases.
7Impact on code review
Traditional diff tools often fail to show structural code changes clearly. Calldiff addresses this gap, particularly valuable after significant refactoring where understanding behavioral impact is crucial. By visualizing call hierarchy changes, it helps teams conduct more thorough and efficient code reviews, potentially catching integration issues earlier.
8Future potential
As AI-assisted coding tools proliferate, tools like Calldiff become increasingly important for understanding automated changes. With code generation becoming more common, the need for change comprehension tools grows. The open-source project has already gained traction with 289 GitHub stars, suggesting strong developer interest in call-aware diff visualization.