Skip to main content

repo-graph-kit

A small Python-first repo graph package.

It parses Python repositories with ast, builds a directed graph of modules, imports, classes, functions, methods, and calls, then exports the result as JSON or Mermaid.

Features

  • Python AST repo graph builder
  • Modules, imports, classes, functions, methods, inheritance, and calls
  • Better local symbol and import alias call resolution
  • DFS traversal
  • BFS shortest path
  • Strongly Connected Components using Tarjan's algorithm
  • Topological sort for dependency ordering
  • Degree centrality for blast-radius and hotspot detection
  • Graph diffing for CI and PR tracking
  • Dead-code candidate detection
  • JSON export
  • Mermaid export
  • CLI command: repo-graph

Install locally

pip install -e .

Publish to PyPI

This project is ready for standard PyPI packaging:

  • build backend: setuptools
  • package layout: src/
  • CLI entry point: repo-graph

To release a version:

  1. Update version in pyproject.toml.
  2. Install release tools with python -m pip install --upgrade build twine.
  3. Build distributions with python -m build.
  4. Verify them with python -m twine check dist/*.
  5. Upload to TestPyPI first, then to PyPI.

For automated releases, configure PyPI Trusted Publishing and use the GitHub Actions workflow in .github/workflows/publish.yml.

Build a graph

repo-graph scan ./examples/sample_project \
  --json out/repo-graph.json \
  --mermaid out/repo-graph.mmd \
  --findings out/findings.json \
  --metrics out/metrics.json

Diff two graphs

repo-graph diff previous/repo-graph.json current/repo-graph.json \
  --json out/graph-diff.json

Python API

from repo_graph_kit import build_python_repo_graph
from repo_graph_kit.algorithms import (
    strongly_connected_components,
    top_central_nodes,
    diff_graphs,
)

graph = build_python_repo_graph("examples/sample_project")

print(len(graph.nodes))
print(len(graph.edges))

print(strongly_connected_components(graph, edge_types={"imports"}))
print(top_central_nodes(graph, limit=5, edge_types={"imports", "calls"}))

Current limitations

This is intentionally static-analysis-first. It will not perfectly resolve dynamic imports, monkey patching, dependency injection, framework magic, or runtime-generated calls.

Treat findings like dead-code candidates as review hints, not automatic deletion instructions.

Metadata

Release files for repo-graph-kit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for repo-graph-kit 0.2.0
File Size Uploaded Provenance Actions
repo_graph_kit-0.2.0.tar.gz 13.6 kB Without provenance Details for repo_graph_kit-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for repo-graph-kit 0.2.0
File Interpreter ABI Platform Actions
repo_graph_kit-0.2.0-py3-none-any.whl Python 3 none any Details for repo_graph_kit-0.2.0-py3-none-any.whl

Total release size: 29.9 kB

Release files / repo_graph_kit-0.2.0.tar.gz

Download URL repo_graph_kit-0.2.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2973b63162888af037a4a640384009315195edfdbd4e572899578000e22a584b
BLAKE2b-256 checksum
How to use checksums
fe6eb0ee274e018c9c58e4474ab20a487ffa73acfdde6692f3dd3d3a906b63b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / repo_graph_kit-0.2.0-py3-none-any.whl

Download URL repo_graph_kit-0.2.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4c503fb7ba98be650aef643ecb2f8504ccf4e06acfea23195568b48ad30af58
BLAKE2b-256 checksum
How to use checksums
04e97f13baffddaa1f0af876d0877de1313b38dfcbac7cf026412dcf40b58522
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for repo-graph-kit 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page