Babysitting a PR
Use this skill when the user has an open pull request and wants the agent to monitor it, fix CI failures, resolve review comments, and keep it merge-ready.
Steps
Get the PR status — fetch the current state of the PR:
gh pr view --json number,title,state,mergeable,reviewDecision,statusCheckRollup,comments,reviews
Also check for merge conflicts:
gh pr view --json mergeStateStatus
Check CI status — look at the statusCheckRollup field. For each failing check:
gh pr checks
This lists all CI checks and their status (pass/fail/pending).
Fix CI failures — for each failing check, get the logs:
gh run view <run-id> --log-failed
Analyze the failure and fix it:
- Lint failures: run the linter locally (
npm run lint -- --fix), fix remaining issues manually, commit.
- Type errors: run
npx tsc --noEmit, read the errors, fix the types, commit.
- Test failures: run the failing test suite locally, read the assertion errors, fix the code or update the test expectations, commit.
- Build failures: run
npm run build, read the error output, fix imports/configs/missing deps, commit.
After fixing, push the changes:
git add -A && git commit -m "fix: resolve CI failures" && git push
Handle review comments — fetch PR review comments:
gh api repos/{owner}/{repo}/pulls/{pr}/comments
For each unresolved comment:
- Read the comment and the code it references.
- If the fix is clear (typo, naming, missing null check, style issue), apply it.
- If the comment requires a design decision or clarification, skip it and report to the user.
Commit fixes for resolved comments:
git add -A && git commit -m "fix: address review feedback" && git push
Resolve merge conflicts — if the PR has conflicts:
git fetch origin main
git merge origin/main
Resolve conflicts by reading both sides and choosing the correct resolution. For ambiguous conflicts, ask the user. After resolving:
git add -A && git commit -m "fix: resolve merge conflicts" && git push
Re-check status — after pushing fixes, wait for CI to run and check again:
gh pr checks --watch
If new failures appear, go back to step 3. Limit to 3 rounds to avoid infinite loops.
Report — summarize what was done:
- Which CI checks were failing and how they were fixed
- Which review comments were addressed
- Whether merge conflicts were resolved
- Current PR status (ready to merge, or what's still blocking)
Loop Behavior
This skill is designed to run in a loop:
Check PR → Find issues → Fix issues → Push → Re-check → Repeat
Stop when:
- All checks pass, no unresolved comments, no conflicts → PR is merge-ready
- 3 fix-push-check cycles have been attempted without full resolution → report what's still failing
- A fix requires a design decision → ask the user
Notes
- Never force-push to a shared PR branch.
- Don't modify test assertions to make tests pass unless the behavior change was intentional.
- Don't resolve review comments you're unsure about — skip them and let the user know.
- If CI is queued/pending, wait for it to complete before analyzing failures.
- Use
gh pr ready to mark the PR as ready for review once everything is green.
1---2name: babysitting-pr3description: Monitor a pull request for CI failures, review comments, and merge conflicts — then fix them automatically. Use when a PR is open and you want the agent to keep it merge-ready.4---5
6# Babysitting a PR
7
8Use this skill when the user has an open pull request and wants the agent to monitor it, fix CI failures, resolve review comments, and keep it merge-ready.
9
10## Steps
11
121. **Get the PR status** — fetch the current state of the PR:
13
14 ```bash
15 gh pr view --json number,title,state,mergeable,reviewDecision,statusCheckRollup,comments,reviews
16 ```
17
18 Also check for merge conflicts:
19
20 ```bash
21 gh pr view --json mergeStateStatus
22 ```
23
242. **Check CI status** — look at the `statusCheckRollup` field. For each failing check:
25
26 ```bash
27 gh pr checks
28 ```
29
30 This lists all CI checks and their status (pass/fail/pending).
31
323. **Fix CI failures** — for each failing check, get the logs:
33
34 ```bash
35 gh run view <run-id> --log-failed
36 ```
37
38 Analyze the failure and fix it:
39
40 - **Lint failures**: run the linter locally (`npm run lint -- --fix`), fix remaining issues manually, commit.
41 - **Type errors**: run `npx tsc --noEmit`, read the errors, fix the types, commit.
42 - **Test failures**: run the failing test suite locally, read the assertion errors, fix the code or update the test expectations, commit.
43 - **Build failures**: run `npm run build`, read the error output, fix imports/configs/missing deps, commit.
44
45 After fixing, push the changes:
46
47 ```bash
48 git add -A && git commit -m "fix: resolve CI failures" && git push
49 ```
50
514. **Handle review comments** — fetch PR review comments:
52
53 ```bash
54 gh api repos/{owner}/{repo}/pulls/{pr}/comments
55 ```
56
57 For each unresolved comment:
58 - Read the comment and the code it references.
59 - If the fix is clear (typo, naming, missing null check, style issue), apply it.
60 - If the comment requires a design decision or clarification, skip it and report to the user.
61
62 Commit fixes for resolved comments:
63
64 ```bash
65 git add -A && git commit -m "fix: address review feedback" && git push
66 ```
67
685. **Resolve merge conflicts** — if the PR has conflicts:
69
70 ```bash
71 git fetch origin main
72 git merge origin/main
73 ```
74
75 Resolve conflicts by reading both sides and choosing the correct resolution. For ambiguous conflicts, ask the user. After resolving:
76
77 ```bash
78 git add -A && git commit -m "fix: resolve merge conflicts" && git push
79 ```
80
816. **Re-check status** — after pushing fixes, wait for CI to run and check again:
82
83 ```bash
84 gh pr checks --watch
85 ```
86
87 If new failures appear, go back to step 3. Limit to 3 rounds to avoid infinite loops.
88
897. **Report** — summarize what was done:
90 - Which CI checks were failing and how they were fixed
91 - Which review comments were addressed
92 - Whether merge conflicts were resolved
93 - Current PR status (ready to merge, or what's still blocking)
94
95## Loop Behavior
96
97This skill is designed to run in a loop:
98
99```
100Check PR → Find issues → Fix issues → Push → Re-check → Repeat
101```
102
103Stop when:
104- All checks pass, no unresolved comments, no conflicts → PR is merge-ready
105- 3 fix-push-check cycles have been attempted without full resolution → report what's still failing
106- A fix requires a design decision → ask the user
107
108## Notes
109
110- Never force-push to a shared PR branch.
111- Don't modify test assertions to make tests pass unless the behavior change was intentional.
112- Don't resolve review comments you're unsure about — skip them and let the user know.
113- If CI is queued/pending, wait for it to complete before analyzing failures.
114- Use `gh pr ready` to mark the PR as ready for review once everything is green.