Skip to main content

Claude Code Prompt to Analyze Git History and Code Health

Turn Claude Code into a git-history auditor: hotspots, churn, bug-fix frequency, file coupling, bus factor, and risk scoring for upcoming changes in your repo.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt turns Claude Code into a forensic auditor of your git history. Instead of asking for an opinion on the current code, it points Claude at the log — commits, diffs, PRs, authorship — over a window you choose, and asks ten specific, computable questions: hotspots, bug-fix frequency by directory, churn (add/delete ratio), commit-size and author distribution, PR quality, file coupling, debt signals in messages, recommendations, change risk, and bus factor.

It works because every one of those ten outputs is derivable from data Claude Code can actually read with git log, git log --numstat, and gh pr list. The numbered structure forces the model to treat history as a dataset rather than guess. Hotspots come from change counts, coupling from files co-occurring in commits, bus factor from author concentration per directory. Nothing here asks Claude to invent — it asks it to aggregate and interpret what your repo already recorded.

When to use it

  • Onboarding to an unfamiliar codebase and you want the risky, high-churn areas before you touch anything.
  • Pre-refactor planning — find the files that change together so you scope the blast radius correctly.
  • A quarterly engineering-health review for stakeholders who want evidence, not vibes.
  • Spotting a module that's quietly accumulating bug fixes (a stability red flag).
  • Identifying bus-factor-1 directories before a key engineer goes on leave or leaves.
  • Reviewing whether your team's PRs are getting larger and slower over time.

Example output

HOTSPOTS (last 90 days)
  app/Services/Billing.php      47 commits   ⚠ 19 were bug fixes
  resources/views/checkout.blade  31 commits

COUPLING (changed together >80% of the time)
  Billing.php ⇄ InvoiceObserver.php   (24/27 commits)

BUS FACTOR
  app/Services/Billing/   ← 91% by one author  RISK: HIGH

RISK FOR UPCOMING CHANGES
  Touching Billing.php = high churn + bug-prone + single owner.
  Recommend: pair review + characterization tests first.

Pro tips

  • Set [time_period] to match a release cadence (one quarter), not "all time" — old churn drowns recent signal and skews hotspots toward founding commits.
  • Bug-fix detection is only as good as your commit hygiene. If you prefix fixes (fix:, bug:) or reference issue IDs, tell Claude the convention so #2 and #7 are accurate.
  • For [pr_count], 20–30 is the sweet spot — enough to see PR-size and review-latency trends without flooding the context window.
  • Ask for [report_format] as Markdown for a readme, or JSON when you want to feed the hotspot/coupling data into a dashboard or follow-up script.
  • Pair it with a second pass: take the top hotspot it finds and run a focused code review on that one file. History tells you where the risk is; the file read tells you what it is.

Frequently Asked Questions

Does this run real git commands or just guess from the repo?
It runs real commands. Claude Code reads your history with git log, git log --numstat, and gh pr list, then aggregates the results. Hotspots, churn, coupling, and bus factor are computed from actual commit data, not estimated from a glance at the current code.
Why are its bug-fix and tech-debt numbers sometimes off?
Sections 2 and 7 read commit messages, so they inherit your team's commit hygiene. If fixes aren't labeled (no fix:, bug:, or issue references) they're undercounted. Tell Claude your message conventions in the prompt and accuracy improves sharply.
Will it work on a huge monorepo with years of history?
Yes, but scope it. A wide [time_period] on a large repo can exceed the context window and bury recent signal under old churn. Use one quarter and a moderate [pr_count] (20-30); for repo-wide stats, run it per top-level directory instead.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Claude Code Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support