auldsyababua/instructor-workflow/pr-backlog-cleaner

Claude Code and agent skill by auldsyababua/instructor-workflow

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Clean and normalize a large backlog of GitHub pull requests in messy repositories. This skill should be used when facing a repository with numerous stale, conflicted, or outdated PRs that need systematic review, conflict resolution, testing, and disposition (merge, close, or defer). Handles PR triage, automated rebasing, CI verification, risk assessment, and safe merging while maintaining default branch stability.

Install

npx vskill@latest install auldsyababua/instructor-workflow/pr-backlog-cleaner

SKILL.md

PR Backlog Cleaner

Overview

Clean and normalize large backlogs of GitHub pull requests systematically while keeping the default branch stable and deployable. This skill provides a comprehensive workflow for triaging, reviewing, rebasing, testing, and dispositioning PRs at scale, ensuring every PR ends in one of three states: merged safely, closed with reason, or explicitly deferred.

NEW: Integrates pr-comment-analysis subskill to systematically extract, analyze, and prioritize existing PR review feedback. This helps avoid re-litigating issues reviewers already identified, catch hidden impacts through automated analysis, and make informed merge/close/defer decisions based on the complete feedback picture.

When to Use This Skill

Use this skill when:

  • Facing a repository with numerous stale, outdated, or conflicted PRs
  • Need to systematically clean up technical debt in pull request backlogs
  • Want to safely merge or close PRs without destabilizing the default branch
  • Managing a repository where PRs have accumulated without clear disposition
  • Need to establish clear PR hygiene and backlog management practices
  • PRs have existing review feedback that needs to be systematically analyzed and addressed (uses pr-comment-analysis subskill)

Global Safety Constraints

CRITICAL RULES - Never violate these:

  1. No blind merging: Do not modify or merge code without automated verification if any tests or CI are available
  2. No invention: Do not invent repository structure, commands, or tools—infer them only from existing files and configs
  3. Minimal scope: Do not modify unrelated files—restrict edits to files directly involved in the PR or minimally required for functionality
  4. Respect CI: Do not bypass failing CI without explicit instruction from user
  5. Prefer small changes: Prefer smaller, isolated changes over large refactors
  6. Prefer fresh PRs: Prefer creating new clean PRs over attempting to merge extremely outdated or conflicted ones

Core Workflow

Phase 1: Repository Initialization

Discover the environment before taking any action.

1.1 Identify Main Branch
bash
# List all branches
git branch -a
# Identify protected/default branch
gh repo view --json defaultBranchRef

Look for: main, master, or other protected branches

1.2 Identify Language and Tooling

Check for these files to determine tech stack:

  • Node.js: package.json, .nvmrc
  • Python: requirements.txt, pyproject.toml, setup.py, Pipfile
  • Java: pom.xml, build.gradle, build.gradle.kts
  • Go: go.mod, go.sum
  • Rust: Cargo.toml, Cargo.lock
  • Ruby: Gemfile, Gemfile.lock

Check for CI/build configs:

  • .github/workflows/*
  • Jenkinsfile
  • .gitlab-ci.yml
  • azure-pipelines.yml
  • .circleci/config.yml
1.3 Determine Test Commands

Extract test commands from:

  1. README.md or CONTRIBUTING.md - Look for "Running Tests" sections
  2. CI workflows - Parse .github/workflows/*.yml for test steps
  3. Package configs:
  • package.json: scripts.test
  • pyproject.toml: [tool.pytest] or [tool.tox]
  • pom.xml: <build><plugins> for surefire/failsafe
  • Cargo.toml: cargo test is standard

Common test commands by ecosystem:

bash
# Node.js
npm test
npm run test:unit
npm run test:integration
# Python
pytest
python -m pytest
tox
python -m unittest discover
# Java
mvn test
./gradlew test
# Go
go test ./...
# Rust
cargo test
1.4 Verify Tests Run Locally
bash
# Checkout default branch
git checkout <default_branch>
git pull origin <default_branch>
# Run identified test command
<test_command>

Record:

  • ✅ Pass/fail status
  • ⏱️ Approximate runtime
  • 🔍 Any flaky or known failing tests (from CI config or output)

If tests fail on default branch:

  • Document the baseline failure state
  • Future PR tests must not introduce additional failures beyond this baseline
Phase 2: Backlog Inventory

Create a comprehensive inventory of all open PRs.

2.1 Retrieve PR List
bash
# List all open PRs with detailed info
gh pr list --state open --json number,title,author,createdAt,updatedAt,additions,deletions,files,labels,statusCheckRollup --limit 1000 > pr_inventory.json
2.2 Extract PR Metadata

For each PR, document:

  • PR number
  • Title
  • Author (username)
  • Created date (ISO format)
  • Last updated date (ISO format)
  • CI status: SUCCESS, FAILURE, PENDING, or N/A
  • Changed files count
  • Additions/deletions (lines changed)
  • Labels (if present)

See scripts/analyze_pr_backlog.py for automated inventory generation.

2.3 Classify PRs by Type

Based on title, description, and diff, classify as:

  • `bugfix`: Fixes reported bugs or errors
  • `feature`: Adds new functionality
  • `refactor`: Restructures code without changing behavior
  • `infra`: CI, build, tooling, deployment, configs
  • `docs`: Documentation-only changes
  • `mixed`: Contains multiple categories (upgrade risk)
2.4 Assign Risk Levels

Low Risk:

  • Only docs changes
  • Trivial or localized changes without external dependencies
  • Logging-only or comment-only updates

Medium Risk:

  • Localized behavior changes
  • Small features with tests
  • Non-critical infrastructure changes

High Risk:

  • Large refactors (>500 lines or >10 files)
  • Cross-cutting changes affecting multiple modules
  • Database migrations or schema changes
  • Public API changes
  • Changes with no tests in critical areas
  • Mixed PRs combining multiple change types
2.5 Create Structured Inventory

Store in pr_backlog_analysis.md:

markdown
# PR Backlog Analysis
**Repository**: owner/repo
**Analysis Date**: 2025-01-19
**Total Open PRs**: 47
**Default Branch**: main
**Test Status**: ✅ Passing (baseline)
## PR Inventory
| PR# | Title | Author | Age (days) | Type | Risk | CI | Files | +/- |
|-----|-------|--------|------------|------|------|-----|-------|-----|
| 123 | Fix auth timeout | user1 | 45 | bugfix | medium | ✅ | 3 | +25/-10 |
| 124 | Update README | user2 | 120 | docs | low | ✅ | 1 | +15/-5 |
| 125 | Refactor database layer | user3 | 200 | refactor | high | ❌ | 25 | +500/-300 |
## Stale Candidates (>90 days, no recent activity)
-PR #124 (120 days)
-PR #125 (200 days)
Phase 3: Global Policies

Establish consistent rules for all PR processing.

3.1 Stale PR Policy

Stale threshold: 90 days with no commits or comments

For stale PRs:

  • Mark as stale-candidate
  • Review for obsolescence before closing
  • Add comment with clear revival instructions

Stale closure template:

This PR has been inactive for >90 days and the branch is significantly behind the current `main` branch.
To revive this work:
1. Rebase on current main: `git rebase origin/main`
2. Resolve any conflicts
3. Ensure tests pass
4. Open a new PR with updated context
Closing for now to keep the backlog manageable. Thank you for the contribution!
3.2 Merge Strategy

Default: Squash and merge

  • Simplifies history
  • Easier rollbacks
  • Cleaner commit log

Use merge commits only if:

  • Repository convention clearly demands it (check existing merge patterns)
  • PR has carefully crafted commit history worth preserving

Rebase before merge:

  • Always rebase on latest default branch first
  • Resolve conflicts before final merge
3.3 Test Requirement Policy

If automated tests exist:

  • ✅ Tests MUST pass before merging
  • Align with default branch baseline (no new failures)

If tests are broken on default branch:

  • Do not introduce additional failures
  • Consider fixing baseline before merging PRs

If no tests exist:

  • Restrict merging to:
  • Low-risk changes (docs, comments, logging)
  • Clearly localized fixes with verifiable behavior
  • Avoid merging large refactors or cross-cutting changes
Phase 4: Triage Order

Process PRs in this priority order:

Priority 1: Low-hanging fruit

  1. Docs and low-risk infra changes
  2. Small bugfix PRs with clear intent

Priority 2: Value-add features

  1. Small to medium feature PRs (recent, low-to-medium risk)

Priority 3: Complex work

  1. Refactors and high-risk PRs

Priority 4: Problem cases

  1. Very old or heavily conflicted PRs

Within each category, prioritize:

  • ✅ More recent activity over older
  • 📦 Smaller diffs over larger
  • 🟢 Passing CI over failing CI
Phase 5: Per-PR Standard Flow

Execute this workflow for each PR in triage order.

Step A: Relevance Check
bash
# View PR details
gh pr view <PR_NUMBER>
# Check linked issues
gh issue view <ISSUE_NUMBER>

Determine if still relevant:

  • Is the problem/feature still needed?
  • Has this been superseded by newer merged work?
  • Is the approach still aligned with current architecture?

If clearly obsolete:

  • Mark as obsolete
  • Close with factual comment
  • Move to next PR

Template for obsolete closure:

This PR is no longer relevant because [specific reason]:
- [Problem was solved by PR #XYZ]
- [Feature is no longer needed per issue #ABC discussion]
- [Architecture has moved in a different direction]
Closing this PR. Thank you for the contribution!
Step B: Metadata and Precheck

Check CI status:

bash
gh pr checks <PR_NUMBER>

If CI is green (✅):

  • Proceed to Step C (rebase)

If CI is red (❌):

  • Inspect logs to determine if failures are:
  • Unrelated: Already failing on default branch (check baseline)
  • PR-caused: Introduced by this PR
  • If unclear, treat as PR-caused until proven otherwise

View CI logs:

bash
gh run view <RUN_ID> --log-failed
Step C: Local Checkout and Rebase
bash
# Fetch PR branch
gh pr checkout <PR_NUMBER>
# OR manually:
git fetch origin pull/<PR_NUMBER>/head:pr-<PR_NUMBER>
git checkout pr-<PR_NUMBER>
# Rebase onto latest default branch
git fetch origin
git rebase origin/<default_branch>

Resolve conflicts:

Conflict resolution rules:

  1. Follow existing patterns from default branch
  2. Do not introduce new patterns during conflict resolution
  3. Do not modify files outside PR scope unless strictly required
  4. Prefer default branch's version for infrastructure files (CI, build configs)

After resolving conflicts:

bash
# Ensure code compiles (if applicable)
npm run build # or mvn compile, cargo build, etc.
# Run tests for affected modules
<test_command>

Test scope:

  • Full suite for small repos (<5 min runtime)
  • Affected modules only for large repos
  • At minimum, smoke tests for critical paths

Push rebased branch:

bash
# Use force-with-lease to avoid clobbering external changes
git push origin pr-<PR_NUMBER> --force-with-lease
Step D: Structural Review and Comment Analysis

Identify blast radius:

  1. List affected modules/packages

``bash # View changed files gh pr diff <PR_NUMBER> --name-only ``

  1. Detect impact areas:
  • Public APIs (exported functions, REST endpoints)
  • Core domain logic (business rules, algorithms)
  • Database schema (migrations, models)
  • Shared utilities (used by multiple modules)

Detect change type:

  • Mechanical: Renames, formatting, simple refactors (low risk if tests pass)
  • Behavioral: Logic changes, new features (requires test validation)
  • Mixed: Combines mechanical and behavioral (higher risk)

If PR mixes unrelated changes:

  • Example: Formatting + behavior + infra in one PR
  • Mark as mixed
  • Consider splitting into focused follow-up PRs
  • If not feasible, upgrade to high-risk classification

Extract and Analyze PR Comments (NEW - Subskill Integration):

Use the pr-comment-analysis subskill to systematically analyze existing PR feedback:

  1. Extract all PR comments:

```bash # Navigate to repository cd /path/to/repo

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
6
Repository forks
1
7-day trend score
10

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 26 Apr 2026, 7 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/auldsyababua/instructor-workflow/pr-backlog-cleaner/badge)](https://verified-skill.com/skills/auldsyababua/instructor-workflow/pr-backlog-cleaner)

Something wrong with this skill or its page? Tell us.