code-graph is a lightweight command-line tool that inspects a git repository and emits a YAML description of the project hierarchy and function call relationships. The tool prioritizes accuracy by combining git-aware file discovery with Tree-sitter-based parsing and reuses Blarify's language coverage and reference resolution pipeline so the same languages are supported out of the box.
- Git native – only committed files are analyzed via
git ls-files, so transient build artifacts are ignored without custom ignore rules. - Tree-sitter powered – language-specific grammar support enables precise parsing of source structure.
- Portable YAML – the resulting manifest can be consumed by any downstream tooling that understands YAML (e.g. graphing pipelines, documentation generators).
npm install -g @sourcegraph/scip-python
npm install -g @sourcegraph/scip-typescript
pip install -e .Run from anywhere inside a git repository:
code-graph > call-graph.yamlKey options:
--root PATH– optional explicit path to the repository (defaults to current directory).--output FILE– write the YAML graph to a file instead of stdout.--skip-name/--skip-extension– extend the ignore lists if you need to filter additional assets.
- A git repository (only tracked files are analysed via
git ls-files). - The CLI shells out to Blarify, which in turn relies on multilspy to spin up the right Language Server Protocol processes. Ensure the machine can launch the corresponding LSP servers for the languages in your project (Python, TypeScript/JavaScript, Go, Java, C#, Ruby, PHP, etc.).
- Optional but recommended: install the SCIP indexers (
npm install -g @sourcegraph/scip-python @sourcegraph/scip-typescript) to speed up reference resolution when working with Python or TypeScript/JavaScript codebases.
pip install -e ".[dev]"
pytestThe generated YAML document contains:
nodes: every folder, file, class, function, and method discovered, with ids, names, relative paths, and optional line numbers.edges: relationships between nodes, includingcontains,defines, andcallslinks.
This format is easy to diff, transform, or feed into custom visualisation/back-end systems.
- Expose knobs for switching between SCIP and LSP modes explicitly.
- Surface richer graph metadata (e.g., cyclomatic complexity, module grouping).
MIT