Acompanhamento automático de PR no GitHub (CodeRabbit, CI e merge) no repo atual do Hangar.
Use ao pedir para olhar o CodeRabbit do PR, acompanhar o PR até ficar pronto ou mesclar quando
estiver verde. Não usar para MR do GitLab nem revisão local.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Pr Review Auto?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/jeffer1312-pr-review-auto)
---
name: pr-review-auto
description: |
Acompanhamento automático de PR no GitHub (CodeRabbit, CI e merge) no repo atual do Hangar.
Use ao pedir para olhar o CodeRabbit do PR, acompanhar o PR até ficar pronto ou mesclar quando
estiver verde. Não usar para MR do GitLab nem revisão local.
---
# PR review auto (Hangar, GitHub)
Scope authorized for the named PR only: fix code on the PR branch, commit, push to that branch,
reply to and resolve CodeRabbit threads, and merge when ready (§5). Forbidden: force push, rebase,
`--admin` outside §5, closing PR, pushing to `main`, deleting branch, or running `coderabbit` CLI.
`SKILL_DIR` = this skill's directory; `<repo>` = `gh repo view --json nameWithOwner -q .nameWithOwner`
in PR tree; `<main tree>` = line 1 of `git worktree list`.
## 1. Pick PR and tree
1. Get PR number from request or `gh pr view --json number,headRefName`.
2. Run `gh pr view <N> --json headRefName,author,isCrossRepository,maintainerCanModify,state`.
3. Locate the branch checkout via `git worktree list`:
- Current cwd → work here.
- Another live session's cwd (`hangar-send --list`) → hand over via
`hangar-send <session> "Rode a skill pr-review-auto no PR #<N>."`, tell the user who got it,
and stop.
- Not checked out → ask user where to check it out (never create a worktree or switch `<main tree>` on your own).
- Cross-repo PR with `maintainerCanModify: false` → reply to threads only; report needed fixes.
4. Check `git status`: exclude foreign dirty files from all commits.
5. Read the full PR description, comments and reviews (`gh pr view <N> --json title,body,comments,reviews`
and `gh api --paginate repos/<repo>/pulls/<N>/comments`) before analyzing or fixing anything: what the
author wanted to change, why, what they tested, what they did not test and what they left out. In your
own analysis, a choice the description explains is not a defect by itself. The description states
intent, it does not prove the code right: with contrary evidence it is still a defect, so fix it or
report it to the user with that evidence. CodeRabbit items still follow §3.
## 2. Watch
Arm **Monitor** (`timeout_ms: 1800000`; keep exactly one per PR):
```bash
python3 -u "SKILL_DIR/scripts/pr_watch.py" <N>
```
Polls GitHub every 60 s, prints actionable events only, and persists state in
`~/.cache/hangar-pr-watch/` (`--once` prints snapshot + `ready` for one-off checks, never loops).
Your own notes never wake the watch — including notes the user wrote by hand under the same GitHub
account. Re-arm the same command silently (no `--reset`) on `{"control":"window_ended"}` or Monitor
expiry; on `{"control":"expired"}` (24 h), inform user and stop. After arming, **end the turn** (no
sleeps, crons, or periodic updates).
## 3. Handle events
| Event | Action |
|---|---|
| `change` | Process new items below in order, then end turn. |
| `ready` | Go to §5. |
| `closed` | Report merged/closed PR, stop. |
| `query_failed` | Warn once (script retries). |
| `query_recovered` | Run `--once` and continue. |
| `crashed` | Report `error`, stop. |
| `state_reset` | Replay follows — skip items already done in log. |
Order inside `change` (full snapshot):
1. **`threads`** (`last_by` ≠ you): read full thread (`gh api repos/<repo>/pulls/<N>/comments` or
`url`) against current code. Fix every valid point (small ones included). Reject only factually
wrong or out-of-scope points with **one** reply (`@coderabbitai` + evidence), then resolve
(unresolved threads block `ready`).
2. **`replies_in_resolved_threads`**: ignore agreements; handle new objections like open threads.
3. **`reviews_on_head` (`nitpicks: true`)**: read `gh api repos/<repo>/pulls/<N>/reviews/<id>` and
handle each nitpick identically; if any nitpick was skipped, post one top-level `@coderabbitai`
comment listing which and why.
4. **`bot_comments`** replying to you: ignore agreements; analyze new technical objections.
5. **`coderabbit: "NEUTRAL"`** (concluded without reviewing this head, usually rate-limited): run
`code-review` skill once (`high <N>`; without it, run stack reviewer on `gh pr diff <N>`), fix
valid findings (§4), log rest, then run
`python3 SKILL_DIR/scripts/pr_watch.py <N> --mark-local-review <last-pushed-head>`. For a
subsequent head that only adds those fixes, mark it with `--mark-local-review <head>` without
re-reviewing (`ready` requires `SUCCESS` on the head, or `NEUTRAL` marked for that head).
6. **`failed` checks**: `gh run view <run> --log-failed`. Caused by PR → fix. Known flaky/infra →
`gh run rerun <run> --failed` once (fails again → report and stop). Unrelated non-flaky → report
and stop (do not merge).
7. **`mergeable: CONFLICTING`**: `git merge origin/main` (never rebase), resolve, commit.
Maintain `~/.cache/hangar-pr-watch/<owner>_<name>_<N>.log.md` (thread/review id, decision, fix
commit, reply); read after compaction so you never reply twice to the same item.
## 4. Publish a round
1. Stage round files by explicit path; commit with descriptive English message (`fix(scope): …`),
never the branch name.
2. Push to PR branch. When the review hook blocks the first push, run stack reviewer once on the
round diff, apply valid fixes, and push again (fixes from reviewer need no second review). Skip
`scripts/verificar-local` (PR CI is the gate).
3. Reply once per fixed thread and resolve:
```bash
gh api repos/<repo>/pulls/<N>/comments/<root_comment_id>/replies \
-f body="@coderabbitai Corrigido em <sha>. <what changed>."
gh api graphql -f query='mutation($t:ID!){resolveReviewThread(input:{threadId:$t}){thread{isResolved}}}' -F t=<thread_id>
```
## 5. Ready → merge
The script computes `ready` (open, non-draft, mergeable, CodeRabbit `SUCCESS` on the head or
`NEUTRAL` marked for that head, zero unresolved threads, every check terminal with none failed,
unchanged 90 s), except it does not track nitpicks.
1. Confirm every nitpick in your log is handled, and verify
`python3 SKILL_DIR/scripts/pr_watch.py <N> --once` returns `ready: true` on the same `head`
(else keep watching).
2. Check `viewer_permission`: if not `ADMIN` (`main` requires 1 approval with no other reviewer),
do not merge — stop Monitor, tell user the PR is ready for admin approval/merge, and stop.
3. If `ADMIN`: `gh pr merge <N> --merge --admin --match-head-commit <head>` (merge commit, keeps
branch; fails if new commit arrived).
4. Stop Monitor via **TaskStop**.
5. Move the board cards of the issues the PR closed to the done column:
`python3 SKILL_DIR/scripts/board_done.py <N>` (failure → report it; never say the card moved).
6. In `<main tree>` (if on `main` and clean): `git fetch origin && git merge --ff-only origin/main`
(if dirty or non-FF, just report it).
7. Report: PR, merge commit, fixed vs answered summary, board lines, and `gh run list --branch main -L 1`.
User says stop → **TaskStop**, do not resume.