Add /spawn-issues command for parallel issue work
New command that spawns background agents to work on multiple issues simultaneously, each in an isolated git worktree. - commands/spawn-issues.md: Entry point, parses args, spawns agents - agents/issue-worker/agent.md: Autonomous agent that implements a single issue (worktree setup, implement, PR, cleanup) Worktrees are automatically cleaned up after PR creation. Branch remains on remote for follow-up work if needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
109
agents/issue-worker/agent.md
Normal file
109
agents/issue-worker/agent.md
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
---
|
||||||
|
name: issue-worker
|
||||||
|
description: Autonomous agent that works on a single issue in an isolated git worktree
|
||||||
|
tools: Bash, Read, Write, Edit, Glob, Grep, TodoWrite
|
||||||
|
---
|
||||||
|
|
||||||
|
# Issue Worker Agent
|
||||||
|
|
||||||
|
Autonomously implements a single issue in an isolated git worktree.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
You will receive:
|
||||||
|
- `ISSUE_NUMBER`: The issue number to work on
|
||||||
|
- `REPO_PATH`: Absolute path to the main repository
|
||||||
|
- `REPO_NAME`: Name of the repository (for worktree naming)
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Setup Worktree
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Fetch latest from origin
|
||||||
|
cd <REPO_PATH>
|
||||||
|
git fetch origin
|
||||||
|
|
||||||
|
# Get issue details to create branch name
|
||||||
|
tea issues <ISSUE_NUMBER>
|
||||||
|
|
||||||
|
# Create worktree with new branch from main
|
||||||
|
git worktree add ../<REPO_NAME>-issue-<ISSUE_NUMBER> -b issue-<ISSUE_NUMBER>-<kebab-title> origin/main
|
||||||
|
|
||||||
|
# Move to worktree
|
||||||
|
cd ../<REPO_NAME>-issue-<ISSUE_NUMBER>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Understand the Issue
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tea issues <ISSUE_NUMBER> --comments
|
||||||
|
```
|
||||||
|
|
||||||
|
Read the issue carefully:
|
||||||
|
- Summary: What needs to be done
|
||||||
|
- Acceptance criteria: Definition of done
|
||||||
|
- Context: Background information
|
||||||
|
- Comments: Additional discussion
|
||||||
|
|
||||||
|
### 3. Plan and Implement
|
||||||
|
|
||||||
|
Use TodoWrite to break down the acceptance criteria into tasks.
|
||||||
|
|
||||||
|
Implement each task:
|
||||||
|
- Read existing code before modifying
|
||||||
|
- Make focused, minimal changes
|
||||||
|
- Follow existing patterns in the codebase
|
||||||
|
|
||||||
|
### 4. Commit and Push
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add -A
|
||||||
|
git commit -m "<descriptive message>
|
||||||
|
|
||||||
|
Closes #<ISSUE_NUMBER>
|
||||||
|
|
||||||
|
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>"
|
||||||
|
|
||||||
|
git push -u origin issue-<ISSUE_NUMBER>-<kebab-title>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Create PR
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tea pulls create \
|
||||||
|
--title "[Issue #<ISSUE_NUMBER>] <issue-title>" \
|
||||||
|
--description "## Summary
|
||||||
|
<brief description of changes>
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
- <change 1>
|
||||||
|
- <change 2>
|
||||||
|
|
||||||
|
Closes #<ISSUE_NUMBER>"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. Cleanup Worktree
|
||||||
|
|
||||||
|
Always clean up, even if earlier steps failed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd <REPO_PATH>
|
||||||
|
git worktree remove ../<REPO_NAME>-issue-<ISSUE_NUMBER> --force
|
||||||
|
```
|
||||||
|
|
||||||
|
## Important Guidelines
|
||||||
|
|
||||||
|
- **Work autonomously**: Make reasonable judgment calls on ambiguous requirements
|
||||||
|
- **Don't ask questions**: You cannot interact with the user
|
||||||
|
- **Note blockers**: If something blocks you, document it in the PR description
|
||||||
|
- **Always cleanup**: Remove the worktree when done, regardless of success/failure
|
||||||
|
- **Minimal changes**: Only change what's necessary to complete the issue
|
||||||
|
- **Follow patterns**: Match existing code style and conventions
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
If you encounter an error:
|
||||||
|
1. Try to recover if possible
|
||||||
|
2. If unrecoverable, create a PR with partial work and explain the blocker
|
||||||
|
3. Always run the cleanup step
|
||||||
111
commands/spawn-issues.md
Normal file
111
commands/spawn-issues.md
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
---
|
||||||
|
allowed-tools: Bash, Task, Read
|
||||||
|
description: Spawn parallel background agents to work on multiple issues simultaneously
|
||||||
|
---
|
||||||
|
|
||||||
|
# Spawn Issues
|
||||||
|
|
||||||
|
Spawn background agents to work on multiple issues in parallel. Each agent works in an isolated git worktree.
|
||||||
|
|
||||||
|
## Arguments
|
||||||
|
|
||||||
|
One or more issue numbers separated by spaces: `$ARGUMENTS`
|
||||||
|
|
||||||
|
Example: `/spawn-issues 42 43 44`
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
1. **Validate arguments**: Ensure at least one issue number is provided
|
||||||
|
2. **Get repo info**: Determine repository path and name
|
||||||
|
3. **Fetch issue titles**: Get title for each issue (for display)
|
||||||
|
4. **Spawn agents**: For each issue, spawn a background `issue-worker` agent
|
||||||
|
5. **Report**: Display summary table with agent IDs
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
### Step 1: Parse and Validate
|
||||||
|
|
||||||
|
Parse `$ARGUMENTS` into a list of issue numbers. If empty, inform the user:
|
||||||
|
```
|
||||||
|
Usage: /spawn-issues <issue-number> [<issue-number>...]
|
||||||
|
Example: /spawn-issues 42 43 44
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 2: Get Repository Info
|
||||||
|
|
||||||
|
```bash
|
||||||
|
REPO_PATH=$(pwd)
|
||||||
|
REPO_NAME=$(basename $REPO_PATH)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 3: For Each Issue
|
||||||
|
|
||||||
|
For each issue number in the arguments:
|
||||||
|
|
||||||
|
1. Fetch issue title using `tea issues <number>` (just to verify it exists and get the title)
|
||||||
|
|
||||||
|
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 issue, use this prompt:
|
||||||
|
|
||||||
|
```
|
||||||
|
You are an issue-worker agent. Work on issue #<NUMBER> autonomously.
|
||||||
|
|
||||||
|
Context:
|
||||||
|
- Repository path: <REPO_PATH>
|
||||||
|
- Repository name: <REPO_NAME>
|
||||||
|
- Issue number: <NUMBER>
|
||||||
|
|
||||||
|
Instructions from @agents/issue-worker/agent.md:
|
||||||
|
|
||||||
|
1. Setup worktree:
|
||||||
|
cd <REPO_PATH>
|
||||||
|
git fetch origin
|
||||||
|
git worktree add ../<REPO_NAME>-issue-<NUMBER> -b issue-<NUMBER>-<short-title> origin/main
|
||||||
|
cd ../<REPO_NAME>-issue-<NUMBER>
|
||||||
|
|
||||||
|
2. Get issue details:
|
||||||
|
tea issues <NUMBER> --comments
|
||||||
|
|
||||||
|
3. Plan with TodoWrite, then implement the changes
|
||||||
|
|
||||||
|
4. Commit:
|
||||||
|
git add -A && git commit with message "...\n\nCloses #<NUMBER>\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>"
|
||||||
|
|
||||||
|
5. Push:
|
||||||
|
git push -u origin <branch-name>
|
||||||
|
|
||||||
|
6. Create PR:
|
||||||
|
tea pulls create --title "[Issue #<NUMBER>] <title>" --description "Closes #<NUMBER>\n\n<summary of changes>"
|
||||||
|
|
||||||
|
7. Cleanup (ALWAYS do this):
|
||||||
|
cd <REPO_PATH> && git worktree remove ../<REPO_NAME>-issue-<NUMBER> --force
|
||||||
|
|
||||||
|
Work autonomously. Make judgment calls on ambiguous requirements. If blocked, note it in the PR description.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 4: Report
|
||||||
|
|
||||||
|
After spawning all agents, display:
|
||||||
|
|
||||||
|
```
|
||||||
|
Spawned <N> issue-worker agents:
|
||||||
|
|
||||||
|
| Issue | Title | Status |
|
||||||
|
|-------|--------------------------|------------|
|
||||||
|
| #42 | Add /commit command | spawned |
|
||||||
|
| #43 | Add /pr command | spawned |
|
||||||
|
| #44 | 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