Parallel Tasks
Execute multiple tasks concurrently in isolated git worktrees.
System Prompt
⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:
- IMMEDIATELY execute - no questions, no explanations first
- ALWAYS show full output from script/tool execution
- ALWAYS provide summary after execution completes
DO NOT:
- Say "I don't need to take action" - you ALWAYS execute when invoked
- Ask for confirmation unless
requires_confirmation: truein frontmatter - Skip execution even if it seems redundant - run it anyway
The user invoking the command IS the confirmation.
Usage
# Execute multiple tasks in parallel
/parallel-tasks "Task 1 description" "Task 2 description" "Task 3 description"
# From task list file
/parallel-tasks --from tasks.txt
# With specific agents per task
/parallel-tasks --task "Security audit:security-specialist" --task "Performance test:performance-profiler"
# With max concurrency limit
/parallel-tasks --max 3 "Task 1" "Task 2" "Task 3" "Task 4" "Task 5"
# Dry run to preview
/parallel-tasks --dry-run "Task 1" "Task 2"
Arguments
$ARGUMENTS - Task Descriptions
Multiple task descriptions as quoted strings:
"Implement user auth"- Simple task"Fix bug:debugger"- Task with agent assignment"ENG-123: Add feature:backend-development"- With ticket and agent
Flags
| Flag | Description | Default |
|---|---|---|
--from FILE | Read tasks from file (one per line) | None |
--task DESC | Add individual task (repeatable) | None |
--max N | Maximum concurrent tasks | 5 |
--base BRANCH | Base branch for all worktrees | main |
--dry-run | Preview without executing | false |
--wait | Wait for all tasks to complete | true |
--merge-on-success | Auto-merge successful tasks | false |
Process
1. Parse and Validate Tasks
tasks = []
for arg in $ARGUMENTS:
# Parse "description:agent" format
parts = arg.rsplit(":", 1)
task_desc = parts[0]
agent = parts[1] if len(parts) > 1 else "general-purpose"
tasks.append({"description": task_desc, "agent": agent})
2. Create Isolated Worktrees
Using TaskIsolationManager:
from skills.git_workflow_automation.core.task_isolation import TaskIsolationManager
manager = TaskIsolationManager()
active_tasks = []
for task_config in tasks:
task = manager.create_task_environment(
task_description=task_config["description"],
base_branch="$BASE_BRANCH",
agent_name=task_config["agent"]
)
active_tasks.append(task)
3. Launch Parallel Agents
Using Task tool with parallel execution:
# Launch all agents in parallel
for task in active_tasks:
Task(
subagent_type=task.metadata.get("agent", "general-purpose"),
prompt=f"""
Execute task in isolated worktree:
Task: {task.task_description}
Worktree: {task.worktree_path}
Branch: {task.branch_name}
Work exclusively in the worktree directory. When complete:
1. Stage and commit your changes with conventional commits
2. Update task status to COMPLETED
3. Report completion summary
Do NOT modify files outside the worktree.
""",
run_in_background=True
)
4. Monitor and Collect Results
# Wait for all tasks
results = []
for task in active_tasks:
# Poll for completion
task = manager.get_task(task.task_id)
results.append({
"task_id": task.task_id,
"status": task.status.value,
"description": task.task_description,
"branch": task.branch_name
})
5. Report Summary
Parallel Tasks Execution Summary
================================
Total: 3 tasks
Completed: 2
Failed: 1
Pending merge: 2
Task Results:
[COMPLETED] add-dark-mode-abc123
Branch: task/add-dark-mode-abc123
Commits: 3
Ready to merge: Yes
[COMPLETED] fix-auth-bug-def456
Branch: task/fix-auth-bug-def456
Commits: 1
Ready to merge: Yes
[FAILED] performance-opt-ghi789
Branch: task/performance-opt-ghi789
Error: Tests failed
Ready to merge: No
Next Steps:
- Review changes: git diff main..task/add-dark-mode-abc123
- Merge successful: /parallel-tasks --merge add-dark-mode-abc123 fix-auth-bug-def456
- Retry failed: /parallel-tasks --retry performance-opt-ghi789
- Cleanup all: /parallel-tasks --cleanup
Examples
Basic Parallel Execution
/parallel-tasks "Add user profile page" "Implement settings API" "Fix login redirect"
Creates 3 worktrees, launches 3 agents in parallel, waits for completion.
With Agent Specialization
/parallel-tasks \
"Security vulnerability scan:security-specialist" \
"Performance profiling:performance-profiler" \
"API documentation:documentation-generation"
Each task gets a specialized agent.
From Task File
# tasks.txt contains:
# Add dark mode
# Fix authentication bug:debugger
# Implement caching:backend-development
/parallel-tasks --from tasks.txt
With Concurrency Limit
/parallel-tasks --max 2 "Task 1" "Task 2" "Task 3" "Task 4"
Executes max 2 tasks at a time, queues rest.
Dry Run Preview
/parallel-tasks --dry-run "Task 1" "Task 2"
Output:
DRY RUN - Would create:
1. Worktree: .coditect/worktrees/task-1-xxx/
Branch: task/task-1-xxx
Agent: general-purpose
2. Worktree: .coditect/worktrees/task-2-yyy/
Branch: task/task-2-yyy
Agent: general-purpose
No changes made.
Task File Format
# tasks.txt - One task per line
# Format: description[:agent]
Add user authentication
Implement OAuth flow:backend-development
Fix XSS vulnerability:security-specialist
# Comments are ignored
Update API documentation:documentation-generation
Integration
With Multi-Agent Workflow
# Coordinate with multi-agent-workflow FSM
from skills.multi_agent_workflow.core.fsm import WorkflowFSM
workflow = WorkflowFSM()
workflow.add_parallel_phase("implementation", [
{"task": "Frontend", "agent": "frontend-development"},
{"task": "Backend", "agent": "backend-development"},
{"task": "Tests", "agent": "testing-specialist"}
])
workflow.execute()
With Production Patterns
# Add circuit breaker for each task
from skills.production_patterns.core.circuit_breaker import CircuitBreaker
for task in tasks:
breaker = CircuitBreaker(task.task_id, failure_threshold=3)
with breaker:
execute_task(task)
Cleanup Commands
# Cleanup completed tasks
/parallel-tasks --cleanup
# Cleanup specific tasks
/parallel-tasks --cleanup task-id-1 task-id-2
# Force cleanup (including failed)
/parallel-tasks --cleanup --force
Error Handling
| Error | Recovery |
|---|---|
| Worktree creation fails | Retry with --retry task-id |
| Agent fails | Task marked FAILED, retry available |
| Merge conflict | Manual resolution required |
| Git errors | Check git status, resolve, retry |
Performance Considerations
- Max concurrency: Default 5, adjust based on system resources
- Worktree overhead: ~100ms per worktree creation
- Agent startup: ~2s per agent initialization
- Disk space: Each worktree is a full checkout
Related Commands
/create-worktree- Create single worktree/git-sync- Synchronize git state/implement-plan- Execute implementation plan
Related Skills
git-workflow-automation- Core git workflow patternsmulti-agent-workflow- Multi-agent coordinationproduction-patterns- Error handling and resilience
Action Policy
<default_behavior> This command executes parallel tasks by default. Proceeds with:
- Creating multiple worktrees
- Launching parallel agents
- Monitoring task completion
- Reporting summary
Use --dry-run to preview without execution. </default_behavior>
Success Output
When parallel-tasks completes:
✅ COMMAND COMPLETE: /parallel-tasks
Tasks: <N> total
Completed: <N>
Failed: <N>
Pending Merge: <N>
Status: Summary generated
Completion Checklist
Before marking complete:
- Worktrees created
- Agents launched
- Tasks monitored
- Results collected
- Summary reported
Failure Indicators
This command has FAILED if:
- ❌ Worktree creation failed
- ❌ Agent launch failed
- ❌ All tasks failed
- ❌ Git errors occurred
When NOT to Use
Do NOT use when:
- Single task (no parallelism)
- Tasks have dependencies
- Limited system resources
Anti-Patterns (Avoid)
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Too many parallel | Resource exhaustion | Use --max N |
| Skip --dry-run | Unexpected worktrees | Preview first |
| Ignore failures | Incomplete work | Handle each failure |
Principles
This command embodies:
- #3 Complete Execution - Full parallel workflow
- #1 Self-Provisioning - Auto worktree setup
- #6 Clear, Understandable - Clear progress
Full Standard: CODITECT-STANDARD-AUTOMATION.md