explain-this-pr

$npx mdskill add Varnan-Tech/opendirectory/explain-this-pr

Explains a GitHub PR in plain English and posts a summary comment.

  • Solves the need to quickly understand what a pull request changes.
  • Depends on the GitHub CLI (`gh`) for fetching PR data and posting comments.
  • Determines the PR from a URL, number, or current branch provided by the user.
  • Posts a plain-English explanation as a comment on the pull request.

SKILL.md

.github/skills/explain-this-prView on GitHub ↗
---
name: explain-this-pr
description: Takes a GitHub PR URL or the current branch and writes a plain-English explanation of what it does and why, then posts it as a PR comment. Use when asked to explain a PR, summarize a pull request, write a plain-English description of a PR, add a summary comment to a PR, or understand what a PR changes. Trigger when a user says "explain this PR", "summarize this pull request", "what does this PR do", "add a comment explaining the PR", or shares a GitHub PR URL and asks what it does.
compatibility: [claude-code, gemini-cli, github-copilot]
author: OpenDirectory
version: 1.0.0
---

# Explain This PR

Read a GitHub pull request, understand what it changes, and write a plain-English explanation. Post it as a PR comment so reviewers have instant context.

---

## Step 1: Check Setup

Confirm `gh` is authenticated:

```bash
gh auth status
```

If not authenticated: `gh auth login` and follow the prompts.

Confirm input. The user must provide one of:
- A GitHub PR URL (e.g. `https://github.com/owner/repo/pull/123`)
- A PR number in the current repo (e.g. `#123`)
- The keyword "current" to use the PR for the current branch

If no input, ask: "Which PR should I explain? Share the URL, PR number, or say 'current' for the active branch."

---

## Step 2: Fetch PR Context

**Get PR metadata:**
```bash
gh pr view PR_URL_OR_NUMBER --json number,url,title,body,author,baseRefName,headRefName,additions,deletions,changedFiles,commits,labels,state,isDraft
```

If `isDraft` is `true`, note this to the user: "This PR is still in draft. The explanation is based on its current state."

**Get the diff:**
```bash
gh pr diff PR_URL_OR_NUMBER
```

If the diff is over 400 lines, read the `--stat` summary and the first 200 lines of the diff:
```bash
gh pr view PR_URL_OR_NUMBER --json files
gh pr diff PR_URL_OR_NUMBER | head -200
```

**Get existing comments (to avoid repeating what is already there):**
```bash
gh pr view PR_URL_OR_NUMBER --json comments --jq '.comments[].body' 2>/dev/null | head -20
```

---

## Step 3: Write the Explanation

Write two paragraphs. Read each rule before writing.

**Paragraph 1: What it does (technical)**

- One sentence per major change
- Name the specific files, functions, or systems that changed
- State the before/after if the diff makes it clear
- Include concrete numbers if present in the diff (lines removed, tables dropped, endpoints added)
- Active voice, present tense

Example:
```
Replaces the in-memory session cache in auth.middleware.ts with a Redis-backed cache (src/cache/redis.ts). Adds get, set, and invalidate methods to the new Redis module and wraps UserService.getById() with a 5-minute TTL. Removes the Map-based cache that was limited to a single process and caused session drift across multiple instances.
```

**Paragraph 2: Why it matters (business/product impact)**

- Who benefits and how
- What problem this solves or what risk it reduces
- If the commit messages contain a "why", use that context
- If there is no clear "why" in the diff or commits, omit this paragraph rather than guessing

Example:
```
Users hitting the /api/me endpoint under load were getting inconsistent session data across server instances, causing intermittent 401 errors. This change makes session state consistent across all instances and reduces database load by eliminating one query per authenticated request.
```

**Rules for both paragraphs:**
- No em dashes — use a comma or period
- No filler: "this PR", "this change", "as you can see"
- No invented outcomes. Only state impacts that are directly visible in the diff or commit messages
- If the PR is a pure refactor with no behavior change, say that explicitly: "Refactors X to Y with no change in observable behavior."
- Under 150 words total

---

## Step 4: Self-QA

Before posting, check:

- [ ] Paragraph 1 names specific files or functions from the diff
- [ ] No invented metrics or outcomes
- [ ] No em dashes
- [ ] No filler phrases
- [ ] Under 150 words total
- [ ] If no clear "why" exists, paragraph 2 is omitted rather than guessing

Fix any violation before posting.

---

## Step 5: Post as PR Comment

Present the explanation to the user. Ask: "Ready to post this as a PR comment, or would you like to edit it first?"

On confirmation, pass the body via stdin to handle backticks, quotes, and newlines safely:

```bash
gh pr comment PR_URL_OR_NUMBER --body-file - << 'EOF'
EXPLANATION_HERE
EOF
```

After posting: "Comment added. View it at: [url from Step 2]"

If the user says "output only", present the explanation in a code block for manual copy-paste without posting.


More from Varnan-Tech/opendirectory

SkillDescription
app-store-review-arbitrageFetches low-star App Store and Google Play reviews, clusters them into broken-promise patterns, and generates a ranked copy brief with positioning opportunities.
blog-cover-generatorUse when the user asks to generate a blog cover image, thumbnail, or article header. Automatically uses modern typography, brand logos, and Google Search grounding to create beautiful 16:9 images with Gemini 3.1 Flash Image Preview.
brand-alchemyWorld-class brand strategist and naming expert. Uses an interrogation-led discovery phase to extract your brand's DNA, then applies scientific naming frameworks (Phonosemantics) and automated multi-TLD domain checking.
claude-md-generatorUse when the user asks to generate or update a project's CLAUDE or AGENTS context file from a codebase scan. Writes a focused file under 100 lines containing only the non-obvious build commands, conventions, and gotchas Claude Code needs.
cold-email-verifierUse when the user wants to verify cold emails, enrich a lead list, or autonomously guess email addresses from a CSV using ValidEmail.co or the open-source Reacher engine.
company-radarCompetitive intelligence orchestrator tracking companies across 8+ platforms (GitHub, Twitter, Reddit, HN, PH, YC Jobs) with heat scores and AI briefings.
competitor-pr-finderGive it your product URL or description. It finds your top 5 competitors, runs three-track PR research across all of them (editorial, podcasts, communities), identifies which channels appear most frequently, looks up the journalist or host for each, and returns a tiered outreach list with story angles and ready-to-send cold pitch drafts tailored to your product. Use when asked to find PR opportunities, discover where competitors got featured, build a media outreach list, find which journalists cover my space, or get pitch templates for press coverage.
cook-the-blogGenerate high-converting, deep-dive growth case studies in MDX format. Use this skill when asked to write a case study or blog post about a company's growth, tech stack, or product-led strategy. It handles the full pipeline (researching the company via Tavily, generating a 16:9 cover image, quality checking the draft, uploading assets to cloud storage, and pushing directly to the target repository).
dependency-update-botScans your project for outdated npm, pip, Cargo, Go, or Ruby packages. Runs a CVE security audit. Fetches changelogs, summarizes breaking changes with Gemini, and opens one PR per risk group (patch, minor, major). Includes Diagnosis Mode for install conflicts. Use when asked to update dependencies, check for outdated packages, open dependency PRs, scan for package updates, audit for CVEs, or flag breaking changes in upgrades. Trigger when a user says "check for outdated packages", "update my dependencies", "open PRs for dependency updates", "scan for CVEs", or "which packages need upgrading".
docs-from-codeGenerates and updates README.md and API reference docs by reading your codebase's functions, routes, types, schemas, and architecture. Uses graphify to build a knowledge graph first, then writes accurate docs from it. Use when asked to write docs, generate a README, document an API, update stale docs, create an API reference from code, add an architecture section, or document a project in any language. Trigger when a user says their docs are missing, outdated, or wants to document their codebase without writing it manually.