Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Code History?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ku5ic-code-history)
---
name: code-history
description: A file or folder's git and PR history: turning points, recurring bugs, broken promises, who to ask
argument-hint: "<file or folder path, or a component name>"
allowed-tools:
- Bash(gh pr diff *)
- Bash(gh pr view *)
- Bash(glab mr diff *)
- Bash(glab mr view *)
- Bash(git log *)
- Bash(kit code-graph *)
- Bash(kit git-base *)
- Bash(kit scratch-dir *)
---
# /code-history
The git and PR history of a file or folder, as a report with turning points, recurring bugs, broken promises, who to ask, and a short story. With no argument, ask for the path before anything else.
Loading this skill isn't enough. Before the step a row names, read its file.
| Before | Read |
| ----------------------------------- | -------------------------------------------- |
| Collecting commits or lines changed | [reference/git-log.md](reference/git-log.md) |
| Writing the report | [reference/report.md](reference/report.md) |
## Inputs
1. Resolve the argument to a real path. A loose name ("Filter ds component") may not match one: search with `fd` and `rg`, pick the match, and state the substitution in the report header.
2. Size the job: `git log --format='%h' -- <path> | wc -l`.
3. Find the code host per `skills/kit-rules/reference/tooling.md` section 4, and resolve the repo's path and default branch through it. With no CLI or connector for the host, say so, take the default branch from `kit git-base`, and work from commits alone.
4. A docs or decision-log connector, found the same way, is optional. If one exists, search it for the component name and record whether any entry covers it.
## Collect
Read every commit and every PR description that touches the path. Don't sample.
1. Commit list: `git log --format='%H%x09%ad%x09%an%x09%s' --date=short -- <path>`, saved to the raw folder.
2. PR numbers from subjects, in each form the host writes: a squash suffix `(#1234)`, `Merge pull request #1234`, or `See merge request <path>!1234`.
3. Fetch PRs in batches through the host's batched PR-bodies operation (`skills/code-host-patterns`), never one call per PR. Save the raw JSON.
4. Lines changed on the path per commit (`git log --numstat -- <path>`), ranked. The top entries are the structural turning points, found faster than by title. When `difft` is installed, drop reformat-only ones first: `DFT_CHECK_ONLY=true GIT_EXTERNAL_DIFF=difft git show --ext-diff --format=%h <sha> -- <path>` prints `No syntactic changes.` for a file whose diff is only formatting. Prose files print `Has changes.` either way.
5. For the biggest PRs with empty descriptions, read the squash commit body (it lists sub-commits) and the diffstat on the path. State what the diffstat and commit body show, not a why, and list the PR under Caveats as having no description.
## Digest
1. Strip PR template boilerplate before reading: checklists, "Type of change", tooling notes. Otherwise the signal drowns.
2. Write a chronological digest, one heading per PR linking to it, cleaned body below.
3. Grep the digest for promises and reversals: `temporary`, `for now`, `will be removed`, `TODO`, `in the future`, `revert`. Check each against the current code before calling it unkept.
4. Group fixes by bug class to find the ones that keep coming back.
5. For "Who to ask": `git shortlog -sn --no-merges -- <path>` for commits per author, and `git log --format='%ad %an' --date=short -- <path>` for each one's first and last commit there.
## Report
Shape and writing rules: [reference/report.md](reference/report.md).
## Output
- Report at the path `kit scratch-dir history <component-slug>` prints.
- Raw material in a sibling folder named after the report (without `.md`): `prs.json`, `commits.tsv`, `digest.md`.
## Verify before replying
Check by script, not by eye:
1. Every `#<n>` in the report is in the collected PR list and resolves to a PR in this repo.
2. Every linked file or folder exists on the default branch (`git cat-file -e <default>:<path>`).
3. The header counts match `git log -- <path>` and the collected PR list.
4. No TL;DR bullet runs past two lines, and the story is under about 300 words.
## Reply
Per `skills/kit-rules/reference/output.md` section 3.
## Out of scope
- Proposing fixes or refactors.
- Code review of the current state.
- History of code that only imports the path, unless a PR moved code into or out of it.
Arguments: `$ARGUMENTS`