Add git-blame-historic-context skill#4373
Conversation
07f2227 to
ff73770
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a new Claude command and detailed documentation for the 'git blame historic context' skill, which assists developers in understanding the rationale behind unusual code by tracing it back to its originating PR. The feedback focuses on improving the automation of the gh pr view command by removing unnecessary repository flags that would require manual variable substitution, allowing the CLI to infer the context automatically.
| 1. `git blame -L <start>,<end> -- <path>` to find the originating commit. | ||
| 2. If the surface looks like a wholesale move/refactor (same author across many lines, recent date, identical hashes), retry with `git blame -w -C -C -C -L <start>,<end> -- <path>` to recover the real authoring commit. | ||
| 3. `git log -1 --format='%s%n%b' <sha>` for the commit body. | ||
| 4. If the subject ends with `(#NNNN)`, pivot to the PR conversation: `gh pr view <NNNN> -R <owner>/<repo>`. The PR body is usually richer than the squash commit alone. |
There was a problem hiding this comment.
The placeholder / in the gh pr view command will cause the command to fail when executed by the AI, as it won't have a value for these variables. Since the command is executed within a git repository, the gh CLI can automatically detect the repository context. Removing the -R flag makes the procedure truly end-to-end and more robust.
| 4. If the subject ends with `(#NNNN)`, pivot to the PR conversation: `gh pr view <NNNN> -R <owner>/<repo>`. The PR body is usually richer than the squash commit alone. | |
| 4. If the subject ends with (#NNNN), pivot to the PR conversation: gh pr view <NNNN>. The PR body is usually richer than the squash commit alone. |
References
- Focus on identifying logic that deviates from the PR's stated goals (end-to-end automation). (link)
| # subject ends with "(#NNNN)" — extract the PR number, then pivot to the | ||
| # PR conversation, which is usually richer than the commit body alone. | ||
| git log -1 --format='%s%n%b' <sha> | ||
| gh pr view <NNNN> -R <owner>/<repo> |
There was a problem hiding this comment.
The placeholder / in the gh pr view command is problematic for automated execution. Since the tool is intended to be used within the repository context, the gh CLI can infer the repository automatically. Removing the explicit repository flag ensures the command works without requiring the AI to guess or prompt for the owner and repository names.
| gh pr view <NNNN> -R <owner>/<repo> | |
| gh pr view <NNNN> |
References
- Focus on identifying logic that deviates from the PR's stated goals (end-to-end automation). (link)
9b89fe4 to
8cb5c1d
Compare
What this is
A standalone procedure for using
git blameto recover historic context before flagging unusual-looking code. Often code looks weird because it had to due to a deliberate workaround, a fix, or a hot-patch from prod.This skill formalises the lookup + decision rubric.
Ships with
/blame-context <path>:<line>, a slash command that wraps the procedure end-to-end. Use either the slash command or the procedure manually.Why split out
Extracted from #4351 because the procedure is reusable beyond PR review — order-debug sessions and ad-hoc code investigations both want the same lookup play. Splitting keeps each consumer's surface focused.
Files
docs/skills/git-blame-historic-context.md— the procedure + decision rubric..claude/commands/blame-context.md— slash command wrapping the procedure.Reviewing this in isolation
The skill body is self-contained — see the new "How to invoke" and "Example" sections. The "Used by" footer links to
../COW_PR_REVIEW_SKILL.md, which lands with #4351; that link will 404 until that PR merges. Nothing else here depends on #4351.How to try it
Worked sample output is in the skill file's Example section.