Skip to content

Commit abc2e08

Browse files
claudeduyetbot
andcommitted
feat(github): add babysit-pr command with AI review bot integration
Add /github:babysit-pr slash command that monitors PRs, reads all review comments (CodeRabbit, Sourcery, Gemini, and human reviewers), fixes suggestions, resolves merge conflicts, and auto-merges when ready. Includes effort reporting and /loop integration for continuous monitoring. - Add babysit-pr command, example script, and review-bots skill - Fix watch-and-fix.sh stub for fix skill integration - Bump github plugin version to 1.4.0 Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>
1 parent b4c636c commit abc2e08

8 files changed

Lines changed: 803 additions & 13 deletions

File tree

github/.claude-plugin/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "github",
3-
"version": "1.3.0",
4-
"description": "GitHub operations using gh CLI - PRs, workflows, issues, repositories, batch operations, and smart branch detection for implementation workflows",
3+
"version": "1.4.0",
4+
"description": "GitHub operations using gh CLI - PRs, workflows, issues, repositories, batch operations, PR babysitting with AI review bot integration, and smart branch detection",
55
"author": "duyetbot",
66
"license": "MIT"
77
}

github/README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ GitHub operations using gh CLI - PRs, issues, workflows, repositories, batch ope
44

55
## Version
66

7-
1.3.0
7+
1.4.0
88

99
## Components
1010

1111
### Skills
12-
- **github** - Comprehensive GitHub operations knowledge
12+
- **github** - GitHub operations knowledge
13+
- **review-bots** - AI code review bot parsing (CodeRabbit, Sourcery, Gemini)
1314

1415
### Commands
1516
- `/github:bulk-close-issues` - Close multiple issues by label or search query
1617
- `/github:bulk-merge-prs` - Merge multiple approved PRs
1718
- `/github:bulk-label` - Apply labels to multiple issues/PRs
1819
- `/github:watch-and-fix` - Watch PR, fix issues from AI reviews, and auto-merge when ready
20+
- `/github:babysit-pr` - Babysit a PR: monitor, fix review bot suggestions (CodeRabbit, Sourcery, Gemini), resolve conflicts, and merge
1921

2022
## Features
2123

@@ -80,6 +82,21 @@ gh pr create --title "feat: add new feature" --body "Implements #123"
8082
/github:watch-and-fix --dry-run
8183
```
8284

85+
### Babysit PR
86+
```bash
87+
# Babysit current branch's PR — reads all review comments and fixes them
88+
/github:babysit-pr --auto-merge
89+
90+
# Babysit specific PR with limited iterations
91+
/github:babysit-pr --pr 123 --max-iterations 5
92+
93+
# Use with /loop for continuous monitoring every 10 minutes
94+
/loop 10m /github:babysit-pr --auto-merge
95+
96+
# Preview mode
97+
/github:babysit-pr --dry-run
98+
```
99+
83100
## Real-World Workflows
84101

85102
### Automated PR Triage
@@ -160,6 +177,7 @@ gh pr list --limit 100 --json number,title --jq '.[]'
160177
## Examples
161178

162179
See the `examples/` directory for complete automation scripts:
180+
- `babysit-pr.sh` - Babysit PR with review bot integration and effort reporting
163181
- `bulk-close-issues.sh` - Close issues by label with confirmation
164182
- `bulk-merge-prs.sh` - Merge approved PRs with passing CI
165183
- `pr-automation.sh` - Auto-label, auto-assign, and welcome contributors
@@ -170,15 +188,18 @@ See the `examples/` directory for complete automation scripts:
170188
```
171189
github/
172190
├── .claude-plugin/
173-
│ └── plugin.json # Manifest (version 1.3.0)
191+
│ └── plugin.json # Manifest (version 1.4.0)
174192
├── commands/ # Slash commands
193+
│ ├── babysit-pr.md
175194
│ ├── bulk-close-issues.md
176195
│ ├── bulk-merge-prs.md
177196
│ ├── bulk-label.md
178197
│ └── watch-and-fix.md
179198
├── skills/ # Reusable knowledge
180-
│ └── github.md
199+
│ ├── github.md
200+
│ └── review-bots.md
181201
└── examples/ # Example scripts
202+
├── babysit-pr.sh
182203
├── bulk-close-issues.sh
183204
├── bulk-merge-prs.sh
184205
├── pr-automation.sh
@@ -192,7 +213,7 @@ Follow semantic versioning (semver):
192213
| Change Type | Version Bump | Example |
193214
|-------------|--------------|---------|
194215
| Bug fix, docs | Patch | 1.2.0 → 1.2.1 |
195-
| New feature, minor change | Minor | 1.2.0 → 1.3.0 |
216+
| New feature, minor change | Minor | 1.2.0 → 1.4.0 |
196217
| Breaking change | Major | 1.2.0 → 2.0.0 |
197218

198219
**When to bump:**

github/commands/babysit-pr.md

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
---
2+
allowed-tools: Bash(git *), Bash(gh *), Read, Edit, Write, Glob, Grep, Agent
3+
description: Babysit a PR - monitor, fix review bot suggestions, resolve conflicts, and merge when ready
4+
---
5+
6+
# Babysit PR
7+
8+
Continuously monitor a pull request, read AI review bot comments (CodeRabbit, Sourcery, Gemini), fix suggested issues, resolve merge conflicts, and merge when ready. Reports total effort at completion.
9+
10+
## Usage
11+
12+
```bash
13+
/github:babysit-pr
14+
/github:babysit-pr --pr 123
15+
/github:babysit-pr --auto-merge
16+
/github:babysit-pr --max-iterations 10
17+
/github:babysit-pr --dry-run
18+
```
19+
20+
## Options
21+
22+
- `--pr <number>`: Specific PR number (default: current branch's PR)
23+
- `--auto-merge`: Merge PR when CI passes and all review comments are resolved
24+
- `--max-iterations <n>`: Maximum fix iterations (default: 10)
25+
- `--dry-run`: Preview what would happen without making changes
26+
27+
## How It Works
28+
29+
### 1. Initial Setup
30+
- Verify we're on a feature branch (not main/master)
31+
- Find the PR for current branch (or use `--pr`)
32+
- Record start time for effort tracking
33+
34+
### 2. Babysit Loop
35+
36+
For each iteration:
37+
38+
#### Step A: Wait for CI and Reviews
39+
- Poll CI status until all checks complete (or timeout after 15 min)
40+
- Wait for review bots to post their comments (30s grace period after CI)
41+
42+
#### Step B: Fetch ALL Review Comments
43+
Read all review comments — both from AI bots and human reviewers:
44+
45+
**Known AI Review Bots:**
46+
47+
| Bot | Username Pattern | Comment Style |
48+
|-----|-----------------|---------------|
49+
| CodeRabbit | `coderabbitai[bot]` | Structured markdown with file paths, actionable suggestions, and code blocks |
50+
| Sourcery | `sourcery-ai[bot]` | Inline suggestions with refactoring advice and quality scores |
51+
| Gemini | `gemini-code-assist[bot]` | Code review with inline suggestions and summary |
52+
53+
**Fetch all comments (bots + humans):**
54+
```bash
55+
# Top-level PR comments (summaries, discussion)
56+
gh api repos/{owner}/{repo}/issues/{pr}/comments
57+
58+
# Inline review comments (line-specific suggestions from all reviewers)
59+
gh api repos/{owner}/{repo}/pulls/{pr}/comments
60+
61+
# Review threads with verdicts
62+
gh api repos/{owner}/{repo}/pulls/{pr}/reviews
63+
64+
# Human review requests with changes requested
65+
gh pr view $PR_NUMBER --json reviews --jq '.reviews[] | select(.state == "CHANGES_REQUESTED")'
66+
```
67+
68+
Both AI bot suggestions and human reviewer feedback are processed. AI bot comments are parsed for structured suggestions; human comments are read as instructions and addressed with code understanding.
69+
70+
#### Step C: Check for Merge Conflicts
71+
```bash
72+
# Fetch latest base branch
73+
git fetch origin $(gh pr view --json baseRefName --jq '.baseRefName')
74+
75+
# Check if merge is possible
76+
git merge-tree $(git merge-base HEAD origin/main) HEAD origin/main
77+
```
78+
79+
If conflicts exist:
80+
1. Attempt automatic resolution
81+
2. If auto-resolution fails, analyze conflict markers and resolve using code understanding
82+
3. Commit resolution
83+
84+
#### Step D: Apply Fixes from ALL Review Suggestions
85+
For each unresolved review comment (bot or human):
86+
1. Parse the file path and line number from the comment
87+
2. Read the suggested change or instruction
88+
3. For bot comments: extract structured suggestions (code blocks, diffs)
89+
4. For human comments: read the instruction and apply using code understanding
90+
5. Apply the fix (not blind text replacement — understand intent)
91+
6. Track the fix in effort report
92+
93+
#### Step E: Commit and Push
94+
```bash
95+
git add -A
96+
git commit -m "fix(pr): address review bot suggestions
97+
98+
- Applied N fixes from CodeRabbit/Sourcery/Gemini
99+
- Resolved merge conflicts (if any)
100+
101+
Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>"
102+
103+
git push
104+
```
105+
106+
#### Step F: Check Completion
107+
Exit loop if:
108+
- CI passes AND no unresolved review comments → ready to merge
109+
- Max iterations reached → report and stop
110+
111+
### 3. Merge (if `--auto-merge`)
112+
```bash
113+
gh pr merge $PR_NUMBER --squash --delete-branch
114+
```
115+
116+
### 4. Effort Report
117+
118+
Print summary at completion:
119+
120+
```
121+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
122+
PR #123: Feature title
123+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
124+
125+
Effort Summary:
126+
Iterations: 3
127+
Fixes applied: 7
128+
CodeRabbit: 4
129+
Sourcery: 2
130+
Gemini: 1
131+
Conflicts resolved: 1
132+
Total duration: 12m 34s
133+
134+
Result: ✅ Merged successfully
135+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
136+
```
137+
138+
## Exit Conditions
139+
140+
The loop exits when:
141+
- ✅ CI passes AND all review suggestions (bot + human) addressed → merge (if `--auto-merge`)
142+
- ⚠️ Max iterations reached → report status and stop
143+
- ⚠️ Unresolvable conflict or error → report and stop
144+
- ⚠️ Manual interrupt (Ctrl+C)
145+
146+
## Supported Review Bots
147+
148+
### CodeRabbit (`coderabbitai[bot]`)
149+
- Posts a summary comment with overall review
150+
- Leaves inline comments on specific lines with code suggestions
151+
- Uses collapsible sections for detailed analysis
152+
- Suggestions often include replacement code blocks
153+
154+
### Sourcery (`sourcery-ai[bot]`)
155+
- Posts inline suggestions with refactoring advice
156+
- Provides quality metrics (complexity, readability)
157+
- Suggestions include "before" and "after" code
158+
- Labels suggestions by type: bug, refactoring, style
159+
160+
### Gemini (`gemini-code-assist[bot]`)
161+
- Posts review summary with severity levels
162+
- Leaves inline comments with suggested fixes
163+
- Groups findings by category (security, performance, style)
164+
165+
## Examples
166+
167+
### Basic babysit
168+
```bash
169+
# On a feature branch with an open PR
170+
git checkout feat/new-feature
171+
/github:babysit-pr
172+
```
173+
174+
### Babysit and auto-merge
175+
```bash
176+
/github:babysit-pr --auto-merge
177+
```
178+
179+
### Babysit specific PR with limited iterations
180+
```bash
181+
/github:babysit-pr --pr 456 --max-iterations 3
182+
```
183+
184+
### Preview mode
185+
```bash
186+
/github:babysit-pr --dry-run
187+
```
188+
189+
## Continuous Monitoring with /loop
190+
191+
For long-running PRs, combine with `/loop` for periodic checks:
192+
193+
```bash
194+
# Check every 10 minutes, auto-merge when ready
195+
/loop 10m /github:babysit-pr --auto-merge
196+
197+
# Check every 5 minutes for a specific PR
198+
/loop 5m /github:babysit-pr --pr 123 --auto-merge
199+
```
200+
201+
## Related Commands
202+
203+
- `/github:watch-and-fix` - Simpler CI-focused watch loop (no bot parsing)
204+
- `/fix:and-update-pr` - Single-iteration fix and push
205+
- `/github:bulk-merge-prs` - Merge multiple approved PRs

0 commit comments

Comments
 (0)