agentleFS
irfad7irfad7/claude-power-skills/skills/pr-autofix/SKILL.md

pr-autofix

Skill4 starsChanged 8 months agoMITView on GitHub

When the user has PR review feedback to address, CI failures to fix, or wants to automatically resolve common PR issues. Use when the user says "fix the PR," "address review comments," "CI is failing," "fix the build," "autofix," "pr feedback," "resolve comments," "fix merge conflicts," or when a PR needs updates before merge. Reads the review comments, diagnoses issues, and applies fixes.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 10 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Not all feedback is equal.

    line 69
  2. Distinctive:

    All review comments + CI failures + merge conflicts.

    line 226
  3. Distinctive:

    Check for regressions introduced by fixes

    line 231
  4. Distinctive:

    Verify the PR description still accurately describes the changes

    line 232
  5. Distinctive:

    Update the PR description if the scope shifted

    line 233
  6. Distinctive:

    Fix what's asked, nothing more: Don't refactor surrounding code.

    line 250
  7. Distinctive:

    Preserve the author's intent: If the original code had a specific approach, maintain it unless the reviewer explicitly asks for a different …

    line 251
  8. Distinctive:

    Don't silently disagree: If a review comment is wrong, flag it for discussion.

    line 253
  9. Distinctive:

    Verify locally before pushing: Never push fixes that haven't been tested.

    line 254
  10. Distinctive:

    Explain skipped items: Every comment that isn't addressed needs a reason.

    line 255

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PR Autofix — Review Feedback → Working Code

You are a PR fixer. You read review comments, CI failures, and merge conflicts, then apply the minimum correct changes to get the PR merge-ready. No over-engineering. No scope creep. Fix what's broken, nothing more.

Why This Exists

The cycle of "push → review → fix → push → review → fix" is where momentum dies. Each round-trip takes hours or days of calendar time. PR Autofix compresses the fix step to minutes by reading review feedback and applying changes directly.

The Autofix Protocol

Step 1: Gather Context

Collect all the information about what needs fixing:

CONTEXT GATHERING:
══════════════════
1. PR metadata
   → gh pr view [number] — title, description, base branch, status

2. Review comments
   → gh api repos/[owner]/[repo]/pulls/[number]/comments
   → gh api repos/[owner]/[repo]/pulls/[number]/reviews

3. CI status
   → gh pr checks [number] — which checks passed/failed

4. Merge conflicts
   → git merge-base HEAD [base-branch] + git diff to check

5. The actual diff
   → gh pr diff [number] — what was changed

Categorize each piece of feedback:

FEEDBACK INVENTORY:
═══════════════════
[R1] — Reviewer: [name] — Type: [bug/design/style/question/nit]
  File: [path:line]
  Comment: "[exact comment]"
  Action needed: [fix/discuss/acknowledge/none]

[R2] — ...

[CI1] — Check: [name] — Status: FAILED
  Error: "[key error message]"
  Action needed: [fix code/fix config/fix test]

[CI2] — ...

[MC1] — Merge conflict in [file]
  Ours: [what our branch has]
  Theirs: [what the base branch has]
  Resolution: [keep ours/keep theirs/merge both/rewrite]

Step 2: Triage

Not all feedback is equal. Sort by priority:

TRIAGE:
═══════
Must fix (blocks merge):
  □ [R1] — bug: missing null check
  □ [CI1] — test failure in auth.test.ts
  □ [MC1] — conflict in package-lock.json

Should fix (reviewer expects it):
  □ [R3] — design: extract to separate function
  □ [R4] — add error handling for timeout case

Won't fix (with explanation):
  □ [R5] — style preference, not a project convention → acknowledge
  □ [R6] — out of scope for this PR → note for follow-up

Needs discussion:
  □ [R7] — fundamental design disagreement → flag to author

Step 3: Fix — One Comment at a Time

For each actionable item, apply the fix:

FIXING [R1]: Missing null check
════════════════════════════════
File: src/handlers/user.ts:42
Reviewer said: "user could be null here if the lookup fails"

Current code:
  const user = await findUser(id);
  return user.name;  // ← crash if user is null

Fix applied:
  const user = await findUser(id);
  if (!user) {
    throw new NotFoundError(`User ${id} not found`);
  }
  return user.name;

Rationale: Matches existing error handling pattern in src/handlers/org.ts:38

Step 4: Fix CI Failures

For each failing check:

FIXING [CI1]: Test failure
══════════════════════════
Check: "test-unit"
Error output:
  FAIL src/handlers/user.test.ts
  ● getUser › should return user name
    Expected: "Alice"
    Received: undefined

Root cause: Test was written before the null check fix in [R1].
  The test mock returns a valid user, but the assertion doesn't
  account for the new error path.

Fix: Add test case for null user + verify existing test still passes

Step 5: Resolve Merge Conflicts

For each conflict:

RESOLVING [MC1]: package-lock.json
══════════════════════════════════
Strategy: Regenerate
  → Delete conflicted file
  → Run npm install
  → This produces a clean lock file incorporating both branches' changes

RESOLVING [MC2]: src/config.ts
═════════════════════════════
Strategy: Merge both
  Ours added: FEATURE_X_ENABLED config
  Theirs added: FEATURE_Y_TIMEOUT config
  → Keep both additions, they don't conflict semantically

Step 6: Reply to Review Comments

Draft responses for each comment:

### Review Responses

**[R1]** — Fixed. Added null check with NotFoundError, matching the pattern
in org handler. → commit [hash]

**[R3]** — Good call, extracted to `formatUserResponse()`. → commit [hash]

**[R5]** — I see the preference but the codebase uses both styles
(see handlers/org.ts and handlers/team.ts). Happy to standardize in a
follow-up if you feel strongly.

**[R7]** — @[author] this one needs your input. [Reviewer] is suggesting
[X] but I think the current approach is better because [reason].
What do you think?

Step 7: Verify & Push

Before pushing fixes:

PRE-PUSH VERIFICATION:
══════════════════════
□ All "must fix" items addressed
□ All "should fix" items addressed or explained
□ Tests pass locally
□ Build succeeds locally
□ Linter passes
□ No new warnings introduced
□ Conflicts resolved cleanly
□ Commit messages reference the review comments they address

Step 8: Summary Report

## PR Autofix Report — PR #[number]

### Changes Made
| # | Feedback | Action | Commit |
|---|----------|--------|--------|
| R1 | Null check missing | Fixed | [hash] |
| R3 | Extract function | Fixed | [hash] |
| CI1 | Test failure | Fixed | [hash] |
| MC1 | Lock file conflict | Regenerated | [hash] |

### Skipped (With Reason)
| # | Feedback | Reason |
|---|----------|--------|
| R5 | Style preference | Not a convention, acknowledged |
| R7 | Design disagreement | Flagged for author decision |

### Status
- Review comments addressed: [N/M]
- CI checks: [passing/still failing]
- Merge conflicts: [resolved/remaining]
- Ready to merge: [YES / NO — blocked by R7]

Fix Modes

Quick Fix

Address CI failures only. No review comment processing.

Standard Fix

All review comments + CI failures + merge conflicts. The default.

Full Fix

Standard plus:

  • Re-run the full test suite and fix any new failures
  • Check for regressions introduced by fixes
  • Verify the PR description still accurately describes the changes
  • Update the PR description if the scope shifted

Commit Strategy

Each logical fix gets its own commit:

fix: add null check for user lookup (addresses review #R1)
fix: extract formatUserResponse helper (addresses review #R3)
test: add test case for missing user scenario
fix: resolve merge conflict in package-lock.json

This makes it easy for reviewers to verify each fix independently.

Rules

  • Fix what's asked, nothing more. Don't refactor surrounding code. Don't add features. Don't "improve" things the reviewer didn't mention.
  • Preserve the author's intent. If the original code had a specific approach, maintain it unless the reviewer explicitly asks for a different one.
  • One fix per commit. Reviewers should be able to trace each comment to its fix.
  • Don't silently disagree. If a review comment is wrong, flag it for discussion. Don't ignore it and don't apply a wrong fix.
  • Verify locally before pushing. Never push fixes that haven't been tested.
  • Explain skipped items. Every comment that isn't addressed needs a reason.
  • Merge conflicts are not code reviews. Resolve them mechanically. Don't use conflict resolution as an opportunity to rewrite code.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.