Skip to main content

git-xray 🩻

X-ray any git repository in one command. Find the code that hurts: hotspots, bus factor, hidden coupling, stale and orphaned files.

PyPI Python CI License: MIT

git-xray running on the Flask repository
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 survives git 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.1

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

Source distribution (sdist)

Source distribution for git-xray-tool 0.1.1
File Size Uploaded Provenance Actions
git_xray_tool-0.1.1.tar.gz 17.6 kB Without provenance Details for git_xray_tool-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for git-xray-tool 0.1.1
File Interpreter ABI Platform Actions
git_xray_tool-0.1.1-py3-none-any.whl Python 3 none any Details for git_xray_tool-0.1.1-py3-none-any.whl

Total release size: 34.1 kB

Release files / git_xray_tool-0.1.1.tar.gz

Download URL git_xray_tool-0.1.1.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
30e2a8b230a65d88e3d42821e7d3657baf8f9f79ea024e4fac6a74aea5c56a55
BLAKE2b-256 checksum
How to use checksums
fb98c2b000d9214e0a4e74bf2be41aa76caafc441a8ca38d9771633ef832ebb8
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.1-py3-none-any.whl

Download URL git_xray_tool-0.1.1-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0504b7d57c81095efd1ef51844807e70d107d8e8e61375bd8ba3d79ddf56e6c
BLAKE2b-256 checksum
How to use checksums
e23f8bf2ee38d97d4f841cc7688d7757adfa55f24b3a4076f9044297975c8fe7
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.1

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.

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