Add /spawn-pr-fixes command and pr-fixer agent

New command to spawn parallel agents that address PR review feedback:
- /spawn-pr-fixes 12 15 18 - fix specific PRs
- /spawn-pr-fixes - auto-find PRs with requested changes

pr-fixer agent workflow:
- Creates worktree from PR branch
- Reads review comments
- Addresses each piece of feedback
- Commits and pushes fixes
- Runs code-reviewer synchronously
- Loops until approved (max 3 iterations)
- Cleans up worktree
- Outputs concise summary

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-09 17:14:24 +01:00
parent 0692074e16
commit d3bc674b4a
2 changed files with 260 additions and 0 deletions

121
commands/spawn-pr-fixes.md Normal file
View File

@@ -0,0 +1,121 @@
---
allowed-tools: Bash, Task, Read
description: Spawn parallel background agents to address PR review feedback
argument-hint: [pr-number...]
---
# Spawn PR Fixes
Spawn background agents to address review feedback on multiple PRs in parallel. Each agent works in an isolated git worktree.
## Arguments
Optional PR numbers separated by spaces: `$ARGUMENTS`
- With arguments: `/spawn-pr-fixes 12 15 18` - fix specific PRs
- Without arguments: `/spawn-pr-fixes` - find and fix all PRs with requested changes
## Process
### Step 1: Get Repository Info
```bash
REPO_PATH=$(pwd)
REPO_NAME=$(basename $REPO_PATH)
```
### Step 2: Determine PRs to Fix
**If PR numbers provided**: Use those directly
**If no arguments**: Find PRs needing work
```bash
# List open PRs
tea pulls --state open
# For each PR, check if it has review comments requesting changes
tea pulls <number> --comments
```
Look for PRs where:
- Review comments exist that haven't been addressed
- PR is not approved yet
- PR is open (not merged/closed)
### Step 3: For Each PR
1. Fetch PR title using `tea pulls <number>`
2. Spawn background agent using Task tool:
```
Task tool with:
- subagent_type: "general-purpose"
- run_in_background: true
- prompt: See agent prompt below
```
### Agent Prompt
For each PR, use this prompt:
```
You are a pr-fixer agent. Address review feedback on PR #<NUMBER> autonomously.
Context:
- Repository path: <REPO_PATH>
- Repository name: <REPO_NAME>
- PR number: <NUMBER>
Instructions from @agents/pr-fixer/agent.md:
1. Get PR details and review comments:
cd <REPO_PATH>
git fetch origin
tea pulls <NUMBER> --comments
2. Setup worktree from PR branch:
git worktree add ../<REPO_NAME>-pr-<NUMBER> origin/<branch-name>
cd ../<REPO_NAME>-pr-<NUMBER>
git checkout <branch-name>
3. Analyze feedback, create todos with TodoWrite
4. Address each piece of feedback
5. Commit and push:
git add -A && git commit with message "Address review feedback\n\n...\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>"
git push
6. Spawn code-reviewer synchronously (NOT in background) to re-review
7. If needs more work, fix and re-review (max 3 iterations)
8. Cleanup (ALWAYS do this):
cd <REPO_PATH> && git worktree remove ../<REPO_NAME>-pr-<NUMBER> --force
9. Output concise summary (5-10 lines max):
PR #<NUMBER>: <title>
Status: <fixed|partial|blocked>
Feedback addressed: <count> items
Review: <approved|needs-work|skipped>
Work autonomously. Make judgment calls on ambiguous feedback. If blocked, note it in a commit message.
```
### Step 4: Report
After spawning all agents, display:
```
Spawned <N> pr-fixer agents:
| PR | Title | Status |
|-----|--------------------------|------------|
| #12 | Add /commit command | spawned |
| #15 | Add /pr command | spawned |
| #18 | Add CI status | spawned |
Agents working in background. Monitor with:
- Check PR list: tea pulls
- Check worktrees: git worktree list
```