using-git-worktrees
OBobra/superpowers298k2,631 new stars in the last 7 days
Bootstrap branch-context on an existing PR. Writes issue-brief.md from the linked issue(s) + current PR state, and backfills pr-decisions.md with decision-bearing entries from already-resolved review threads. Use when picking up a PR mid-flight (yours or someone else's) without prior local context.
Populate issue-brief.md and pr-decisions.md for a worktree whose PR already
exists and has history.
Do not use this for fresh work with no PR yet -- write the brief from the linked issue directly.
Bootstrapping presumes the linked issue describes a real problem. If you have not confirmed that, skim the issue before adopting -- authorship (a bot, contributor, or automated sweep) is not proof the problem is real.
CLAUDE.md for project context.cd "$(git rev-parse --show-toplevel)"
D=.claude/skills/branch-context
[ -f "$D/issue-brief.md" ] || cp "$D/issue-brief.template.md" "$D/issue-brief.md"
[ -f "$D/pr-decisions.md" ] || cp "$D/pr-decisions.template.md" "$D/pr-decisions.md"
If issue-brief.md already has populated issues: frontmatter, ask via
AskUserQuestion whether to overwrite the brief, re-seed decisions, both, or
neither, before proceeding.Parse $ARGUMENTS:
PR_NUMBER=$(gh pr view --json number -q .number 2>/dev/null)
If detection fails, ask via AskUserQuestion.Fetch PR metadata:
gh pr view "$PR_NUMBER" --json number,title,url,state,headRefName,body,closingIssuesReferences,createdAt,author
Two sources, in order:
closingIssuesReferences from the PR metadata (canonical -- set via the PR
sidebar or Fixes #N keywords).(?:Fixes|Closes|Resolves|Relates to) #\d+ if
(1) is empty.For each linked issue:
gh issue view "<N>" --json number,url,title,state,body,labels,comments
If there is no linked issue and the body has no problem description worth
linking, proceed with issues: [] (free-text problem) -- ask the user whether to
continue or abort.
Understand the code before synthesizing the brief:
git fetch origin main 2>/dev/null || git fetch origin master
MERGE_BASE=$(git merge-base HEAD origin/main 2>/dev/null || git merge-base HEAD origin/master)
git diff --stat "$MERGE_BASE"..HEAD
git log --oneline "$MERGE_BASE"..HEAD
Map the changes: which files/modules are touched, which tests exist on the branch (existing tests are implied success criteria), which public symbols changed, any notable new abstractions.
issue-brief.mdUse the schema in issue-brief.template.md. Adaptations for adoption:
related_pr: the PR URL (not TBD -- the PR already exists).branch: git rev-parse --abbrev-ref HEAD.Write to .claude/skills/branch-context/issue-brief.md, overwriting the
template.
pr-decisions.md from resolved threadsFetch resolved review threads via the GraphQL API:
read -r OWNER REPO < <(gh repo view --json owner,name -q '.owner.login + " " + .name')
gh api graphql -f query='
query($owner:String!,$repo:String!,$pr:Int!){
repository(owner:$owner,name:$repo){
pullRequest(number:$pr){
reviewThreads(first:100){ nodes{
isResolved
comments(first:50){ nodes{ author{login} bodyText url path } }
}}
}
}
}' -F owner="$OWNER" -F repo="$REPO" -F pr="$PR_NUMBER" \
--jq '.data.repository.pullRequest.reviewThreads.nodes | map(select(.isResolved))'
For each resolved thread, read the full conversation, then classify:
For each decision-bearing thread, append an entry (Source is the root comment's
url):
.claude/skills/branch-context/append-pr-decision.sh \
--title "thread: <short title>" \
--decision "<one-line summary of what was decided>" \
--why "<one-line reason, quoting reviewer or author if concise>" \
--source "<thread URL>" \
--iter "-"
Decision budget: aim for <=10 entries. If more resolved threads than that seem worth logging, you are probably over-including noise -- re-apply the filter.
Append one final entry marking the boundary between backfilled decisions (everything above) and live-logged ones (everything below):
.claude/skills/branch-context/append-pr-decision.sh \
--title "adopted PR #<N> at <DATE>" \
--decision "Branch-context bootstrapped from existing PR + issue(s). Decisions above are backfilled from resolved threads." \
--why "PR predates the branch-context setup" \
--source "<PR URL>" \
--iter "-"
Print a concise summary:
Adopted PR #<N> -- "<title>"
Issues linked: #<A>, #<B>
Resolved threads seeded: <count> decisions
Unresolved threads (for later triage): <count>
Source:. If you cannot find
one, you are over-inferring -- skip it.OBobra/superpowers298k2,631 new stars in the last 7 days
OBobra/superpowers298k2,631 new stars in the last 7 days
OBobra/superpowers298k2,631 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days