About prepare-branch-context
A read-only skill that builds context about the current Git branch for follow-up work. It examines the branch diff and commits, checks for a related PR, and summarizes the changes and review state.
Key features
- 01Identify branch and merge base
- 02Read the diff against main
- 03Review branch commit history
- 04Check for a related pull request
- 05Summarize changes and review context
Use cases
- 01Understand an existing branch before making changes
- 02Prepare for follow-up work on a pull request
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ jnsahaj/ skills --skill prepare-branch-contextAfter installing, type/prepare-branch-contextin Claude Code to confirm it loaded.
Details
From the project READMEPrepare Branch Context
Build a comprehensive understanding of the current branch so you can handle followup requests with full context.
Steps
-
Identify the current branch and base branch:
git branch --show-current git merge-base HEAD main -
Gather the diff from main:
git diff main...HEAD --stat git diff main...HEADRead through the full diff carefully. Understand what files were changed, added, or removed, and what the changes do.
-
Review the commit history on this branch:
git log main..HEAD --onelineRead commit messages to understand the progression of changes.
-
Check for a related PR:
gh pr list --head "$(git branch --show-current)" --json number,title,body,url,state,comments --jq '.[0]'If a PR exists, read its title, description, and comments for additional context (acceptance criteria, discussion, review feedback).
-
Summarize your understanding to the user:
- What this branch does (high-level purpose)
- Key files and areas of the codebase affected
- Notable decisions or patterns visible in the changes
- Any open review comments or discussion from the PR
- Current state (clean, uncommitted changes, etc.)
-
Signal readiness: Tell the user you're ready for followup questions or tasks related to this branch.
Rules
- Do NOT make any changes to files. This skill is read-only.
- Read the actual diff content, not just the stat summary. You need to understand the code changes.
- If there's no PR, that's fine — just skip that step and note it.
- If the diff is very large, focus on understanding the overall structure first, then read key files in detail.
- Keep the summary concise but thorough enough that you could confidently make changes to this branch.
- If the branch is
mainor has no divergence from main, tell the user there's nothing to analyze.