--- name: spawn-pr-fixers description: > Fix one or more PRs based on review feedback using pr-fixer agents. Creates isolated worktrees, addresses review comments, commits and pushes fixes. Use when PRs need work, or when user says /spawn-pr-fixers. model: claude-haiku-4-5 argument-hint: [...] allowed-tools: Bash, Task, Read, TaskOutput user-invocable: true --- # Spawn PR Fixers @~/.claude/skills/worktrees/SKILL.md @~/.claude/skills/gitea/SKILL.md Fix one or more pull requests that have review feedback using pr-fixer agents. ## Arguments One or more PR numbers: `$ARGUMENTS` Example: `/spawn-pr-fixers 55 56 57` ## Workflow ``` Concurrent Fixes - each PR fixed independently: PR #55 ──► fetch branch ──► create worktree ──► read feedback ──► fix ──► commit ──► push ✓ PR #56 ──► fetch branch ──► create worktree ──► read feedback ──► fix ──► commit ──► push ✓ PR #57 ──► fetch branch ──► create worktree ──► read feedback ──► fix ──► commit ──► push ✓ Event-driven: As each fix completes, show results immediately. ``` ## Process ### 1. Parse and Validate Parse `$ARGUMENTS` into PR numbers. If empty: ``` Usage: /spawn-pr-fixers [...] Example: /spawn-pr-fixers 55 56 ``` ### 2. Setup Repository Context ```bash REPO_PATH=$(pwd) REPO_NAME=$(basename "$REPO_PATH") WORKTREES_DIR="${REPO_PATH}/../worktrees" ``` Verify in git repository: ```bash git rev-parse --git-dir >/dev/null 2>&1 || exit 1 ``` ### 3. Fetch PR Details and Create Worktrees For each PR number: **Get PR details:** ```bash tea pulls ``` Extract: - Branch name (e.g., "issue-42-feature-name") - PR title - PR state (verify it's open) **Check for review comments:** ```bash tea pulls --comments ``` Verify there are review comments. If no comments: ``` [PR #] No review comments found - skipping ``` **Create fix worktree:** ```bash cd "$REPO_PATH" git fetch origin fix_worktree=$(~/.claude/skills/worktrees/scripts/create-worktree.sh review ) ``` Track PR state: ```javascript prs = { 55: { worktree: "/path/to/worktrees/repo-review-55", branch: "issue-42-feature", title: "Add user authentication", stage: "ready", task_id: null }, ... } ``` Print initial status: ``` Created fix worktrees for 3 PRs: [PR #55] ready - Add user authentication [PR #56] ready - Fix validation bug [PR #57] ready - Update documentation ``` ### 4. Spawn PR Fixers For each PR, spawn pr-fixer agent in background: ``` Task tool with: - subagent_type: "pr-fixer" - run_in_background: true - prompt: "Fix PR # based on review feedback Repository: PR number: Worktree: Follow the pr-fixer agent instructions to address review feedback. Output the result in PR_FIXER_RESULT format." ``` Track task_id for each PR and update stage to "fixing". Print status: ``` [PR #55] fixing... [PR #56] fixing... [PR #57] fixing... ``` ### 5. Event-Driven Results **Wait for `` messages** that arrive automatically when background tasks complete. When notification arrives: 1. **Identify which PR completed:** - Extract task_id from notification - Look up which PR this belongs to 2. **Read task output:** ``` TaskOutput tool with task_id ``` 3. **Parse result:** - Extract status (fixed/partial/failed) - Extract changes summary 4. **Print status update:** ``` [PR #55] Fix complete: fixed ✓ [PR #56] Fix complete: partial (some issues unclear) [PR #57] Fix complete: fixed ✓ ``` 5. **Check if all done:** - If all PRs fixed → proceed to cleanup and summary ### 6. Cleanup Worktrees After all fixes complete: ```bash cd "$REPO_PATH" ~/.claude/skills/worktrees/scripts/cleanup-worktrees.sh "$WORKTREES_DIR" ``` This removes all fix worktrees created during this run. ### 7. Final Summary Print summary table with links: ``` All fixes complete! | PR | Title | Status | Changes | |-----|---------------------------|-------------|--------------------------------------| | #55 | Add user authentication | fixed ✓ | Fixed error handling, added tests | | #56 | Fix validation bug | partial | Fixed main issue, one unclear | | #57 | Update documentation | fixed ✓ | Fixed typos, improved examples | 2 fully fixed, 1 partial PRs updated: - PR #55: https://git.flowmade.one/owner/repo/pulls/55 - PR #56: https://git.flowmade.one/owner/repo/pulls/56 - PR #57: https://git.flowmade.one/owner/repo/pulls/57 Next: Re-run reviews with /spawn-pr-reviews to verify fixes ``` ## Guidelines **Event-driven execution:** - Wait for task-notification messages - Don't poll or check task status manually - Process notifications as they arrive - Fix each PR independently **Worktree management:** - Create fix worktrees upfront - One worktree per PR - Clean up all worktrees at end - Always cleanup, even on error **State tracking:** - Track stage and task_id for each PR - Update state when notifications arrive - Print status after each transition **Error handling:** - If PR not found: skip it, continue with others - If PR is closed: skip it, note in summary - If no review comments: skip it, note why - If branch not found: skip it, note error - If fixer fails: mark as "failed" - Always cleanup worktrees **Review iteration:** - This is one fix pass - After fixes, use /spawn-pr-reviews to re-review - Can repeat fix → review cycles manually - For automated cycles, use /spawn-issues instead ## Use Cases **When to use spawn-pr-fixers:** - PRs have review feedback that needs addressing - Manual PRs from team members need fixes - spawn-issues hit review iteration limit (3 cycles) - You want to re-apply fixes after manual changes - Quick fixes to existing PRs **When NOT to use spawn-pr-fixers:** - Implementing new issues (use /spawn-issues) - Just reviewing PRs (use /spawn-pr-reviews) - Need automated review loops (use /spawn-issues) - PRs have no review comments yet ## Tips - Run after /spawn-pr-reviews identifies issues - Can fix multiple PRs at once for efficiency - Fixes are autonomous (agents make judgment calls) - Review the fixes after completion - Use /spawn-pr-reviews again to verify fixes - For full automation, use /spawn-issues instead