home / skills / phrazzld / claude-config / pr-polish

pr-polish skill

/skills/pr-polish

This skill elevates a working PR from functional to exemplary through hindsight review, refactor suggestions, test audit, docs updates, and quality gate

npx playbooks add skill phrazzld/claude-config --skill pr-polish

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.7 KB
---
name: pr-polish
description: |
  Elevate a working PR: hindsight review, refactor, test audit, docs, quality gates.
  Composes: hindsight-reviewer agent, /refactor, /update-docs, /check-quality, /distill.
  Use when: PR works but could be better. "How would we do this knowing what we know now?"
argument-hint: "[PR-number]"
effort: high
---

# /pr-polish

Holistic quality elevation for a PR that already works.

## Role

Staff engineer doing a retrospective pass. Not finding bugs — asking "would we build it the same way starting over?"

## Objective

Elevate PR `$ARGUMENTS` (or current branch's PR) from "works" to "exemplary": clean architecture, solid tests, current docs.

## Precondition Gate

Before starting, verify:

```bash
gh pr view $PR --json mergeable,statusCheckRollup,reviewDecision
```

Requirements:
- No merge conflicts
- CI green
- No unaddressed critical review feedback

**If any fail**: Tell user to run `/pr-fix` first. Do not proceed.

## Workflow

### 1. Context

Read everything about this PR:

```bash
gh pr view $PR --json body,commits,files
gh pr diff $PR
```

Read linked issue(s). Read commit history. Understand the full arc of what was built and why.

### 2. Hindsight Review

Launch `hindsight-reviewer` agent via Task tool.

Key question: **"Knowing what we know now — the final shape of the code, the edge cases discovered, the patterns that emerged — would you build it the same way?"**

Feed it: full diff against main, PR description, linked issue.

Expect back: architectural observations, naming concerns, abstraction boundaries, missed simplifications.

### 3. Refactor

Invoke `/refactor` for findings that are addressable now:

- Naming improvements
- Shallow module consolidation
- Unnecessary abstraction removal
- Code path simplification

For architectural findings that require broader changes: create GitHub issues.

```bash
gh issue create --title "[Arch] Finding from PR #$PR hindsight review" --body "..."
```

### 4. Test Audit

Review test coverage for the PR's changed files. Look for:

- Missing edge cases
- Error path coverage
- Behavior tests (not implementation tests — per `/testing-philosophy`)
- Boundary conditions
- Integration gaps

Write missing tests. Each test should justify its existence — no coverage-padding.

### 5. Documentation

Invoke `/update-docs` for anything the PR affects:

- ADRs for architectural decisions made during implementation
- README updates for new features or changed behavior
- Architecture diagrams if module boundaries changed
- API docs if endpoints changed

### 6. Quality Gates

Invoke `/check-quality` and run project verification:

```bash
pnpm typecheck && pnpm lint && pnpm test
```

All gates must pass. Fix anything that doesn't.

### 7. Codify (Optional)

If patterns or learnings emerged during this polish pass, invoke `/distill` to capture them as permanent knowledge (hooks, agents, skills, CLAUDE.md entries).

Skip if nothing novel surfaced.

## Agent Teams Mode

For large PRs (>500 line diff), parallelize phases 3-5:

| Teammate | Task |
|----------|------|
| **Refactorer** | `/refactor` on hindsight findings |
| **Test writer** | Test audit + write missing tests |
| **Doc updater** | `/update-docs` |

Lead sequences: hindsight first (all teammates need its output), then parallel work, then quality gates.

## Anti-Patterns

- Polishing a PR that doesn't work yet (use `/pr-fix` first)
- Architectural refactors in a polish pass (create issues instead)
- Adding tests for coverage percentage instead of confidence
- Documenting obvious mechanics instead of non-obvious decisions
- Skipping hindsight and jumping straight to refactoring

## Output

Summary: hindsight findings, refactors applied, issues created, tests added, docs updated, quality gate results, learnings codified.

Overview

This skill elevates a working PR from “works” to “exemplary” by running a retrospective pass: architectural hindsight, targeted refactors, test audits, documentation updates, and quality gates. It treats the PR as a finished artifact and asks, “Knowing what we know now, would we build it this way?” to surface practical improvements.

How this skill works

Start by gating the PR: no merge conflicts, CI green, and no unaddressed critical review feedback. Read the PR body, diff, commits, and linked issues to understand intent and arc. Run a hindsight reviewer agent to produce architecture and naming observations, then apply refactors and tests where safe, update docs, and run project quality checks until everything passes.

When to use it

  • The PR implements desired behavior and passes CI but could be clearer or more maintainable.
  • You want a retrospective pass to capture learnings and reduce future technical debt.
  • Before merging a feature that will shape ongoing architecture or developer ergonomics.
  • When reviewers left non-critical suggestions that deserve a coordinated improvement pass.
  • For medium-to-large PRs where small design wins and tests improve long-term stability.

Best practices

  • Gate first: stop and run /pr-fix if there are merge conflicts, failing CI, or unresolved critical feedback.
  • Run a full context read (PR body, diff, commits, linked issues) before any changes.
  • Use hindsight findings for guidance; convert large architectural work into issues rather than forcing big refactors in the polish pass.
  • Write tests that validate behavior and edge cases, not just to increase coverage numbers.
  • Parallelize refactor/test/docs work for large diffs, but run hindsight review first so everyone aligns.
  • Codify recurring learnings only when they meaningfully reduce future friction.

Example use cases

  • A feature PR that works but has messy naming and a couple of redundant modules.
  • A bugfix PR that added behavior but missed several error-path tests and updated docs.
  • A large feature where patterns emerged and you want to capture them as team guidance.
  • A performance tweak that needs boundary tests and a short refactor to simplify control flow.
  • A PR with green CI but reviewers asked for clearer abstractions and more explicit docs.

FAQ

What if the PR is failing CI or has merge conflicts?

Do not run this polish workflow. Run /pr-fix first to resolve conflicts and CI issues, then re-run the polish steps.

Should I do large architectural refactors in this pass?

No. Create issues for broad architecture changes. Apply small, safe refactors that reduce friction and risk.