github-pr-fixer
GitHub PR Fixer
You are a PR fixer. Given a PR number, read review feedback from GitHub, implement fixes, run tests, commit/push, reply to reviewers, and resolve threads. Runs once per invocation.
Prerequisites
Requires the gh-pr-review extension for thread management:
gh extension install agynio/gh-pr-review
Verify: gh pr-review --help
If the extension is not installed, install it automatically before proceeding.
Input
The user provides a PR number: PR#11, #11, or just 11.
On startup, extract the PR number and begin Phase 0.
Phase 0 — State Detection
Determine whether there is new work to do before proceeding:
# Repo info
REPO=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
# PR details
gh pr view <PR> --json number,title,state,headRefName,baseRefName,author
# Ensure we're on the PR branch
gh pr checkout <PR>
# Check for unresolved review threads
gh pr-review threads list --pr <PR> --repo {owner}/{repo}
# PR-level discussion comments (check for new feedback or previous completion markers)
gh api --paginate repos/{owner}/{repo}/issues/<PR>/comments --jq '.[] | {body, user: .user.login, created_at}'
# Existing review comments (inline)
gh api repos/{owner}/{repo}/pulls/<PR>/comments --jq '.[] | {id,path,line,body,user: .user.login,pull_request_review_id}'
Analyze the results and decide how to proceed:
-
Check for unresolved threads:
- Unresolved threads found → there is new feedback to address → proceed to Phase 1
- No unresolved threads → proceed to step 2
-
Check for new reviewer feedback since your last run:
- Scan PR discussion comments for review feedback (REQUEST_CHANGES or critical comments) posted AFTER the timestamps of your previous replies
- New feedback found → proceed to Phase 1 to address it
- No new feedback → proceed to step 3
-
Verify whether all work is already complete:
- Confirm all previous review threads are resolved
- Confirm all review comments have been replied to
- Confirm the code has been pushed (
git statusshows clean,git logshows your commits) - If ALL checks pass → this is a duplicate invocation. Output this message and stop:
✅ All review feedback has already been addressed. All threads resolved, replies posted, and changes pushed. No further action needed. - If any check fails → something is incomplete → proceed to Phase 1 to finish the remaining work
Phase 1 — Analyze Feedback
For each unresolved comment or thread:
- Read the referenced file — use the Read tool on
{path}around{line} - Validate the comment:
- Is it accurate and still applicable to the current code?
- Has the code already been changed since the comment was made? (check
isOutdated)
- Categorize:
- Fix — Valid, implement the change
- Explain — Invalid or outdated, reply with reasoning (do NOT change code)
- Prioritize:
- High: security, bugs, breaking changes
- Medium: code quality, maintainability, tests
- Low: style, documentation, nice-to-haves
Rules:
- Do NOT skip a fix because it's time-consuming — either fix it or explain why not
- If a reviewer provided a
suggestionblock, prefer applying it (but verify correctness first) - If a comment is outdated (code already changed), resolve the thread without fixing
Phase 2 — Implement Fixes
Edit files using the Edit tool. Follow these principles:
- Match existing code patterns in the repo (naming, imports, file organization)
- Follow
AGENTS.mdorCLAUDE.mdguidelines if they exist - Add/update tests for any new logic
- One logical change per fix — don't mix unrelated changes
After all fixes are applied, proceed to Phase 3 to verify before committing.
Phase 3 — Verify Changes
Run checks in order. Auto-detect available commands from package.json, Makefile,
pyproject.toml, or CI workflow files.
# 1. Lint
npm run lint # or: ruff check . | golangci-lint run | eslint
# 2. Type-check
npx tsc --noEmit # or: mypy . | pyright
# 3. Tests (prefer relevant to changed files)
npm test # or: pytest | bun run test:unit
If any check fails: Fix the failures before proceeding. Do NOT push broken code.
If no checks are available: Skip verification and note it in the reply.
Phase 4 — Commit and Push
# Check what changed
git status
# Stage only files that were part of the fixes (not unrelated changes)
git add <file1> <file2>
# Commit with a clear message listing all changes
git commit -m "fix: address PR review feedback
- <summary of change 1>
- <summary of change 2>
- ..."
# Push to remote
git push
Verify clean state: git status should show clean working tree.
Phase 5 — Reply to Review Threads
Reply to ALL open threads before resolving any.
For review threads:
gh pr-review comments reply \
--pr <PR> \
--repo {owner}/{repo} \
--thread-id <THREAD_ID> \
--body "$(cat <<'EOF'
@reviewer Thanks for the feedback!
<Explain what was changed and why. If not fixed, explain why not.>
Changes committed in <short SHA>, all checks pass.
EOF
)"
For regular PR comments (not in a thread):
gh pr comment <PR> --body "$(cat <<'EOF'
@reviewer <response>
EOF
)"
Reply rules:
- Always start with
@reviewer_username— look up the actual username from the comment - There may be multiple reviewers — address each comment's actual author
- For fixes: explain what changed, reference the commit
- For non-fixes: explain why the suggestion was not applied (with reasoning)
- Be concise but clear
Phase 6 — Resolve Threads and Finish
After replying to all threads, resolve them:
# Resolve outdated threads first (code changed, comment no longer applies)
gh pr-review threads resolve --pr <PR> --repo {owner}/{repo} --thread-id <OUTDATED_THREAD_ID>
# Then resolve active threads that you've replied to
gh pr-review threads resolve --pr <PR> --repo {owner}/{repo} --thread-id <ACTIVE_THREAD_ID>
Output ✅ Review feedback addressed and stop.
This skill runs once per invocation. If the reviewer submits new feedback, the user should invoke the skill again.
More from satone7/skills
writing-plans-plus
Enhanced planning with structured, machine-readable task format based on writing-plans. Use this skill whenever you need to create implementation plans with explicit completion tracking, cross-validation issue tracking, or machine-readable JSON output. Always use this when planning software development tasks, especially when tasks need to be executed by other agents or reviewed later.
10find-next-task
Find the next executable task from writing-plans-plus JSON plan files. Use this skill whenever you need to locate the next task to work on, check task status, or understand what to do next in a project with structured plans. Always use this when the user asks "what's next", "find the next task", "show pending tasks", or wants to continue working on a plan.
5aitc-workflow
>
5guardian
|
4find-task-skills
>
4executing-single-task
执行 writing-plans-plus 计划中的“恰好一个任务”:输入为 find-next-task 的完整输出 JSON。严格按四阶段流程(实现→规范审查→质量审查→最终验证),基于证据更新 plan JSON 的 passes(成功时删除 issue 字段;失败时写入/更新非空 issue[]),并创建且仅创建一个 git commit。凡用户要求“执行下一个任务/只跑一个任务/把 passes 写回/自动执行单任务”都应优先使用本技能。
4