Official agent skill

Adopt PR Branch Context

by pydantic in pydantic/pydantic-ai-harness

Fills in issue-brief.md and pr-decisions.md for an existing pull request, so you can pick up a PR mid-flight with its linked issue and past review decisions summarized.

OfficialMITAuto-check passedDevelopment

Install Adopt PR Branch Context

skills CLI
$ npx skills add pydantic/pydantic-ai-harness --skill adopt-pr -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install pydantic/pydantic-ai-harness adopt-pr --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/pydantic/pydantic-ai-harness.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/adopt-pr .claude/skills/adopt-pr && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
adopt-pr
GitHub stars
948
Token cost
~1.8k tokens
SKILL.md length
621 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Fills in issue-brief.md and pr-decisions.md for an existing pull request, so you can pick up a PR mid-flight with its linked issue and past review decisions summarized.

  • Works in 7 steps: Resolve the PR → Resolve linked issues → Study the existing diff → …
  • Picking up someone else's pull request that has no local context
  • SKILL.md covers When to use, Startup, Step 1 -- Resolve the PR and Step 2 -- Resolve linked issues, plus 6 more sections
  • Calls git and gh

What it does

This skill bootstraps branch-context files on a worktree whose pull request already has history. It writes issue-brief.md from the linked issues and the current PR state, and backfills pr-decisions.md with decision-bearing entries taken from review threads that are already resolved. It suits PRs you checked out fresh, PRs you are taking over from someone else, and your own PRs that predate the branch-context setup.

The steps are to read CLAUDE.md for project context, create the branch-context files from their templates if missing, and ask before overwriting a brief that is already populated. The agent then resolves the PR from an argument or the current branch with gh, collects linked issues from the PR's closing references or, failing that, from Fixes, Closes or Resolves keywords in its body, and studies the diff against the merge base. It cautions that an issue's author is no proof the problem is real, and it is not meant for new work with no PR yet.

When your agent uses it

  • Picking up someone else's pull request that has no local context
  • Backfilling a brief for your own PR that predates the branch-context setup
  • Recovering the decisions made in already-resolved review threads

Example prompts

  • “Adopt the PR on my current branch and write the issue brief from its linked issue.”
  • “I just checked out a colleague's pull request, so backfill pr-decisions.md from the resolved review threads.”
  • “Bootstrap branch context for this PR before I continue the work.”

Requirements

  • The gh CLI authenticated for the repository
  • A worktree with the PR branch checked out
  • The branch-context skill files in the repository
  • Pre-approved tools (allowed-tools): Bash(git:*), Bash(gh:*), Bash(jq:*), Bash(date:*), Bash(ls:*), Bash(cat:*), Bash(cp:*), Bash(.claude/skills/branch-context/*), Read, Write, Edit, Glob, Grep, AskUserQuestion

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Resolve the PR
  2. Resolve linked issues
  3. Study the existing diff
  4. Write issue-brief.md
  5. Backfill pr-decisions.md from resolved threads
  6. Seed an "adoption" meta-entry
  7. Report

What it can do on your machine

Read from SKILL.md and the folder at commit 4399efa. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Bash(git:*)
    • Bash(gh:*)
    • Bash(jq:*)
    • Bash(date:*)
    • Bash(ls:*)
    • Bash(cat:*)
    • Bash(cp:*)
    • Bash(.claude/skills/branch-context/*)
    • Read
    • Write

    …and 4 more on the same allowed-tools line.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • gh

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git and gh, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Adopt PR Branch Context loads about 1.8k tokens when it runs. Until then it costs about 77 tokens; SKILL.md has 621 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~77
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from pydantic/pydantic-ai-harness at commit 4399efa, republished under its MIT licence (© pydantic). 621 words, ~1,751 tokens.

Download SKILL.mdSave it as .claude/skills/adopt-pr/SKILL.md (or your agent's skills folder).
name
adopt-pr
description
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.
allowed-tools
Bash(git:*), Bash(gh:*), Bash(jq:*), Bash(date:*), Bash(ls:*), Bash(cat:*), Bash(cp:*), Bash(.claude/skills/branch-context/*), Read, Write, Edit, Glob, Grep, AskUserQuestion
user-invocable
true

Adopt PR -- bootstrap branch-context on an existing PR

Populate issue-brief.md and pr-decisions.md for a worktree whose PR already exists and has history.

When to use

  • You checked out an existing PR and the branch-context files are empty templates (or absent).
  • You are picking up someone else's PR.
  • Your own PR predates the branch-context setup and you want to backfill.

Do not use this for fresh work with no PR yet -- write the brief from the linked issue directly.

Startup

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.

  1. Read CLAUDE.md for project context.
  2. Instantiate the branch-context instances if they do not exist:
    bash
    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.

Step 1 -- Resolve the PR

Parse $ARGUMENTS:

  • PR number/URL -> use it directly.
  • Empty -> detect from the current branch:
    bash
    PR_NUMBER=$(gh pr view --json number -q .number 2>/dev/null)
    If detection fails, ask via AskUserQuestion.

Fetch PR metadata:

bash
gh pr view "$PR_NUMBER" --json number,title,url,state,headRefName,body,closingIssuesReferences,createdAt,author

Step 2 -- Resolve linked issues

Two sources, in order:

  1. closingIssuesReferences from the PR metadata (canonical -- set via the PR sidebar or Fixes #N keywords).
  2. Fallback: grep the PR body for (?:Fixes|Closes|Resolves|Relates to) #\d+ if (1) is empty.

For each linked issue:

bash
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.

Step 3 -- Study the existing diff

Understand the code before synthesizing the brief:

bash
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.

Step 4 -- Write issue-brief.md

Use 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.
  • Success criteria -- derive from the issue text and from tests already on the branch (each existing test is a de facto criterion; cross-reference them in the table).
  • Affected surface -- extract from the diff, not from a planning pass.
  • Constraints -- include anything reviewers have already emphasized in comments (e.g. "must preserve backwards-compat" from a maintainer reply).

Write to .claude/skills/branch-context/issue-brief.md, overwriting the template.

Show full SKILL.md (244 more words)Show less

Step 5 -- Backfill pr-decisions.md from resolved threads

Fetch resolved review threads via the GraphQL API:

bash
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:

  • Decision-bearing -- the thread debated two or more options, or a reviewer flagged a concern and the author adjusted the code (e.g. "use kwargs over positional", "renamed the public method", "moved the helper to a different module").
  • Noise -- typo fixes, "nit: missing docstring", "good catch thanks", resolved without a code change. Skip these.

For each decision-bearing thread, append an entry (Source is the root comment's url):

bash
.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.

Step 6 -- Seed an "adoption" meta-entry

Append one final entry marking the boundary between backfilled decisions (everything above) and live-logged ones (everything below):

bash
.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 "-"

Step 7 -- Report

Print a concise summary:

Adopted PR #<N> -- "<title>"
  Issues linked: #<A>, #<B>
  Resolved threads seeded: <count> decisions
  Unresolved threads (for later triage): <count>

Rules

  • Do not open a new PR (it already exists). Do not commit anything to the branch during adoption -- only read, classify, and write the two branch-context files.
  • Do not re-classify unresolved threads during adoption -- just report the count.
  • Do not log every resolved thread -- only decision-bearing ones. The decisions log is meant to reward reading; diluting it with noise defeats the point.
  • Every backfilled entry must have a thread URL in Source:. If you cannot find one, you are over-inferring -- skip it.
  • If the existing brief/decisions files are already populated (not templates), the user's Startup confirmation governs whether to overwrite.

© pydantic, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/adopt-pr of pydantic/pydantic-ai-harness.

Open the folder on GitHubat commit 4399efa

Compare with similar skills

Adopt PR Branch Context next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Adopt PR Branch Context compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Adopt PR Branch Context this skillpydantic/pydantic-ai-harness948—~1.8kAutomated safety check: PassMIT
Review Triage Phaseprisma/orm48k—~995Automated safety check: PassApache-2.0
Understand Diff AnalysisEgonex-AI/Understand-Anything86k1 repos~1.4kAutomated safety check: PassMIT
Open Code Review CLIalibaba/open-code-review44k—~3.1kAutomated safety check: PassApache-2.0
Code Reviewflutter/flutter179k—~1.4kAutomated safety check: PassBSD-3-Clause
PR Review State Fetchprisma/orm48k—~767Automated safety check: PassApache-2.0

Similar skills

  • Official

    Runs the triage step of the review-framework loop: reads fetched PR review state, builds `review-actions.json`, validates it and renders `review-actions.md`.

    48k GitHub stars~995 tokensUpdated today
    DevelopmentAuto-check passed
  • Understand Diff Analysis

    Egonex-AI/Understand-Anything

    Reads your git changes or a pull request against a prebuilt knowledge graph of the project to explain what changed, which components are affected and what is risky.

    86k GitHub starsUsed in 1 repo~1.4k tokens
    DevelopmentAuto-check passed
  • Open Code Review CLI

    alibaba/open-code-review

    Runs the ocr command-line tool to review Git changes, a commit or a branch comparison with an AI model, returning line-level comments and optionally applying fixes.

    44k GitHub stars~3.1k tokensUpdated 3 days ago
    DevelopmentAuto-check passed
  • Code Review

    flutter/flutter

    Performs a comprehensive, multi-step code review of pull requests or local code changes, using iterative refinement (generation, critique, synthesis) to ensure high-quality, actionable feedback.

    179k GitHub stars~1.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    Fetches a pull request's canonical review state as JSON, validates it, and renders markdown, a text summary and triage target files from it using bundled scripts.

    48k GitHub stars~767 tokensUpdated today
    DevelopmentAuto-check passed
  • Knowledge Graph PR Review

    tirth8205/code-review-graph

    Reviews a pull request or branch diff with a code knowledge graph and produces a structured review that includes blast-radius analysis.

    32k GitHub stars~452 tokensUpdated yesterday
    DevelopmentAuto-check passed

More from pydantic/pydantic-ai-harness

  • Branch Context Handoff

    pydantic/pydantic-ai-harness

    Official

    Keeps a branch-local issue brief, decision log and session handoffs so a pull request's context survives across separate agent sessions.

    948 GitHub stars~1.7k tokensUpdated 5 days ago
    Auto-check: notes
  • Pushing Commits To The Repo

    pydantic/pydantic-ai-harness

    Official

    What to do when you open a PR and every time you push -- label the PR, watch CI to green, triage every review comment to a reply and a reaction, and escalate genuine design trade-offs to maintainers.

    948 GitHub stars~566 tokensUpdated 5 days ago
    Auto-check passed

Works with

Questions about Adopt PR Branch Context

What does Adopt PR Branch Context do?

Fills in issue-brief.md and pr-decisions.md for an existing pull request, so you can pick up a PR mid-flight with its linked issue and past review decisions summarized. This skill bootstraps branch-context files on a worktree whose pull request already has history.md with decision-bearing entries taken from review threads that are already resolved.

When should I use Adopt PR Branch Context?

Adopt PR Branch Context fits situations like: picking up someone else's pull request that has no local context; backfilling a brief for your own PR that predates the branch-context setup; recovering the decisions made in already-resolved review threads.

How do I install Adopt PR Branch Context in Claude Code?

Run `npx skills add pydantic/pydantic-ai-harness --skill adopt-pr -a claude-code`. Or copy the skill folder (.agents/skills/adopt-pr in pydantic/pydantic-ai-harness) into .claude/skills/adopt-pr in your project. Claude Code loads it when a task matches its description.

How do I install Adopt PR Branch Context in Codex?

Run `npx skills add pydantic/pydantic-ai-harness --skill adopt-pr -a codex`. Or copy the skill folder (.agents/skills/adopt-pr in pydantic/pydantic-ai-harness) into .agents/skills/adopt-pr in your project. Codex loads it when a task matches its description.

Can I use Adopt PR Branch Context in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add pydantic/pydantic-ai-harness --skill adopt-pr -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/adopt-pr, .gemini/skills/adopt-pr, .github/skills/adopt-pr and .opencode/skills/adopt-pr in your project.

What does Adopt PR Branch Context need to run?

Going by SKILL.md and its folder, Adopt PR Branch Context needs the command-line tools its instructions call (git and gh). Our summary lists: The gh CLI authenticated for the repository; A worktree with the PR branch checked out; The branch-context skill files in the repository. Its frontmatter pre-approves these tools: Bash(git:*), Bash(gh:*), Bash(jq:*), Bash(date:*), Bash(ls:*), Bash(cat:*), Bash(cp:*), Bash(.claude/skills/branch-context/*), Read, Write, Edit, Glob, Grep, AskUserQuestion.

Does Adopt PR Branch Context access the network?

SKILL.md contains no URLs. Its commands use git and gh, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Adopt PR Branch Context safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Adopt PR Branch Context use?

Adopt PR Branch Context is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Adopt PR Branch Context use?

About 1.8k tokens (SKILL.md is roughly 7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Adopt PR Branch Context?

Skills that share tags, products or a category with Adopt PR Branch Context: Review Triage Phase (prisma/orm, 48k stars), Understand Diff Analysis (Egonex-AI/Understand-Anything, 86k stars), Open Code Review CLI (alibaba/open-code-review, 44k stars) and Code Review (flutter/flutter, 179k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Adopt PR Branch Context?

pydantic (a GitHub organization, an official publisher) maintains it in pydantic/pydantic-ai-harness, which has 948 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 2, 2026.

Source: pydantic/pydantic-ai-harness on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.