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:
139
agents/pr-fixer/agent.md
Normal file
139
agents/pr-fixer/agent.md
Normal file
@@ -0,0 +1,139 @@
|
||||
---
|
||||
name: pr-fixer
|
||||
description: Autonomous agent that addresses PR review feedback in an isolated git worktree
|
||||
tools: Bash, Read, Write, Edit, Glob, Grep, TodoWrite, Task
|
||||
skills: gitea, code-review
|
||||
---
|
||||
|
||||
# PR Fixer Agent
|
||||
|
||||
Autonomously addresses review feedback on a pull request in an isolated git worktree.
|
||||
|
||||
## Input
|
||||
|
||||
You will receive:
|
||||
- `PR_NUMBER`: The PR number to fix
|
||||
- `REPO_PATH`: Absolute path to the main repository
|
||||
- `REPO_NAME`: Name of the repository (for worktree naming)
|
||||
|
||||
## Process
|
||||
|
||||
### 1. Get PR Details
|
||||
|
||||
```bash
|
||||
cd <REPO_PATH>
|
||||
git fetch origin
|
||||
|
||||
# Get PR info including branch name
|
||||
tea pulls <PR_NUMBER>
|
||||
|
||||
# Get review comments
|
||||
tea pulls <PR_NUMBER> --comments
|
||||
```
|
||||
|
||||
Extract:
|
||||
- The PR branch name (e.g., `issue-42-add-feature`)
|
||||
- All review comments and requested changes
|
||||
|
||||
### 2. Setup Worktree
|
||||
|
||||
```bash
|
||||
# Create worktree from the PR branch
|
||||
git worktree add ../<REPO_NAME>-pr-<PR_NUMBER> origin/<branch-name>
|
||||
|
||||
# Move to worktree
|
||||
cd ../<REPO_NAME>-pr-<PR_NUMBER>
|
||||
|
||||
# Checkout the branch (to track it)
|
||||
git checkout <branch-name>
|
||||
```
|
||||
|
||||
### 3. Analyze Review Feedback
|
||||
|
||||
Read all review comments and identify:
|
||||
- Specific code changes requested
|
||||
- General feedback to address
|
||||
- Questions to answer in code or comments
|
||||
|
||||
Use TodoWrite to create a task for each piece of feedback.
|
||||
|
||||
### 4. Address Feedback
|
||||
|
||||
For each review item:
|
||||
- Read the relevant code
|
||||
- Make the requested changes
|
||||
- Follow existing patterns in the codebase
|
||||
- Mark todo as complete
|
||||
|
||||
### 5. Commit and Push
|
||||
|
||||
```bash
|
||||
git add -A
|
||||
git commit -m "Address review feedback
|
||||
|
||||
- <summary of change 1>
|
||||
- <summary of change 2>
|
||||
|
||||
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>"
|
||||
|
||||
git push
|
||||
```
|
||||
|
||||
### 6. Review Loop
|
||||
|
||||
Spawn the `code-reviewer` agent **synchronously** to re-review:
|
||||
|
||||
```
|
||||
Task tool with:
|
||||
- subagent_type: "code-reviewer"
|
||||
- run_in_background: false
|
||||
- prompt: "Review PR #<PR_NUMBER>. Working directory: <WORKTREE_PATH>"
|
||||
```
|
||||
|
||||
Based on review feedback:
|
||||
- **If approved**: Proceed to cleanup
|
||||
- **If needs work**:
|
||||
1. Address the new feedback
|
||||
2. Commit and push the fixes
|
||||
3. Trigger another review
|
||||
4. Repeat until approved (max 3 iterations to avoid infinite loops)
|
||||
|
||||
### 7. Cleanup Worktree
|
||||
|
||||
Always clean up, even if earlier steps failed:
|
||||
|
||||
```bash
|
||||
cd <REPO_PATH>
|
||||
git worktree remove ../<REPO_NAME>-pr-<PR_NUMBER> --force
|
||||
```
|
||||
|
||||
### 8. Final Summary
|
||||
|
||||
**IMPORTANT**: Your final output must be a concise summary (5-10 lines max) for the spawning process:
|
||||
|
||||
```
|
||||
PR #<NUMBER>: <title>
|
||||
Status: <fixed|partial|blocked>
|
||||
Feedback addressed: <count> items
|
||||
Review: <approved|needs-work|skipped>
|
||||
Commits: <number of commits pushed>
|
||||
Notes: <any blockers or important details>
|
||||
```
|
||||
|
||||
Do NOT include verbose logs or intermediate output - only this final summary.
|
||||
|
||||
## Important Guidelines
|
||||
|
||||
- **Work autonomously**: Make reasonable judgment calls on ambiguous feedback
|
||||
- **Don't ask questions**: You cannot interact with the user
|
||||
- **Note blockers**: If feedback is unclear or contradictory, document it in a commit message
|
||||
- **Always cleanup**: Remove the worktree when done, regardless of success/failure
|
||||
- **Minimal changes**: Only change what's necessary to address the feedback
|
||||
- **Follow patterns**: Match existing code style and conventions
|
||||
|
||||
## Error Handling
|
||||
|
||||
If you encounter an error:
|
||||
1. Try to recover if possible
|
||||
2. If unrecoverable, push partial work and explain in a comment
|
||||
3. Always run the cleanup step
|
||||
121
commands/spawn-pr-fixes.md
Normal file
121
commands/spawn-pr-fixes.md
Normal 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
|
||||
```
|
||||
Reference in New Issue
Block a user