Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

batching-patterns

БесплатноБез исполняемых скриптовНе проверен

Batch all related operations into single messages for maximum parallelism and performance. Use when launching multiple agents, reading multiple files, running…

MadAppGangот MadAppGang★ 290 звёзд на GitHub

Об этом скилле

Batching Patterns

Version: 1.0.0 Purpose: The Golden Rule of Claude Code execution -- batch operations for maximum parallelism Status: Production Ready

Overview

The Golden Rule of Claude Code performance:

"1 MESSAGE = ALL RELATED OPERATIONS"

Every tool call within a single message executes in parallel (when no dependencies exist). Every separate message introduces a sequential round-trip. This distinction is the difference between a 2-minute workflow and a 10-minute one.

Sequential (5 separate messages):
  Message 1: Task(agent-1)  →  2 min
  Message 2: Task(agent-2)  →  2 min (waits for agent-1!)
  Message 3-5: ...           →  2 min each
  Total: ~10 minutes (serial)

Batched (1 message):
  Message 1: Task(agent-1) + Task(agent-2) + ... + Task(agent-5)
  Total: ~2 minutes (parallel, limited by slowest agent)
  Speedup: 5x

Each message carries API round-trip overhead. Batching eliminates N-1 round-trips.


The Batching Principle

Claude Code has a simple execution model:

  1. Within ONE message: Same tool type calls execute in parallel (no data dependencies)
  2. Across SEPARATE messages: Tool calls execute sequentially
  3. Mixed tool types in ONE message: May force sequential execution
Same tool type in one message = PARALLEL
  Task(A) + Task(B) + Task(C)  →  All run simultaneously

Different tool types in one message = SEQUENTIAL (often)
  TaskCreate(...) + Task(A) + Bash(...)  →  May run one at a time

Separate messages = ALWAYS SEQUENTIAL
  Message 1: Task(A)  →  completes first
  Message 2: Task(B)  →  starts only after A finishes

Why Same Tool Type Signals Independence:

Multiple calls of the same tool type (all Task, all Read, all Grep) signal independent operations that can run concurrently. Mixing tool types breaks this signal because different types often have implicit ordering requirements.


Batching Patterns by Tool Type

Task Tool Batching

The most impactful tool to batch -- each agent runs for minutes.

❌ Sequential (3 separate messages):
  Message 1: Task(security-reviewer)   → 3 min
  Message 2: Task(perf-reviewer)       → 2 min (waits!)
  Message 3: Task(a11y-reviewer)       → 2 min (waits!)
  Total: ~7 minutes

✅ Batched (1 message):
  Task(security-reviewer) + Task(perf-reviewer) + Task(a11y-reviewer)
  Total: ~3 minutes (3 agents parallel)
  Speedup: 2.3x

Agents are independent when they: read same input but don't modify it, write to different output files, perform different analysis, don't need each other's results.

File Operations Batching

❌ Sequential Reads:
  Message 1: Read("src/auth.ts")        → round-trip
  Message 2: Read("src/middleware.ts")   → round-trip
  Message 3: Read("src/routes.ts")      → round-trip
  Total: 3 round-trips

✅ Batched Reads:
  Read("src/auth.ts") + Read("src/middleware.ts") + Read("src/routes.ts")
  Total: 1 round-trip (3x faster)
❌ Sequential Searches:
  Message 1: Grep("TODO", path="src/")
  Message 2: Grep("FIXME", path="src/")
  Message 3: Glob("**/*.test.ts")

✅ Batched Searches:
  Grep("TODO") + Grep("FIXME") + Glob("**/*.test.ts")
  All parallel in 1 round-trip
⚠️ Write/Edit Caution:
  ❌ Edit("src/auth.ts", change_1) + Edit("src/auth.ts", change_2)  ← Conflict!
  ✅ Edit("src/auth.ts", change_1) + Edit("src/routes.ts", change_2)  ← Safe
  Rule: Different files = safe to batch. Same file = must be sequential.

Tasks Batching

❌ Individual Calls (5 round-trips):
  TaskCreate({ id: "1", title: "Step 1", status: "pending" })
  TaskCreate({ id: "2", title: "Step 2", status: "pending" })
  ...

✅ Single Call (1 round-trip):
  TaskCreate({ id: "1", title: "Step 1", status: "pending" })
  TaskCreate({ id: "2", title: "Step 2", status: "pending" })
  TaskCreate({ id: "3", title: "Step 3", status: "pending" })
  # All in same message = parallel execution

Bash Batching

❌ Sequential Independent Commands:
  Message 1: Bash("npm run lint")
  Message 2: Bash("npm run typecheck")
  Message 3: Bash("npm run test")

✅ Parallel Independent Commands (1 message):
  Bash("npm run lint") + Bash("npm run typecheck") + Bash("npm run test")

✅ Dependent Commands Chained (1 Bash call):
  Bash("mkdir -p ai-docs && cp template.md ai-docs/plan.md")

The 4-Message Pattern (Reference)

The canonical batching template from multi-agent-coordination:

Message 1: Preparation (Bash/Write only)
  - Create directories, write context files, validate inputs
  - NO Task calls, NO Tasks

Message 2: Parallel Execution (Task only)
  - ALL agents in SINGLE message, ONLY Task calls
  - Same tool type = true parallel execution

Message 3: Consolidation (Task only)
  - Consolidation agent reads all output files

Message 4: Present Results
  - Show user final consolidated results

Why 4 messages: Each depends on the previous (agents need context, consolidation needs agent outputs, presentation needs consolidated result). This is the m

Полный SKILL.md на GitHub

Установить batching-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл batching-patterns?

Batch all related operations into single messages for maximum parallelism and performance. Use when launching multiple agents, reading multiple files, running parallel searches, optimizing workflow speed, or avoiding sequential execution bottlenecks. Trigger keywords - "batching", "parallel", "single message", "golden rule", "concurrent", "performance", "sequential bottleneck", "speed optimization".

Как установить скилл batching-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл batching-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить batching-patterns с