Diagnoses PR issues, resolves conflicts, runs pre-commit hooks, and manages final PR merging.
Install
mkdir -p .claude/skills/pr-fix && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/9529" && unzip -o skill.zip -d .claude/skills/pr-fix && rm skill.zipInstalls to .claude/skills/pr-fix
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Triage, fix, and pre-flight a PR before merge. Checks mergeability, CI, reviews, and bot comments — fixes issues, runs /pre-commit before pushing, then hands off to /pr-merge.Key capabilities
- →Triage PR issues
- →Fix CI failures
- →Resolve merge conflicts
- →Pre-flight validation
How it works
It diagnoses PR issues, fixes them, enforces pre-commit validation, and hands off to the merge orchestrator.
Inputs & outputs
When to use pr-fix
- →Fixing CI failures on PRs
- →Resolving merge conflicts
- →Validating PR merge readiness
- →Automating pre-commit validation
About this skill
PR Fix Skill
Purpose
Full triage, fix, and pre-flight for a PR. Diagnoses all issues (merge conflicts, CI failures, bot comments, review requests), fixes them, enforces /pre-commit before pushing, then hands off to /pr-merge for the actual merge and post-merge workflow.
Usage
/pr-fix <pr-number>
Relationship with other skills:
/pr-fix= triage problems + fix them + pre-flight validation (you stay on the PR branch)/pr-merge= validate readiness + execute merge + post-merge workflow (docs, milestone, release)- Use
/pr-fixfirst when you know there are issues. Use/pr-mergewhen you expect the PR is ready.
Phase 1: Full Triage
Checkout the PR branch first:
gh pr checkout <pr-number>
Then run ALL four sources in parallel:
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
PR=<pr-number>
# 1. PR metadata — mergeability, draft state, review decision
gh pr view $PR --json mergeable,isDraft,state,reviewDecision,additions,deletions
# 2. CI check status
gh pr checks $PR --repo $REPO
# 3. Bot inline comments (Codex, Gemini, etc.)
gh api repos/$REPO/pulls/$PR/comments \
--jq '.[] | "[\(.path):\(.line // .original_line // "?")]\n\(.body)\n---"'
# 4. Top-level reviews (approval/request-changes state)
gh pr view $PR --repo $REPO --json reviews \
--jq '.reviews[] | "\(.author.login) [\(.state)]: \(.body)"'
# 5. Forgejo CI status (if dual-remote)
SHA=$(gh pr view $PR --json headRefOid --jq '.headRefOid')
fi
If bot reviews are still pending, poll until complete (max 3 attempts, 30s apart):
for i in 1 2 3; do
STATE=$(gh pr checks $PR --repo $REPO 2>&1)
echo "$STATE"
echo "$STATE" | grep -q "pending" && sleep 30 || break
done
Phase 2: Triage Decision
Hard Stops — Report and Exit
| Condition | Action |
|---|---|
mergeable: CONFLICTING | "Merge conflicts detected. Resolve first: gh api -X PUT repos/O/R/pulls/N/update-branch or rebase locally, then re-run /pr-fix." |
isDraft: true | "PR is a draft. Mark as ready for review first." |
state != OPEN | "PR is not open (state: X). Nothing to fix." |
Soft Issues — Proceed to Fix Loop
| Condition | Route |
|---|---|
| CI failing | → Phase 3 fix loop |
| Bot comments (P1/P2) | → Phase 3 fix loop |
CHANGES_REQUESTED | → Phase 3 fix loop (address review comments) |
REVIEW_REQUIRED (zero reviews) | Note it — addressed at Phase 6 handoff |
| All passing, no issues | Skip Phase 3 → go directly to Phase 4 pre-flight |
Phase 3: Fix Loop
Fix one category at a time. Verify locally after each fix before moving to the next.
Common Fix Patterns
Build/Dependency Issues:
rm -rf node_modules package-lock.json || rm -rf __pycache__ .pytest_cache
npm ci || pip install -r requirements.txt
npm run build || python -m build
Test Failures:
npm run test -- --verbose || pytest -v --tb=short -m "not integration and not e2e"
npm run test:integration || pytest tests/integration/ # CI runs full suite; run locally only if diagnosing integration failures
Code Quality Issues:
npm run lint -- --fix || ruff format . && ruff check --fix .
npm run format || prettier --write .
npm run typecheck || mypy .
Security Issues:
npm audit fix || safety check && pip-audit --fix
npx audit-ci --moderate || bandit -r src/
Implementation by Failure Type
Test Failures:
- Unit tests: Fix broken logic, update mocks, handle edge cases
- Integration tests: Update API contracts, fix database setup
- Security tests: Address input validation, auth issues
Quality Issues:
- TypeScript: Fix type errors, add missing types
- Linting: Address code style violations
- Documentation: Update JSDoc, README, API docs
Bot Review Comments (Codex P1/P2, Gemini):
- Address each inline comment with its file:line reference
- Prioritize P1 (blocking) before P2 (advisory)
Human Review (CHANGES_REQUESTED):
- Address all requested changes before proceeding
- Reply to review comments after fixing
Quick Reference by Stack
JavaScript/TypeScript:
npm audit fix && npm run build
npm run test -- --updateSnapshot
npm run test:coverage -- --coverageThreshold='{"global":{"branches":80}}'
npx eslint . --fix && npx prettier --write .
npx tsc --noEmit
Python:
pip install -r requirements.txt && safety check
pytest -m "not integration and not e2e" # coverage threshold enforced on CI, not locally
ruff format . && ruff check --fix . && mypy src/
Docker/Infrastructure:
docker build -t test-image .
terraform validate && terraform plan
Phase 4: Pre-flight Before Push (MANDATORY)
Always run /pre-commit before pushing any fix to the PR. This enforces the same checks CI will run — catching failures locally before they hit the pipeline and breaking the push→CI-fail→fix→repeat cycle.
/pre-commit
Runs: quality check → tests → coverage → security scan → changelog → companion gate.
For large diffs (additions + deletions > 200 lines), also run first:
/review changes --quick
External AI second opinion on the code changes. Address any BLOCK-level findings before pushing. --quick skips the deeper audits (silent-failures, types, comments) for speed.
Do not proceed to Phase 5 until /pre-commit passes.
Phase 5: Push + Monitor
git add .
git commit -m "fix(pr): resolve PR #<pr-number> issues
- Fixed: [specific issue description]
- Tests: [test fixes applied if any]
- Security: [security issues resolved if any]"
git push
# Monitor GitHub CI
gh pr checks <pr-number> --watch
# Monitor Forgejo CI (dual-remote projects)
SHA=$(git rev-parse HEAD)
TOKEN=$(cat ~/.config/forgejo/token)
sleep 60
for i in 1 2 3; do
RESULT=$(curl -s \
-H "Authorization: token $TOKEN")
STATE=$(echo "$RESULT" | python3 -c "import json,sys; print(json.load(sys.stdin)['state'])" 2>/dev/null)
echo "Forgejo CI: $STATE (attempt $i)"
[ "$STATE" = "pending" ] && sleep 30 || break
done
echo "$RESULT" | python3 -c "
import json,sys; d=json.load(sys.stdin)
print(f'Forgejo CI: {d[\"state\"]} ({d[\"total_count\"]} checks)')
for s in (d.get('statuses') or []):
print(f' {s[\"context\"]}: {s[\"status\"]}')
"
# If Forgejo CI failed, loop back to Phase 3
[ "$STATE" = "failure" ] && echo "FORGEJO CI FAILED — return to Phase 3 fix loop"
fi
# Re-check bot reviews after pushing fixes
gh api repos/$REPO/pulls/<pr-number>/comments \
--jq '.[] | "[\(.path):\(.line // .original_line // "?")]\n\(.body)\n---"'
Phase 6: Handoff
If REVIEW_REQUIRED (no human reviews on this PR):
PR has no reviews yet. Consider getting a second opinion before requesting merge:
/review pr <N> — external AI review (MERGE/BLOCK verdict, ~5 min)
Then run the merge orchestrator:
/pr-merge <N>
If all checks passing and reviews satisfied:
All issues resolved. Run the merge orchestrator:
/pr-merge <N>
/pr-merge owns the merge decision, branch cleanup, milestone check, and release readiness. Do not auto-merge here.
Tips
- Fix one category at a time (CI, then lint, then security)
- Verify fixes locally before running pre-flight
/pre-commitis mandatory — it prevents the push→CI-fail→fix→repeat cycle- Use
gh pr checks --watchto monitor CI progress after push
When not to use it
- →When the PR is already ready for merge
- →When the user wants to bypass pre-flight checks
Prerequisites
Limitations
- →Requires GitHub CLI
- →Requires PR context
How it compares
It automates the entire PR triage and fix lifecycle, ensuring readiness before the final merge.
Compared to similar skills
pr-fix side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| pr-fix (this skill) | 0 | 2mo | Review | Advanced |
| fix-pr | 1 | 4mo | Review | Intermediate |
| resolve-checks | 1 | 6mo | Review | Intermediate |
| agent-github-pr-manager | 1 | 6mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by matteocervelli
View all by matteocervelli →You might also like
fix-pr
AztecProtocol
Fix a failing PR by analyzing CI logs and fixing errors. Autonomous workflow that identifies failures, rebases, fixes issues, and pushes.
resolve-checks
flowglad
Resolve all failing CI checks and address PR review feedback on the current branch's PR. Runs tests locally, fixes failures, incorporates valid review comments, and resolves addressed feedback. Use when CI is red, after receiving PR feedback, or before merging.
agent-github-pr-manager
ruvnet
Agent skill for github-pr-manager - invoke with $agent-github-pr-manager
agent-github-modes
ruvnet
Agent skill for github-modes - invoke with $agent-github-modes
agent-pr-manager
ruvnet
Agent skill for pr-manager - invoke with $agent-pr-manager
git-pr-workflows-git-workflow
sickn33
Orchestrate a comprehensive git workflow from code review through PR creation, leveraging specialized agents for quality assurance, testing, and deployment readiness. This workflow implements modern g