Skip to content

Add git-blame-historic-context skill#4373

Open
AryanGodara wants to merge 3 commits intomainfrom
aryan/git-blame-skill
Open

Add git-blame-historic-context skill#4373
AryanGodara wants to merge 3 commits intomainfrom
aryan/git-blame-skill

Conversation

@AryanGodara
Copy link
Copy Markdown
Member

@AryanGodara AryanGodara commented May 1, 2026

What this is

A standalone procedure for using git blame to 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

/blame-context crates/driver/src/domain/competition/solution/settlement.rs:444

Worked sample output is in the skill file's Example section.

@AryanGodara AryanGodara changed the title Add git-blame-historic-context skill" Add git-blame-historic-context skill May 1, 2026
@AryanGodara AryanGodara force-pushed the aryan/git-blame-skill branch from 07f2227 to ff73770 Compare May 5, 2026 13:45
@AryanGodara AryanGodara marked this pull request as ready for review May 5, 2026 13:48
@AryanGodara AryanGodara requested a review from a team as a code owner May 5, 2026 13:48
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .claude/commands/blame-context.md Outdated
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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
  1. 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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
gh pr view <NNNN> -R <owner>/<repo>
gh pr view <NNNN>
References
  1. Focus on identifying logic that deviates from the PR's stated goals (end-to-end automation). (link)

@AryanGodara AryanGodara force-pushed the aryan/git-blame-skill branch from 9b89fe4 to 8cb5c1d Compare May 5, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant