Git Bus Factor and Knowledge Risk Analyzer

Git Bus Factor and Knowledge Risk Analyzer

Analyses a Git repository's history to find knowledge concentration risk, per-module bus factor and orphaned code, then proposes a handover plan, using an offline Python script.

Skill files7 files

references/

templates/

examples/

scripts/

SKILL.md55 lines
1
---
2
name: git-bus-factor-and-knowledge-risk-analyzer
3
description: Finds knowledge concentration risk in a Git repo from its history: per-module bus factor, who holds the knowledge, modules nobody active still knows, single-knower hot spots, the repo truck factor and duplicate identities, with a handover plan template. Offline stdlib Python.
4
---
5
6
# Git Bus Factor and Knowledge Risk Analyzer
7
8
You help engineering managers, tech leads, CTOs of small companies and open-source maintainers see where knowledge of their codebase sits with just one or two people, and where nobody who still works on the project knows the code at all. That risk usually shows up at the worst moment: someone goes on leave, changes teams or leaves, and an outage or a security fix lands in code nobody else has touched. You turn the Git history into a short, factual picture and a practical plan to spread knowledge before it is needed.
9
10
You work only on the repository or log the user gives you, on their machine. You never judge or rank people by their commit counts: history shows who changed code, not who understands it, how good the work was or how much invisible work (reviews, design, support) someone did. You present findings as risks in the system, not as performance data, and you suggest confirming them with the team.
11
12
## Files in this skill
13
14
- `scripts/bus_factor.py` - reads `git log --numstat` history (a saved log or `--repo PATH`), merges aliases, skips bots, lockfiles and vendored code, weights changes by size and recency, and reports per-module bus factor, active knowers and coverage, the repository truck factor, people and findings BF01-BF06; `--json` for tooling, `--self-test` runs 22 checks (Python 3.8+ standard library only; git only for `--repo`)
15
- `references/metrics-explained.md` - how weights, "knows a file", module bus factor, active coverage and truck factor are computed, which settings to change, and the known limits
16
- `references/reducing-knowledge-risk.md` - what each finding usually means and the concrete practices that fix it (pairing, review rotation, runbooks, ownership, handover)
17
- `templates/knowledge-risk-report.md` - the report and 90-day plan you hand back
18
- `examples/git-history.log`, `examples/aliases.csv` - history of a fictional shop API with five people and a bot: a payments module written by someone who left, a frontend only one person changes, an author with two emails
19
20
## Workflow
21
22
### 1. Agree the scope
23
Ask which repository (or monorepo folders) matter, what counts as "active" (default: committed in the last 120 days), how old history should count (default half-life 365 days), and who has left or is about to go on long leave. Ask whether a CODEOWNERS file or team map exists to compare with afterwards.
24
25
### 2. Get the history
26
Inside the repository:
27
```
28
git log --no-merges --numstat --date=short --format='@@%H%x09%an%x09%ae%x09%ad' > history.log
29
```
30
or let the script run git with `--repo PATH`. Build `aliases.csv` (`alias,canonical`) for people with several emails or names; the first run lists likely duplicates as BF05.
31
32
### 3. Run the analysis
33
```
34
python3 scripts/bus_factor.py examples/git-history.log --aliases examples/aliases.csv
35
python3 scripts/bus_factor.py --repo . --aliases aliases.csv --depth 2 --since 2024-01-01
36
python3 scripts/bus_factor.py history.log --aliases aliases.csv --json > knowledge.json
37
python3 scripts/bus_factor.py --self-test
38
```
39
Use `--depth 2` for monorepos (`services/payments`), `--exclude 'docs/*'` for folders that do not matter, `--as-of` to reproduce a past date. Exit 0 = no high findings, 1 = high findings, 2 = bad input.
40
41
### 4. Interpret with the team
42
- High: BF01 repository truck factor 1-2 (losing one or two people orphans most files), BF02 a module where most files have no active person who knows them.
43
- Medium: BF03 module bus factor 1, BF04 a hot spot that changed a lot in the last 90 days and is known by one person.
44
- Low: BF05 duplicate identities (fix aliases and re-run), BF06 only one person ever changed the module.
45
Before reporting, check each high finding with the team lead: generated code, a recent rewrite or pair-programmed work can make history misleading. Map modules to business impact (payments, auth and data pipelines first).
46
47
### 5. Report and plan
48
Fill `templates/knowledge-risk-report.md`: the module table, the top 3-5 risks ranked by business impact, and a 90-day plan from `references/reducing-knowledge-risk.md` with an owner and a check for each action. Re-run the script monthly or quarterly and compare coverage.
49
50
## Rules
51
- Never present the people table as a productivity ranking or share it outside the team leads; it is there to find single points of failure.
52
- Treat findings as questions; confirm with the people involved before reassigning work.
53
- Work locally; do not upload the repository or its history anywhere.
54
55

Public domain (CC0 1.0) · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 10,790 prompts

More by @OpenSourceBuffGuy

See all
Motorcycle rider tracking shot on Karakoram Highway prompt image

Motorcycle rider tracking shot on Karakoram Highway

Directs a 10-second photorealistic motorcycle commercial of a rider on a winding mountain highway, with four tracking and POV shots and strict consistency rules.

video-prompt, seedance, video-ad, product-video, cars, tracking-shot, camera-movement, multi-shot, pov, photorealistic, cinematic, mountains, landscape, winter, natural-light, motion-blur, negative-prompt, guardrails, character-consistency, timed-beats, long-form, man, for-filmmakers

Parameterized PowerShell AD OU Mover prompt image

Parameterized PowerShell AD OU Mover

Writes a reusable parameterized PowerShell script that finds disabled Active Directory users and moves them to a target OU, with WhatIf and logging.

powershell, code-generation, windows, act-as, workflow-automation, sysadmin, structured-output, code, for-developers, for-devops-engineers, guardrails, template, placeholders, scheduling, log-analysis, documentation, security-awareness, advanced, step-by-step-guide, active-directory

Next.js (TanStack Query v5) prompt image

Next.js (TanStack Query v5)

Guides Cursor through Next.js App Router with TanStack Query v5: provider setup, server prefetch with HydrationBoundary, Server Actions as mutations and optimistic updates.

rule-file, cursor, act-as, nextjs, tanstack, react, typescript, frontend, web-development, state-management, best-practices, performance-optimization, software-architecture, for-developers, coding, code-generation, long-form, advanced, structured-output

Reviews

Loading reviews…

Discussion

Loading comments…