prepare-pr-diff-worktree

Create an isolated git worktree for a GitHub pull request and export its diff.

Updated Mar 3, 2026
One-click install
npx skills add https://github.com/D3Hunter/ai-engineer --skill prepare-pr-diff-worktree
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prepare-pr-diff-worktree
Source: https://github.com/D3Hunter/ai-engineer/tree/main/skills/prepare-pr-diff-worktree
Command: npx skills add https://github.com/D3Hunter/ai-engineer --skill prepare-pr-diff-worktree

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires git, gh, curl, and includes scripts (resource) components.

What problem does it solve?

Manually setting up an isolated git worktree for a GitHub pull request, checking out the PR code, and exporting the PR diff is time-consuming and error-prone, especially when you don't have the gh CLI authenticated or are working outside the target repository.

Core Features & Use Cases

  • Isolated PR Worktree Creation: Automatically creates a unique, isolated git worktree under the target repository's worktrees/ directory to avoid disrupting your main working copy.
  • Flexible PR Checkout: Supports checking out PRs via authenticated gh pr checkout or a public git fetch fallback for unauthenticated use cases.
  • Automatic Diff Export: Saves the PR diff as a <pr-number>.diff file in the worktree root, using gh pr diff or a direct GitHub URL fallback.
  • Use Case: A software engineer needs to review changes in a large open source PR without cloning the entire repo or affecting their local feature branch, even if they don't have a GitHub auth token configured.

Quick Start

Use this skill to create an isolated worktree for the GitHub pull request at https://github.com/tidb/tidb/pull/12345, export its diff, and get the worktree path and metadata for your review workflow.

Frequently Asked Questions about prepare-pr-diff-worktree

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I checkout a GitHub pull request to an isolated git worktree?

To checkout a GitHub pull request to an isolated git worktree, this skill automates creating a unique worktree under the target repository's worktrees directory and checks out the PR code without disrupting your main working copy.

Can I fetch a PR diff without having the gh CLI authenticated?

Yes, you can fetch a PR diff without gh CLI authentication. The skill supports a public git fetch fallback for checking out PRs and a direct GitHub URL fallback for exporting the diff file.

How do I export a pull request diff file for code review outside the repository?

To export a pull request diff file outside the repository, the skill automatically saves the PR changes as a <pr-number>.diff file in the isolated worktree root directory using gh pr diff or a direct GitHub URL.

Do I need to be inside the target git repository to create a PR worktree?

No, you do not need to be inside the target git repository to create a PR worktree. The skill operates effectively for code change analysis and diff export even when you are working entirely outside the target repository.

What is the best way to get structured metadata for a PR worktree for downstream automation?

The best way to get structured metadata for a PR worktree is using this skill, which returns a structured JSON object containing the worktree absolute path, diff filename, and worktree name to satisfy downstream automation requirements.