Tree Climber is a comprehensive static analysis framework for generating Control Flow Graphs (CFGs) and performing dataflow analysis on source code. It supports multiple programming languages through Tree-sitter parsers and provides both programmatic APIs and interactive web visualization.
- Clean architecture and thorough test coverage.
- Semi- (and eventually fully-)automated analyses written by coding agents.
- Interactive, detailed, high-quality visualizations for educational and exploration purposes.
- C: Full CFG generation with control structures, loops, and functions
- Java: CFG generation for Java language constructs
- Extensible: Framework designed to easily add new language support
- CFG Builder: Generates control flow graphs using visitor pattern
- Dataflow Solver: Implements iterative dataflow analysis algorithms
- AST Utils: Tree-sitter integration and AST manipulation utilities
- Visualization: Web-based interactive CFG visualization
- Control Flow Analysis: Statement-level CFG construction
- Def-Use Chains: Variable definition and usage tracking
- Reaching Definitions: Forward dataflow propagation
- Extensible Framework: Support for custom dataflow analyses
This project uses uv
for Python dependency management and bun
for frontend dependencies.
- Clone the repository:
git clone https://github.com/bstee615/tree-climber
cd tree-climber
- Install dependencies:
# Install dependencies on Ubuntu
sudo apt install -y graphviz graphviz-dev
uv sync
- (For web frontend) Install frontend dependencies:
cd src/tree_climber/viz/frontend
bun install
- (For CLI) Install CLI dependencies:
source .venv/bin/activate
uv pip install -e .
CLI is available as a command, tree-climber
. Run the CLI against a file or directory. Use the flags below to pick which graphs to generate and how to render them.
Example:
tree-climber test/example.c --draw_cfg --draw_cpg
Example CFG | Example CPG (Code Property Graph, including AST + CFG + DFG edges) |
---|---|
![]() |
![]() |
An alternative view of the CPG is available which draws the AST and CFG separately, with edges connecting CFG <-> AST nodes. Use the option -L bigraph
.
Try tree-climber --help
to see all options.
The project includes a webapp for visualizing and interacting with CFG/DFGs, inspired by https://godbolt.org. To run it easily, open the project in VSCode and launch the config named "Run Server and Frontend".

# Run FastAPI server with hot reload
uv run -m uvicorn tree_climber.viz.app:app --reload --host 0.0.0.0 --port 8000
# Or use the VS Code task: "Run FastAPI Server"
# Navigate to frontend directory
cd src/tree_climber/viz/frontend
# Start development server
bun dev
# Or use the VS Code task: "Run Frontend"
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
The FastAPI backend provides the following endpoints:
POST /parse
- Parse source code and return CFG in JSON formatPOST /analyze/def-use
- Perform def-use chain analysisPOST /analyze/reaching-definitions
- Perform reaching definitions analysisGET /health
- Health check endpoint
Currently, only basic program constructs are supported. I am working to make the parsing more robust and complete.
See the full list of features handled and planned in the Limitations section of this doc.
- Create a new visitor class in
src/tree_climber/cfg/languages/
- Implement language-specific CFG construction logic
- Register the language in the CFG builder
- Add test cases in the
test/
directory
- Create a new analysis class in
src/tree_climber/dataflow/analyses/
- Implement the dataflow problem interface
- Add API endpoints in
src/tree_climber/viz/app.py
- Update frontend to display analysis results
The frontend is built with:
- React: UI framework
- Cytoscape.js: Graph visualization
- Monaco Editor: Code editing
- Vite: Build tool and dev server
The backend uses:
- FastAPI: Web framework
- Tree-sitter: Source code parsing
- Pydantic: Data validation
The CLI uses:
- Typer: Terminal display and argument parsing
- GraphViz: Graph visualization
For detailed technical documentation, see the docs/
directory: