Inspect a repository through git history before opening source files, so you can decide where to look first and what kinds of risks to expect.
Review process:
- Run the churn hotspot commands from
references/churn-hotspots.md.
- Run the ownership commands from
references/ownership-signals.md.
- Run the bug-cluster commands from
references/bug-clusters.md.
- Run the commit-activity commands from
references/activity-trends.md.
- Run the firefighting commands from
references/firefighting-signals.md.
- Cross-reference the results and rank the first files, folders, teams, and time periods to inspect.
If doing partial work, load only the relevant reference files.
Core Instructions
- Start with git history before opening code when the user is new to the repository, asks for an audit, or wants to plan a refactor.
- Prefer a 6 to 12 month window for active repositories and a 1 year window for stable repositories, unless the user specifies otherwise.
- Treat churn as a signal, not a verdict. High churn may reflect active product work rather than bad architecture.
- Treat authorship counts as directional, not absolute. Squash-merge workflows can hide real contributors.
- Treat bug-fix commit filtering as approximate. Weak commit messages reduce signal quality.
- Cross-reference churn hotspots with bug clusters before declaring a file high-risk.
- Use directory-level churn when file-level results are too noisy or when the user needs a faster first pass.
- Use new-file and deleted-file patterns to distinguish growth from instability.
- Use recent per-file authorship to see who currently carries a risky area.
- Use activity by month to infer momentum, staffing changes, and release batching, but call these interpretations hypotheses rather than facts.
- Use large recent commits as inspection targets when you suspect risky big-bang changes.
- Use revert and hotfix frequency as a proxy for delivery stress, testing gaps, or weak release processes.
- After the git pass, recommend a concrete reading order: the first files, folders, or time periods to inspect next.
- If the user asks for a review, findings should focus on risk signals and next inspection targets, not generic repository summaries.
- By default, create
git-codebase-preflight-report.md in the current working directory.
- Also return a concise summary in chat unless the user explicitly asks for file-only output.
- If the user explicitly asks not to generate a file, do the analysis in chat only.
Output Format
If the user asks for a preflight review, organize findings into these sections:
Hotspots - top churn files and any overlap with bug-fix patterns.
Ownership - key contributors, whether they are still active, and any bus-factor concerns.
Change Shape - whether the area is growing, being deleted, or getting reorganized.
Momentum - what the monthly commit pattern suggests.
Firefighting - whether reverts or hotfixes appear normal or frequent.
Next Reads - the first files or areas to inspect in code.
For each important signal:
- Include the exact command used.
- Summarize the output in plain language.
- State the confidence level or caveat if the signal is noisy.
- Recommend what to inspect next because of it.
If the user asks you to run this workflow on the current repository, run the commands directly instead of returning a generic checklist.
Default deliverable behavior:
- Create
git-codebase-preflight-report.md with the full structured write-up.
- Return a concise summary in chat with the highest-signal findings.
- Skip creating the file only if the user explicitly asks for a chat-only run.
If the output is large:
- Summarize the most important findings in chat.
- Avoid dumping raw command output unless it materially supports the conclusion.
- Put the detailed findings in
git-codebase-preflight-report.md.
Example output:
Hotspots
app/services/billing.rb is both high-churn and bug-adjacent.
Command:
git log --format=format: --name-only --since="1 year ago" | sort | uniq -c | sort -nr | head -20
Interpretation:
- This file appears near the top of the churn list, which means the team changes it repeatedly.
- If the same file also appears in bug-fix commits, it should be the first code file to inspect.
Ownership
One contributor dominates the history, but is missing from recent activity.
Command:
git shortlog -sn --no-merges --since="6 months ago"
Interpretation:
- This suggests knowledge concentration risk.
- Confirm whether squash merges are masking real authorship before drawing a stronger conclusion.
Next Reads
app/services/billing.rb
app/models/subscription.rb
- Deployment or release automation touching rollback paths
End of example.
References
references/churn-hotspots.md - commands and heuristics for identifying the most frequently changed files.
references/ownership-signals.md - commands and caveats for contributor concentration and recent maintainers.
references/bug-clusters.md - commands for mapping bug-fix commits to likely defect hotspots.
references/activity-trends.md - monthly commit trend analysis and interpretation patterns.
references/firefighting-signals.md - revert, hotfix, emergency, and rollback signals in recent history.
1---2name: git-codebase-preflight3description: Audits a repository through git history before reading source files. Use when inheriting a codebase, starting a review, planning a refactor, or deciding which files to inspect first.4license: MIT5---67Inspect a repository through git history before opening source files, so you can decide where to look first and what kinds of risks to expect.89Review process:10111. Run the churn hotspot commands from `references/churn-hotspots.md`.121. Run the ownership commands from `references/ownership-signals.md`.131. Run the bug-cluster commands from `references/bug-clusters.md`.141. Run the commit-activity commands from `references/activity-trends.md`.151. Run the firefighting commands from `references/firefighting-signals.md`.161. Cross-reference the results and rank the first files, folders, teams, and time periods to inspect.1718If doing partial work, load only the relevant reference files.192021## Core Instructions2223- Start with git history before opening code when the user is new to the repository, asks for an audit, or wants to plan a refactor.24- Prefer a 6 to 12 month window for active repositories and a 1 year window for stable repositories, unless the user specifies otherwise.25- Treat churn as a signal, not a verdict. High churn may reflect active product work rather than bad architecture.26- Treat authorship counts as directional, not absolute. Squash-merge workflows can hide real contributors.27- Treat bug-fix commit filtering as approximate. Weak commit messages reduce signal quality.28- Cross-reference churn hotspots with bug clusters before declaring a file high-risk.29- Use directory-level churn when file-level results are too noisy or when the user needs a faster first pass.30- Use new-file and deleted-file patterns to distinguish growth from instability.31- Use recent per-file authorship to see who currently carries a risky area.32- Use activity by month to infer momentum, staffing changes, and release batching, but call these interpretations hypotheses rather than facts.33- Use large recent commits as inspection targets when you suspect risky big-bang changes.34- Use revert and hotfix frequency as a proxy for delivery stress, testing gaps, or weak release processes.35- After the git pass, recommend a concrete reading order: the first files, folders, or time periods to inspect next.36- If the user asks for a review, findings should focus on risk signals and next inspection targets, not generic repository summaries.37- By default, create `git-codebase-preflight-report.md` in the current working directory.38- Also return a concise summary in chat unless the user explicitly asks for file-only output.39- If the user explicitly asks not to generate a file, do the analysis in chat only.404142## Output Format4344If the user asks for a preflight review, organize findings into these sections:45461. `Hotspots` - top churn files and any overlap with bug-fix patterns.471. `Ownership` - key contributors, whether they are still active, and any bus-factor concerns.481. `Change Shape` - whether the area is growing, being deleted, or getting reorganized.491. `Momentum` - what the monthly commit pattern suggests.501. `Firefighting` - whether reverts or hotfixes appear normal or frequent.511. `Next Reads` - the first files or areas to inspect in code.5253For each important signal:54551. Include the exact command used.561. Summarize the output in plain language.571. State the confidence level or caveat if the signal is noisy.581. Recommend what to inspect next because of it.5960If the user asks you to run this workflow on the current repository, run the commands directly instead of returning a generic checklist.6162Default deliverable behavior:63641. Create `git-codebase-preflight-report.md` with the full structured write-up.651. Return a concise summary in chat with the highest-signal findings.661. Skip creating the file only if the user explicitly asks for a chat-only run.6768If the output is large:69701. Summarize the most important findings in chat.711. Avoid dumping raw command output unless it materially supports the conclusion.721. Put the detailed findings in `git-codebase-preflight-report.md`.7374Example output:7576### Hotspots7778**`app/services/billing.rb` is both high-churn and bug-adjacent.**7980Command:8182```bash83git log --format=format: --name-only --since="1 year ago" | sort | uniq -c | sort -nr | head -2084```8586Interpretation:87- This file appears near the top of the churn list, which means the team changes it repeatedly.88- If the same file also appears in bug-fix commits, it should be the first code file to inspect.8990### Ownership9192**One contributor dominates the history, but is missing from recent activity.**9394Command:9596```bash97git shortlog -sn --no-merges --since="6 months ago"98```99100Interpretation:101- This suggests knowledge concentration risk.102- Confirm whether squash merges are masking real authorship before drawing a stronger conclusion.103104### Next Reads1051061. `app/services/billing.rb`1071. `app/models/subscription.rb`1081. Deployment or release automation touching rollback paths109110End of example.111112113## References114115- `references/churn-hotspots.md` - commands and heuristics for identifying the most frequently changed files.116- `references/ownership-signals.md` - commands and caveats for contributor concentration and recent maintainers.117- `references/bug-clusters.md` - commands for mapping bug-fix commits to likely defect hotspots.118- `references/activity-trends.md` - monthly commit trend analysis and interpretation patterns.119- `references/firefighting-signals.md` - revert, hotfix, emergency, and rollback signals in recent history.