Parallel Agents

作者 parcadeid07ff4b06b62无许可证3.9K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库8个月前更新

Parallel Agent Orchestration

仅含说明AI & Agents
AI 生成的概览

通过基于文件的状态跟踪,并行启动多个子代理并避免上下文膨胀的模式。

功能
该技能记录了一套编排模式:在后台同时运行多个代理,并让每个代理通过向共享状态文件追加一行来确认完成,而不是返回输出。它还描述了用于保存代理详细发现的目录结构,以及监控批次进度的命令。
适用场景
当任务可以拆分为许多应同时运行的独立子任务时使用,例如批量回填或并行研究。它适用于每批最多协调十五个代理,同时不让它们的输出淹没主上下文。
运行要求
需要支持后台子代理任务的代理运行时,以及用于写入和读取状态文件的 shell 访问权限;不包含任何脚本或软件包。

Parallel Agent Orchestration

When launching multiple agents in parallel, follow this pattern to avoid context bloat.

Core Principles

  1. No TaskOutput calls - TaskOutput returns full agent output, bloating context
  2. Run in background - Always use run_in_background: true
  3. File-based confirmation - Agents write status to files, not return values
  4. Append, don't overwrite - Multiple agents can write to same status file

Output Patterns

Simple Confirmation (parallel batch work)

For tasks where agents just need to confirm completion:

bash
# Agent writes to shared status fileecho "COMPLETE: <task-name> - $(date)" >> .claude/cache/<batch-name>-status.txt
  • Use >> to append (not > which overwrites)
  • Include timestamp for ordering
  • One line per agent completion
  • Check with: cat .claude/cache/<batch-name>-status.txt

Detailed Output (research/exploration)

For tasks requiring detailed findings:

.claude/cache/agents/<task-type>/<agent-id>/├── output.md      # Main findings├── artifacts/     # Any generated files└── status.txt     # Completion confirmation
  • Each agent gets own directory
  • Full output preserved for later reading
  • Status file still used for quick completion check

Task Prompt Template

markdown
# Task: <TASK_NAME>
## Your Mission<clear objective>
## OutputWhen done, write confirmation:\`\`\`bashecho "COMPLETE: <identifier> - $(date)" >> .claude/cache/<batch>-status.txt\`\`\`
Do NOT return large output. Complete work silently.

Launching Pattern

typescript
// Launch all in single message block (parallel)Task({  description: "Task 1",  prompt: "...",  subagent_type: "general-purpose",  run_in_background: true})Task({  description: "Task 2",  prompt: "...",  subagent_type: "general-purpose",  run_in_background: true})// ... up to 15 parallel agents

Monitoring

bash
# Check completion statuscat .claude/cache/<batch>-status.txt
# Count completionswc -l .claude/cache/<batch>-status.txt
# Watch for updatestail -f .claude/cache/<batch>-status.txt

Batch Size

  • Max 15 agents per parallel batch
  • Wait for batch to complete before launching next
  • Use status file to track which completed

DO

  • Use run_in_background: true always
  • Have agents write to status files
  • Use append (>>) not overwrite (>)
  • Give each agent clear, self-contained instructions
  • Include all context in prompt (agents don't share memory)

DON'T

  • Call TaskOutput (bloats context)
  • Return large outputs from agents
  • Launch more than 15 at once
  • Rely on agent return values for orchestration

Example: Provider Backfill

bash
# Status file.claude/cache/provider-backfill-status.txt
# Each agent appends on completionecho "COMPLETE: anthropic - Thu Jan 2 12:34:56 2025" >> .claude/cache/provider-backfill-status.txtecho "COMPLETE: openai - Thu Jan 2 12:35:12 2025" >> .claude/cache/provider-backfill-status.txt

Check progress:

bash
cat .claude/cache/provider-backfill-status.txt# COMPLETE: anthropic - Thu Jan 2 12:34:56 2025# COMPLETE: openai - Thu Jan 2 12:35:12 2025

来源与署名

来源:parcadei/continuous-claude-v3位于.claude/skills/parallel-agents提交d07ff4b

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架