Skip to main content

explain-repo

explain-repo statically analyzes a local Python repository and produces a guided onboarding report. It parses Python with the standard-library ast module, resolves internal imports, builds a NetworkX dependency graph, and ranks files without reading meaning into source text.

Installation

After the package is published to PyPI, run it without installing it globally:

uvx explain-repo ./path/to/repository

For local development:

git clone <repository-url>
cd explain-repo
uv sync
uv run pytest
uvx --from . explain-repo ./path/to/repository

Python 3.11 or newer is required.

Usage

explain-repo [OPTIONS] PATH

Options:
  --top INTEGER RANGE             Number of files to show. [default: 10]
  --json                          Output structured JSON.
  --rank-method [indegree|pagerank]
											 Ranking algorithm. [default: pagerank]
  --llm                           Add structure-only Anthropic descriptions.
  --help                          Show help and exit.

Examples:

uvx explain-repo . --top 5
uvx explain-repo . --rank-method indegree
uvx explain-repo . --json > report.json
uvx --from 'explain-repo[llm]' explain-repo . --llm

Sample terminal output:

Suggested Reading Order
┏━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ # ┃ File               ┃ Why central               ┃ Dependencies     ┃
┡━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
│ 1 │ src/app/core.py    │ imported by 12 other files │ src/app/types.py │
│ 2 │ src/app/service.py │ imported by 4 other files  │ src/app/core.py  │
└───┴────────────────────┴───────────────────────────┴──────────────────┘

Core Abstractions
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ File               ┃ Classes              ┃ Functions        ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
│ src/app/core.py    │ Repository (load)    │ create_app       │
│ src/app/service.py │ AnalysisService (run)│ analyze          │
└────────────────────┴──────────────────────┴──────────────────┘

Syntax-invalid files are skipped with a warning. Common generated directories, including .git, .venv, venv, node_modules, __pycache__, build, and dist, are excluded from scanning. Circular imports are represented as ordinary cycles in the graph and require no recursive traversal.

Optional Anthropic descriptions

Install the llm extra and provide Anthropic credentials in the environment:

export ANTHROPIC_API_KEY="..."
uv sync --extra llm
uv run explain-repo . --llm

The model receives only the file path and extracted imports, function names, class names, and method names. Full source content is never sent. Override the default model with EXPLAIN_REPO_ANTHROPIC_MODEL.

Publishing to PyPI

The distribution name, Python requirement, runtime dependencies, build backend, and [project.scripts] entry point are defined in pyproject.toml. The script entry is what lets uvx install the distribution and invoke explain-repo.

  1. Choose the next semantic version and update both project.version in pyproject.toml and __version__ in src/explain_repo/__init__.py.
  2. Run uv lock, uv sync, uv run pytest, and uvx --from . explain-repo ..
  3. Build clean wheel and source distributions with uv build.
  4. Check the release files with uvx twine check dist/*.
  5. Create a PyPI trusted publisher for the repository's release workflow, or create a scoped PyPI API token.
  6. Publish interactively with uv publish; when prompted for token credentials, use __token__ as the username and the PyPI token as the password. In CI, prefer PyPI trusted publishing instead of storing a long-lived token.
  7. Verify the published release with uvx --refresh --from explain-repo==<version> explain-repo --help.

PyPI makes the distribution globally discoverable. Before publication, uvx --from . explain-repo PATH is the correct local equivalent.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

explain_repo-0.1.0.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

explain_repo-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file explain_repo-0.1.0.tar.gz.

File metadata

  • Download URL: explain_repo-0.1.0.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Garuda Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for explain_repo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 64362ba3a21bdf9497a18d4653ecd0f64c382888a0395fec1c7d31a6628afee4
MD5 08159dd2466b890aaebab62309c9ec65
BLAKE2b-256 963be613b6b374df979d758393554658d80b97146c16401e1b0671a21d0abf8d

See more details on using hashes here.

File details

Details for the file explain_repo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: explain_repo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Garuda Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for explain_repo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 163ef346c17718feead48b8d45e8fd21a60b9f8a90d4434bd13a7eda2edb9242
MD5 24d8561af1afda681d6a98ca09d66a52
BLAKE2b-256 20f46f3914a4215b80a944007c1f1cf23f1dc152c48991accf72582eca0449b5

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

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