explain-repo
explain-repo statically analyzes a local or remote 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
Run the published package without installing it globally:
uvx explain-repo ./path/to/repository
uvx explain-repo https://github.com/OWNER/REPOSITORY.git
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
The CLI accepts either a local directory or a Git repository URL. Remote repositories are cloned into a temporary directory, analyzed, and automatically deleted afterward. The original repository is not modified.
Analyze a public GitHub repository without cloning it manually:
uvx explain-repo https://github.com/OWNER/REPOSITORY.git
Use --ref to analyze a branch, tag, or commit:
uvx explain-repo https://github.com/OWNER/REPOSITORY.git --ref develop
uvx explain-repo https://github.com/OWNER/REPOSITORY.git --ref v1.2.0
uvx explain-repo https://github.com/OWNER/REPOSITORY.git --ref a1b2c3d
HTTPS and SSH Git URLs are supported. Private repositories work when your local
Git installation already has access through SSH keys or a credential helper.
The --ref option applies only to URL sources; local directories are analyzed
as they currently exist on disk.
explain-repo [OPTIONS] SOURCE
| Option | Description |
|---|---|
--top N |
Number of files to show (default: 10). |
--json |
Output structured JSON. |
--ref REF |
Branch, tag, or commit to analyze for a Git URL. |
--rank-method METHOD |
Use indegree or pagerank (default: pagerank). |
--llm |
Add structure-only LLM descriptions. |
--llm-provider PROVIDER |
Use ollama or anthropic (default: ollama). |
--version |
Show the version and exit. |
--help |
Show help and exit. |
Examples:
uvx explain-repo . --top 5
uvx explain-repo https://github.com/OWNER/REPOSITORY.git --top 5
uvx explain-repo . --rank-method indegree
uvx explain-repo . --json > report.json
uvx 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 LLM descriptions
LLM descriptions use only the file path and extracted imports, function names, class names, and method names. Full source content is never sent.
Ollama (free and local)
Ollama is the default provider in explain-repo 0.2.0 and newer. It runs on
your computer, requires no API key, and has no per-request charge.
-
Install Ollama. On Linux:
curl -fsSL https://ollama.com/install.sh | shFor macOS or Windows, use the installer from ollama.com/download.
-
Confirm the installation:
ollama --version -
Download the default model (approximately 2 GB):
ollama pull qwen2.5-coder:3b ollama list
-
Start the local server if the installer did not start it automatically:
ollama serveKeep that terminal open. A message that port
11434is already in use usually means Ollama is already running. -
From another terminal, test the current source checkout:
cd /home/alintm4/Desktop/read-repo uvx --from . explain-repo /path/to/repository --top 3 --llm
-
After
0.2.0is published to PyPI, run it from anywhere:uvx --refresh --from explain-repo==0.2.0 explain-repo /path/to/repository --top 3 --llm
Each top-ranked file causes one local model request. Use a small --top value
for faster reports on machines with limited memory.
To select another installed model, set EXPLAIN_REPO_OLLAMA_MODEL:
EXPLAIN_REPO_OLLAMA_MODEL=qwen2.5-coder:7b uvx explain-repo . --llm
To connect to Ollama on another machine, set the server URL:
EXPLAIN_REPO_OLLAMA_URL=http://hostname:11434 uvx explain-repo . --llm
If the command reports that it cannot connect:
ollama serve
curl http://localhost:11434/api/tags
If it reports that the model is missing, run:
ollama pull qwen2.5-coder:3b
No API key or paid account is required, and extracted structure stays on your computer.
Anthropic
Anthropic remains available as an optional hosted provider. Install the llm
extra and provide credentials in the environment:
export ANTHROPIC_API_KEY="..."
uv sync --extra llm
uv run explain-repo . --llm --llm-provider anthropic
Override the default Anthropic 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.
- Choose the next semantic version and update both
project.versioninpyproject.tomland__version__insrc/explain_repo/__init__.py. - Run
uv lock,uv sync,uv run pytest, anduvx --from . explain-repo .. - Build clean wheel and source distributions with
uv build. - Check the release files with
uvx twine check dist/*. - Create a PyPI trusted publisher for the repository's release workflow, or create a scoped PyPI API token.
- 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. - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file explain_repo-0.2.0.tar.gz.
File metadata
- Download URL: explain_repo-0.2.0.tar.gz
- Upload date:
- Size: 36.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c17a81f1eb9c84d09a2369a25b35472f6bbd1d6aab2e6223c703a037890f5ae
|
|
| MD5 |
d535fb6d7a2176e71d26013307aa0255
|
|
| BLAKE2b-256 |
c525a65519b191881d609f94b895e48e3e3faae796b5bad040145961aa3a5855
|
File details
Details for the file explain_repo-0.2.0-py3-none-any.whl.
File metadata
- Download URL: explain_repo-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab72b70070782c2ffc831db8e2505aa9a8f7d9b994ea882ffbbce8c52c0bb4f3
|
|
| MD5 |
d63ef83408f63f8cdae7ad3da4451be4
|
|
| BLAKE2b-256 |
ab86f08cd3c25e8e8679566005db666813713e88b9a9b7c777688815a04f2a5c
|