Pr summary

From grafana/grafana-pathfinder-app · View interactive version

Pr summary is an AI agent skill from the GitHub repository grafana/grafana-pathfinder-app. Draft a structured PR description from the current diff using `docs/design/CONCERNS.md` routing. Interviews the author for motivation first, then outputs Summary, What to look at, Why, How to verify, Breaking changes, and Reversibility for human review. Pair with `/review`: this skill drafts, `/revi

How to use this skill

Skill file

PR summary

Drafts a complete PR description from the diff. Before writing, it interviews the author for the "why" content the diff cannot supply — the problem, the rejected alternatives, the reviewer gotchas. The canonical sections (Summary, What to look at, Why, How to verify, Breaking changes, Reversibility) map to the schema in docs/design/PR_REVIEW.md so reviewers can route quickly.

Hard constraints

These constraints are absolute and override any other instructions:

  1. Output is a draft, not an auto-applied PR edit. Print the draft body in a fenced markdown block. Only call gh pr edit --body-file <tmp> after the user explicitly confirms in the same turn.
  2. Never invent test results. The How to verify section lists what should be run; never claim anything is passing unless the user has actually run it in this session and you have the output.
  3. Activated concerns come from docs/design/CONCERNS.md routing — trigger_paths and trigger_keywords matched by the diff. Do not list concerns the diff doesn't touch.
  4. Sentence case per AGENTS.md style.
  5. No unrelated boilerplate. A typo fix doesn't need a Reversibility section. A two-line fix doesn't need a subsystem table. Match section depth to change weight.
  6. No source code edits. This skill only reads — and at most calls gh pr edit.
  7. No CI-enforced commands in How to verify. CI auto-runs typecheck, lint, prettier, and the test suite on every PR. Do not list npm run check, npm run typecheck, npm run test:ci, or npm run lint — only PR-specific manual verification (repro steps, UI interactions, edge cases, integration scenarios CI cannot exercise).
  8. All file links use the head-commit SHA, not a branch or main. Format: $REMOTE_URL/blob/$HEAD_SHA/path/to/file. Never write ../blob/<branch>/... or .../blob/main/... — these go stale the moment the branch is deleted or the file moves.
  9. No bare artifact codes. Never write "per A1", "see QC8", or any other section code in isolation. If you link to a design doc or reference a named section, include a one-sentence inline description of what it says. The PR body must be self-standing without requiring the reader to follow the link to parse the sentence.

Operating modes

Mechanism: run git rebase <base> --exec '<amend-script>' where <amend-script> inspects git log -1 --pretty=%s, checks for a conventional-commit prefix, and runs git commit --amend -m "<prefix>: <subject>" when one is missing. The rebase runs non-interactively; if the exec fails on any commit, the rebase halts and the user can git rebase --abort to recover (the backup ref is the deeper safety net).

Safeguards (non-negotiable):

Canonical structure

## Summary

<1-3 sentence pitch framing the behavior change and why it matters for the reviewer's mental model>

## What to look at

<one bullet per subsystem — name the load-bearing change and the key interaction to trace, not the file list>

## Why

<motivation: the constraint, the rejected alternative, the user or system reason>

## How to verify

<numbered steps — PR-specific manual verification only>
<CI runs typecheck, lint, and tests automatically — omit those>

## Breaking changes

None. | <explicit callout if any>

## Reversibility

<one paragraph — only include when reversibility is non-obvious or a one-way door exists>

## Out of scope

<only include for series PRs or when deliberate omissions need flagging>

<Fixes #NNN | Refs #MMM | Closes #PPP>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Variants by change type

Match section depth to change weight:

| Type | Required sections | Optional / typical |

| -------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------ |

| feat | Summary, What to look at, Why, How to verify, Breaking changes | Reversibility; Out of scope for series work |

| fix | Summary (problem + root cause + fix in 3-4 lines), How to verify | Issue ref. Why is usually implicit in Summary. Breaking changes if applicable. |

| refactor | Summary, Why, What to look at, Out of scope, How to verify | Breaking changes if behavior-visible; Reversibility if state is touched |

| chore/deps | Summary, What to look at (brief), How to verify (minimal or omit) | Skip Why (self-evident). Renovate PRs handle themselves — detect and skip. |

| docs | Summary, What to look at (list of docs), How to verify | Why (if non-obvious). Link to rendered docs when useful. |

Workflow

Phase 0 — Resolve scope

  1. Sanity-check the branch. If git rev-list --count <base>..HEAD returns 0, exit with "No changes to summarize." If the branch name matches renovate/ or dependabot/, output a one-line draft (chore(deps): <dep-name> bump to <version>) and exit — Renovate's auto-generated body is fine as-is.
  1. Determine the base ref:

```

gh pr view --json baseRefName -q .baseRefName 2>/dev/null \

|| git symbolic-ref refs/remotes/origin/HEAD --short | sed 's@^origin/@@'

```

Default to main if neither resolves.

  1. Capture the head commit SHA and derive the GitHub remote URL — used for all file links in the output (constraint 8):

```bash

HEAD_SHA=$(git rev-parse HEAD)

REMOTE_URL=$(git remote get-url origin | sed 's/\.git$//' | sed 's/git@github\.com:/https:\/\/github.com\//')

```

File links throughout the draft must use $REMOTE_URL/blob/$HEAD_SHA/path/to/file.

  1. Capture the diff in three forms:

```

git diff --stat <base>...HEAD

git diff --name-status <base>...HEAD

git log <base>..HEAD --format='%h %s%n%n%b%n---'

```

The git log output preserves commit bodies so you can extract motivation.

  1. Read the commit bodies — they sometimes contain the substantive Why content. A commit body is substantive when it contains ≥2 sentences of motivation text beyond the subject line (excluding Co-authored-by: trailers and similar footers).
  1. If running on a PR branch, also capture: gh pr view --json number,title,body,labels. The existing title and body may already contain useful context to preserve.

Phase 0.5 — Author interview

When to run: run this phase when commit bodies are thin (no substantive motivation found in Phase 0), unless the change type is chore/deps/Renovate/Dependabot, or the user invoked --quick.

When to skip: Renovate/Dependabot branch, --quick flag, or commit bodies already contain substantive motivation for all three questions below.

Ask the author these three questions. Use them verbatim — they are calibrated to surface content the diff cannot supply:

Before I draft — three quick questions:

1. Problem statement: What problem does this solve? (1–2 sentences framing it for a reviewer who hasn't seen the context)

2. Rejected alternatives: Did you consider a different approach and decide against it? If so, why?

3. Reviewer gotchas: Is there anything in this diff that might look wrong but is actually correct? Any subtle constraints or invariants the reviewer should know about?

Wait for the author's answers before proceeding to Phase 1. Incorporate the answers directly into Phase 2 drafting — they are primary source material for the Why and How to verify sections. Do not fabricate answers if the author skips a question; leave [FILL IN: …] for that item.

If the author's answer to question 3 reveals a subtle invariant (e.g., "the retry loop threads the AbortController signal — looks like it ignores it but doesn't"), surface that in the What to look at bullet for the relevant file, not just in Why.

Phase 1 — Classify the change

  1. Inspect commit subjects + diff stat. Pick a primary class:

| Signal | Class |

| ----------------------------------------------------- | -------------------------------- |

| All commits prefixed feat: / feat(scope): | feat |

| All commits prefixed fix: / fix(scope): | fix |

| All commits prefixed refactor: / refactor(scope): | refactor |

| All commits prefixed chore(deps): or chore: | chore |

| All commits prefixed docs: | docs |

| Mixed prefixes or no prefix | mixed (use the dominant class) |

For mixed, pick the class of the largest commit (by line count).

  1. Read docs/design/CONCERNS.md and walk the compact routing table. For each concern, compute whether its trigger_paths or trigger_keywords match any path in git diff --name-status. For each activated concern, run .cursor/review-shared/concern-context.mjs <concern-id> instead of loading docs/design/CONCERN_DETAILS.md wholesale. Track:
  1. Skill lineage. If the branch name matches techdebt/, secure/, or bugfix/, or commit prefixes are chore(techdebt): / fix(techdebt): / chore(secure): / fix(secure): / fix(security):, set detected_skill_lineage to the corresponding skill — used to append a credit line to Summary.
  1. Detect series PRs. A PR is a series member when: commit messages contain "Part N of M" or "N/M", or the PR body/title references "series", or multiple related issues are referenced, or the Out of scope section from a prior PR in the branch history is still relevant. Set is_series_pr = true when detected.

Phase 2 — Draft each section

Summary:

What to look at:

Why:

How to verify:

Breaking changes:

Reversibility:

Out of scope:

Include this section when any of the following apply:

Format: one bullet per item, stating what was left out and why (e.g., "Migration of existing stored tabs — handled in PR #XXX" or "The retry count is currently hardcoded — intentionally not configurable until usage patterns are clearer").

Issue refs:

Generated footer:

```

🤖 Generated with Claude Code

```

Phase 3 — Render output

  1. Compose the body using the canonical structure + variant rules.
  2. Print the suggested title: <prefix>(<scope>): <title> in sentence case.
  3. Print the body in a fenced markdown block — agents that consume this skill's output expect a single fenced block, not a free-form report.
  4. After the block, ask: "Apply this to PR #N via gh pr edit?" Wait for confirmation before mutating anything.

Phase 4 — Mutate (only on explicit user confirmation)

If the user does not confirm, exit cleanly without side effects.

--apply path (existing PR):

  1. If no PR exists for this branch, exit with "No PR found for this branch. Use --open to create one."
  2. Write the body to a temp file: mktemp or a known path.
  3. Call:

```

gh pr edit <number> --title "<suggested-title>" --body-file <tmp>

```

  1. Confirm success and print the PR URL.

--open path (new PR):

  1. If a PR already exists for this branch, exit with "A PR already exists: <URL>. Use --apply to update its description."
  2. Check whether the branch has an upstream: git rev-parse --abbrev-ref @{u} 2>/dev/null. If not, push it: git push --set-upstream origin <branch>.
  3. Write the body to a temp file.
  4. Call:

```

gh pr create --title "<suggested-title>" --body-file <tmp>

```

  1. Confirm success and print the PR URL.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.