Agent skill bus factor

From diegopacheco/ai-playground · View interactive version

Agent skill bus factor is an AI agent skill from the GitHub repository diegopacheco/ai-playground. Builds a knowledge-risk heatmap of a git repository. Runs git blame across tracked files, finds the ones owned by a single person, computes a bus factor per file, directory, and author, and renders a light-theme website that shows where knowledge is concentrated. Use when the user runs /bus-factor o

How to use this skill

Skill file

Bus-Factor Map

When invoked, you measure how concentrated knowledge of a codebase is in single people, then render a light-theme website that shows the risk visually. The "bus factor" of a file is the smallest number of authors who together own more than half of its surviving lines. A bus factor of 1 means one person could leave and take the only knowledge of that file with them.

Global Context

Rules

Step 1 — Choose the target

The scan runs against either the current repository or a GitHub repository the skill clones into a temporary folder. Decide which from $ARGUMENTS:

Step 2 — Clone the GitHub repository (GitHub mode only)

Clone the full history into a temporary folder named after the repo. Full history is mandatory — a shallow clone collapses every line into one commit and destroys the blame attribution the whole analysis depends on.

tmp_root="$(mktemp -d)"
name="$(basename "<URL>" .git)"
git clone "<URL>" "$tmp_root/$name"

If the clone fails (bad URL, private repo with no access, no network), report the git error to the user and stop. Large repositories take longer to clone and to blame.

Step 3 — Run the analysis engine

In current-repo mode, confirm a git repository first; GitHub mode skips this because the fresh clone is already one:

git rev-parse --show-toplevel

If this fails, tell the user the current directory is not a git repository and stop.

The engine enumerates tracked files with git ls-files, runs git blame --line-porcelain -w -M -C on each source file, counts surviving lines per author, and computes the per-file bus factor, per-author sole ownership, per-directory rollups, and a repo-level grade. It then renders the website by injecting the data into the template. It always writes bus-factor-report/ into the current working directory and finds its own template, so invoke it by its installed absolute path.

```bash

python3 "$HOME/.claude/skills/bus-factor/scripts/bus_factor.py" $ARGUMENTS

```

```bash

( cd "$tmp_root/$name" && python3 "$HOME/.claude/skills/bus-factor/scripts/bus_factor.py" )

cp -R "$tmp_root/$name/bus-factor-report" .

rm -rf "$tmp_root"

```

Notes:

Step 4 — Open the report

The report is now at bus-factor-report/index.html in the current working directory. Open it:

open bus-factor-report/index.html

On Linux use xdg-open bus-factor-report/index.html instead.

Step 5 — Summarize for the user

The engine prints a text summary to stdout. Relay the key signals in your reply:

Keep it short. The website carries the detail; your reply points the user at the highest-risk findings.

How the website reads

Risk model (for reference)

Per file, on a 0–100 scale:

A file is counted as single-owned when its top author holds at least 80% of the lines and its bus factor is 1. The repo grade is the lines-of-code weighted average risk mapped to A through F.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.