cnb-pr-diff

Extract pull request diff changes from CNB repositories using git and the CNB API.

3|1|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/wopal-cn/wopal-space-ontology --skill cnb-pr-diff-wopal-cn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cnb-pr-diff
Source: https://github.com/wopal-cn/wopal-space-ontology/tree/main/skills/cnb-pr-diff
Command: npx skills add https://github.com/wopal-cn/wopal-space-ontology --skill cnb-pr-diff-wopal-cn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Reviewing pull requests requires locating the correct head and base commits and generating readable diffs, which is tedious when done manually across different trigger contexts like PR comments or issue references. ## Core Features & Use Cases - Context-Aware SHA Resolution: Automatically detects whether the run is triggered by a PR comment (via CNB environment variables) or by a user-mentioned PR number, then resolves head and target SHAs through the CNB API. - Flexible Diff Extraction: Produces changed file lists, diff statistics, full diffs with configurable context lines, and per-file diffs using git three-dot comparison. - Noise Filtering: Excludes lock files, images, binaries, build artifacts, and dependency directories so reviews focus on meaningful code changes. - Use Case: During an automated code review on CNB, fetch the diff of PR !45, exclude package-lock.json and dist files, and summarize the actual source code changes. ## Quick Start Get the diff for pull request !45, excluding lock files and build artifacts, and summarize the code changes.

Frequently Asked Questions about cnb-pr-diff

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

FAQPage Schema
How do I get the diff of a pull request from the command line?

Use git diff with the three-dot syntax between the target and head SHAs, such as git diff -U5 target_sha...head_sha. First resolve the SHAs from the PR metadata via the platform API, then fetch the commits locally if they are missing.

How to exclude lock files and build artifacts from a git diff?

Pass pathspec exclusions after the diff command, for example git diff sha1...sha2 -- . ':!package-lock.json' ':!dist/*' ':!*.min.js'. This filters out lock files, images, minified assets, and dependency directories so only relevant code changes remain.

Does this work with pull requests referenced outside a PR comment trigger?

Yes. When the PR number is mentioned in an issue or other context, the skill parses the number, queries the CNB API for the PR details to obtain head and base SHAs, and fetches those commits before computing the diff.

What should I do when a pull request diff is too large to review?

Start with git diff --name-only to list changed files, then use --stat for a summary, and request full diffs only for specific files with git diff -U5 sha1...sha2 -- path/to/file. This keeps output manageable for large PRs.

Why does git diff fail with missing commits for a PR?

The local clone may not contain the PR head or base commits. Run git fetch origin with the specific SHAs, or a full git fetch origin, to download the missing objects before running the diff.