git-xray 🩻
X-ray any git repository in one command. Find the code that hurts: hotspots, bus factor, hidden coupling, stale and orphaned files.
pipx install git-xray-tool # or: pip install git-xray-tool
# one-off run: uvx --from git-xray-tool git-xray
cd your-repo
git xray
The package is called git-xray-tool on PyPI; the command is git-xray, or just
git xray. No config, no server, no dependencies. Pure Python and git. It analyses Flask's
3,800 commits in under a second.
Why?
Your git history already knows where the problems are. The files that change all the time and are large are where bugs pile up and velocity goes to die. Directories that only one person understands are a risk. Files that always change together hint at a missing abstraction.
Tools like code-maat pioneered this
analysis (see Your Code as a Crime Scene), but they need a JVM, a log export
step and a spreadsheet. git-xray gives you the answers in one command.
What it shows
| Section | Question it answers |
|---|---|
| 🔥 Hotspots | Which files change most often and are big? Your best refactoring targets. |
| 🚌 Bus factor | How many people would have to leave before nobody knows a directory? |
| 🔗 Hidden coupling | Which files keep changing in the same commits, even though nothing says they're related? |
| 🧊 Stale code | Which big files has nobody touched in a year? |
| 👻 Orphaned code | Which files were mostly written by someone who is no longer active? |
| 👥 Contributors | Who did the work in this time range? |
Usage
git xray # whole history of the current repo
git xray --since "6 months ago" # recent activity only
git xray src/ lib/ # limit to some paths
git xray -n 25 # show 25 rows per section
git xray --depth 2 # bus factor per src/foo instead of src/
git xray -x "*.generated.ts" # extra excludes (repeatable)
git xray -C ~/code/other-repo # analyse another repo
Output formats
git xray --md > XRAY.md # Markdown: paste into a PR, wiki or issue
git xray --json | jq '.hotspots' # JSON: build your own dashboards or CI checks
All options
usage: git-xray [-h] [-C DIR] [--since WHEN] [-n TOP] [--depth DEPTH]
[--min-coupling N] [--stale-days N] [-x GLOB]
[--no-default-excludes] [--include-bots] [--json | --md]
[--color {auto,always,never}] [-V]
[paths ...]
| Option | Default | Meaning |
|---|---|---|
--since WHEN |
all history | Only commits newer than WHEN (anything git log --since accepts) |
-n, --top |
10 | Rows per section |
--depth |
1 | Directory depth used for bus-factor grouping |
--min-coupling |
5 | Minimum shared commits before a pair is reported |
--stale-days |
365 | Days without change before a file counts as stale / an author as inactive |
-x, --exclude |
Glob to skip, repeatable | |
--no-default-excludes |
Keep lockfiles, vendor/, dist/, changelogs, minified files… |
|
--include-bots |
Count dependabot, renovate and other bots | |
--color |
auto | Respects NO_COLOR and FORCE_COLOR |
--icons |
auto | emoji, plain (no emoji) or ascii. Also GIT_XRAY_ICONS |
How the numbers are computed
- Hotspot score =
commits / max_commits × log(loc) / log(max_loc). Change frequency matters most; size is log-scaled so one giant file does not drown out everything else. - Bus factor = the smallest number of authors who together wrote more than 50% of the changed lines in a directory.
- Coupling degree =
shared_commits / average(commits of A, commits of B). Commits touching more than 30 files (mass renames, formatting) are ignored. - Orphaned = the main author wrote at least 50% of the file and has made no commit in
--stale-days. - Renames are followed (
git log -M), so history survivesgit mv. Merge commits are skipped. Author identities respect your.mailmap.
These are heuristics, not verdicts. A hotspot can be a healthy, central module; the point is to know where to look.
FAQ
Is it fast on big repos? It runs git log once and parses it in a single pass.
Most repos take a second or two. On huge monorepos, narrow it down with --since or a path.
Does it send my code anywhere? No. It runs git locally and prints to your terminal.
I see boxes, garbled symbols or broken columns. git-xray picks a glyph set
from your terminal. In Japanese, Chinese and Korean locales it uses plain ASCII,
because those terminals draw box and block characters double-wide. Some other
terminals still can't draw emoji. Use
git xray --icons plain (no emoji) or --icons ascii, or set it once with
export GIT_XRAY_ICONS=plain (PowerShell: $env:GIT_XRAY_ICONS="plain").
Why git xray and not git-xray? Both work. git treats any git-<name>
executable on your PATH as a subcommand.
Contributing
Issues and PRs are welcome! Ideas we would love help with:
an HTML report, --fail-on thresholds for CI, and per-author knowledge maps.
git clone https://github.com/ckh0at/git-xray && cd git-xray
python -m venv .venv && .venv/bin/pip install -e . pytest
.venv/bin/pytest
License
MIT
Metadata
Release files for git-xray-tool 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| git_xray_tool-0.1.0.tar.gz | 17.2 kB | Without provenance | Details for git_xray_tool-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| git_xray_tool-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for git_xray_tool-0.1.0-py3-none-any.whl |
Total release size: 33.6 kB
Release files / git_xray_tool-0.1.0.tar.gz
| Download URL | git_xray_tool-0.1.0.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d54e46d32922046ff2068b85e5d09f3df1750e2fe26fd7203cb59e0331aba980
|
|
BLAKE2b-256 checksum How to use checksums |
80dc2b9c3e3f8b7440738cbb666211a24a6d71bf6ad83deb52fbfaa8b8204bed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / git_xray_tool-0.1.0-py3-none-any.whl
| Download URL | git_xray_tool-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
42a4eb9fe405cc3d89c541afbc43478e9f86a7f76413c9d24da28ea3bee1c8e6
|
|
BLAKE2b-256 checksum How to use checksums |
bd5ba8f4c19ed88744c266addbb4060bdad9d14f762fb4fdd8e6b41553a95f2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for git-xray-tool 0.1.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.