Get the FREE Ultimate OpenClaw Setup Guide →

gh-pr-diff

npx machina-cli add skill dceoy/github-cli-agent-skills/gh-pr-diff --openclaw
Files (1)
SKILL.md
1.9 KB

GitHub PR Diff

When to use

  • The user asks to see what changed in a PR.
  • Reviewing code changes before merge.
  • Getting a list of files changed in a PR.

Inputs to confirm

  • PR number, URL, or branch name (or current branch PR).
  • Output format (full diff, name-only, patch).
  • Target repo if not current (--repo OWNER/REPO).

Workflow

  1. Verify auth:

    gh --version
    gh auth status
    
  2. View the diff:

    # Full diff
    gh pr diff 123
    
    # List changed files only
    gh pr diff 123 --name-only
    
    # Patch format
    gh pr diff 123 --patch
    
  3. Control color output:

    gh pr diff 123 --color always
    gh pr diff 123 --color never | less
    
  4. Open in browser for visual diff:

    gh pr diff 123 --web
    

Examples

# View diff of current branch's PR
gh pr diff

# See only file names changed
gh pr diff 123 --name-only

# Get patch format for applying elsewhere
gh pr diff 123 --patch > changes.patch

# Pipe to less for large diffs
gh pr diff 123 --color always | less -R

Flags reference

FlagDescription
--colorColor output: always, never, auto (default: auto)
--name-onlyShow only names of changed files
--patchDisplay diff in patch format
-w, --webOpen diff in browser

Notes

  • Without arguments, shows diff for current branch's PR.
  • Use --name-only for quick overview of scope.
  • Patch format is useful for cherry-picking or backup.

References

Source

git clone https://github.com/dceoy/github-cli-agent-skills/blob/main/skills/gh-pr-diff/SKILL.mdView on GitHub

Overview

gh-pr-diff lets you quickly inspect what changed in a GitHub pull request using the gh CLI. It supports full diffs, file lists, and patch formats, helping reviewers and maintainers understand changes before merging.

How This Skill Works

It uses gh pr diff under the hood to fetch the diff for a PR identified by number, URL, or the current branch. You can request a full diff, a names-only list, or a patch, and optionally target a different repo with --repo.

When to Use It

  • You want to see what changed in a PR.
  • You're reviewing code changes before merging.
  • You need a quick overview of which files were touched.
  • You want a patch for cherry-picking or backup.
  • You prefer viewing a visual diff in a browser with --web.

Quick Start

  1. Step 1: Install gh and authenticate with gh --version and gh auth status
  2. Step 2: Identify the PR by number, URL, or current branch
  3. Step 3: Run gh pr diff 123 with your preferred format, e.g. gh pr diff 123 --name-only

Best Practices

  • Confirm the PR identifier (number, URL, or branch) and target repo when not on the PR's base.
  • Choose the right diff format with --name-only, --patch, or full diff.
  • Use gh auth status before diff to ensure access.
  • Leverage --color and piping to less for large diffs.
  • Open in browser with --web for a visual diff when needed.

Example Use Cases

  • View diff of current branch's PR: gh pr diff
  • Show only changed file names: gh pr diff 123 --name-only
  • Output a patch for backup: gh pr diff 123 --patch > changes.patch
  • View diff with color and paginate: gh pr diff 123 --color always | less -R
  • Open diff in browser for a visual comparison: gh pr diff 123 --web

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers