agentleFS
kimasplundkimasplund/thinkbetter-skills/skills/parallel-execution/SKILL.md

parallel-execution

Skill0 starsChanged 30 days agoMITView on GitHub

Guides running independent work in parallel, as several tool calls or several subagents in one message, and merging the results. Use when a task splits into independent sub-problems, when the user says "do these in parallel", "fan out", "explore several approaches at once", "run these agents at the same time", or when several branches, hypotheses or perspectives need to be explored together. Also covers parallel code editing in isolated worktrees and advanced ensemble and tree-search patterns. Not for steps that depend on each other (use self-reflecting-chain).

9 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use writing-skills.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • OpenAISkill

    writing-skills

    Use when creating new skills, editing existing skills, or verifying skills work before deployment

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If proposers agree: Boost confidence +5%

    line 229
  2. Distinctive:

    If 2/3 agree: Use majority, document minority

    line 230
  3. Distinctive:

    If no agreement: Escalate to DR (Dialectical Reasoning)

    line 231
  4. Distinctive:

    Parallelizing sequential dependencies: - If step 2 needs step 1's output, don't parallelize

    line 338
  5. Distinctive:

    No merge strategy defined: - Always know how to combine results before fan-out

    line 340

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Parallel Execution Patterns

Built-in Parallel Patterns (no skill needed)

Claude Code v2.1.76+ provides native parallelism. Use these first before reaching for advanced patterns.

PatternHowBest For
Parallel tool callsMultiple tools in single response auto-batchReading files, searching, independent lookups
Parallel subagentsMultiple Task calls with run_in_background: trueIndependent research, analysis, exploration
Agent teamsCLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1Coordinated multi-file work with shared tasks
Worktree isolationisolation: worktree in agent frontmatterParallel agents editing code on separate branches
Background executionCtrl+B or run_in_background: trueLong-running tasks you don't need results from immediately

Parallel Tool Calls

Just make multiple tool calls in one response. Claude Code batches them automatically:

# These run in parallel:
- Read file A
- Read file B
- Grep for pattern X
- Glob for *.ts files

Parallel Subagents

Spawn multiple independent agents that run concurrently:

# Fan-out: 3 agents in parallel
Task 1 (run_in_background: true): "Analyze database performance"
Task 2 (run_in_background: true): "Review API response times"
Task 3 (run_in_background: true): "Check frontend bundle size"

# Fan-in: collect results
TaskOutput from Task 1, 2, 3
Synthesize findings

Agent Teams

For coordinated parallel work where agents need to communicate:

Enable: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

Shared task list:
1. Refactor models (no deps)
2. Update routes (depends: 1)
3. Update tests (depends: 1)
4. Update docs (depends: 1, 2, 3)

Agents pick available tasks and coordinate automatically.

Worktree Isolation

For parallel code editing without conflicts:

# Agent 1
---
isolation: worktree
model: sonnet
---
"Implement feature A in src/features/a/"

# Agent 2
---
isolation: worktree
model: sonnet
---
"Implement feature B in src/features/b/"

Each agent gets its own git worktree. Merge when done.

When to Parallelize

Parallelize when:

  • Problem decomposes into independent sub-problems
  • Multiple solution approaches need exploration (BoT, ToT branching)
  • High confidence required (ensemble methods)
  • Multiple hypotheses need simultaneous testing (HE)
  • Cross-domain analogies need parallel investigation (AT)

Do not parallelize when:

  • Steps have sequential dependencies (use SRC instead)
  • Each step depends on previous results
  • Problem is inherently linear (debugging traces)
  • Merge strategy is undefined

Decision Tree

Is the task decomposable?
├─ NO -> Use sequential execution
└─ YES -> Are sub-tasks independent?
    ├─ NO -> Use sequential with checkpoints
    └─ YES -> Is merge strategy clear?
        ├─ NO -> Define merge strategy first
        └─ YES -> How many sub-tasks?
            ├─ 2-3 -> Parallel tool calls or subagents
            ├─ 4-8 -> Subagents with run_in_background
            └─ 8+  -> Agent teams or DPTS pattern

Advanced Cognitive Patterns

These patterns complement the built-in execution with structured reasoning strategies.

Pattern 1: Dynamic Parallel Tree Search (DPTS)

Efficiency: 2-4x improvement, 70% faster convergence

Adaptive parallel exploration that dynamically allocates resources to promising branches while pruning unpromising ones.

Key Mechanisms:

  • Dynamic worker allocation: more workers on promising branches
  • Adaptive pruning thresholds: adjust based on best-found confidence
  • Early termination: stop when confidence exceeds threshold
  • Resource rebalancing: move workers from exhausted/pruned branches

Integration with ToT:

## DPTS + Tree of Thoughts

### Phase 1: Initial Parallel Expansion
- Spawn N workers for Level 0 branches (N = 5-10)
- Each worker explores one branch independently
- Workers report confidence scores as they complete

### Phase 2: Dynamic Reallocation
- Rank branches by score
- Top 2 branches get 3 workers each for Level 1
- Prune branches below dynamic threshold

### Phase 3: Convergence
- Continue until winning branch > 85% confidence
- OR all branches at Level 4+

### Pruning Threshold Formula
dynamic_threshold = max(0.40, best_confidence - 0.30)

Example:

Level 0: 5 branches, 5 workers (parallel subagents)
├─ Branch A: 75% (3 workers for L1)
├─ Branch B: 68% (2 workers for L1)
├─ Branch C: 52% (1 worker)
├─ Branch D: 48% (1 worker)
└─ Branch E: 35% (PRUNED)

Best found: A.2 at 82% -> New threshold: 52%
-> Branch D PRUNED (48% < 52%)

Pattern 2: Branch-Solve-Merge (BSM)

Decompose problems, solve sub-problems in parallel, merge results. Use when problems partition cleanly.

## Branch Phase
1. Analyze problem structure
2. Identify independent sub-problems
3. Define interfaces between sub-problems

## Solve Phase (parallel subagents)
1. Spawn worker per sub-problem (run_in_background: true)
2. Each worker solves independently
3. Workers report partial solutions

## Merge Phase
1. Collect all partial solutions
2. Apply merge strategy
3. Resolve conflicts
4. Synthesize final solution

Merge Strategies:

StrategyWhen to UseMethod
ConsensusMultiple workers on same problemMajority agreement
VotingCompeting approachesWeighted score aggregation
AggregationComplementary resultsUnion with deduplication
SynthesisConflicting valid resultsDialectical resolution

Pattern 3: Mixture of Agents (MoA)

Layered proposer/aggregator architecture for ensemble confidence.

┌────────────────────────────────────────┐
│            Aggregator Layer             │
│  (Synthesizes proposals, resolves      │
│   conflicts)                           │
└──────────────────┬─────────────────────┘
                   │ Proposals flow up
┌────────────────────────────────────────┐
│            Proposer Layer               │
│  ┌────────┐ ┌────────┐ ┌────────┐      │
│  │Prop 1  │ │Prop 2  │ │Prop 3  │      │
│  │(ToT)   │ │(BoT)   │ │(AT)    │      │
│  └────────┘ └────────┘ └────────┘      │
└────────────────────────────────────────┘

Conflict Resolution:

  • If proposers agree: Boost confidence +5%
  • If 2/3 agree: Use majority, document minority
  • If no agreement: Escalate to DR (Dialectical Reasoning)

Pattern 4: Graph of Thoughts (GoT)

Arbitrary graph-structured reasoning with merge, split, and cycle operations.

OperationDescriptionUse Case
BranchSplit one thought into multipleGenerate alternatives
MergeCombine multiple thoughts into oneSynthesize findings
RefineIterate on a single thoughtImprove solution
BacktrackReturn to previous thoughtError correction
CycleRe-evaluate with new informationIterative improvement
     [Problem]
        │
    ┌───┴───┐
    ▼       ▼
  [A]     [B]
    │       │
    └───┬───┘
        ▼
    [Merged]
        │
        ▼
    [Refined] <── Cycle
        │
        ▼
    [Solution]

Pattern 5: Self-Consistency with RASC

Efficiency: 70% compute reduction vs naive self-consistency

Generate multiple reasoning paths, cluster by rationale similarity, use representative answers.

## Phase 1: Generate K reasoning paths (parallel subagents)
## Phase 2: Cluster paths by rationale similarity
## Phase 3: Select representative from each cluster
## Phase 4: Weighted vote among representatives

Cluster A (size 3): "team autonomy" -> Microservices
Cluster B (size 3): "scalability" -> Microservices
Cluster C (size 2): "simplicity" -> Monolith

Final: Microservices (70% weighted agreement)

Integration with Cognitive Skills

BoT: Parallel Branch Exploration

Spawn 8-10 parallel workers (subagents with run_in_background)
Each explores one approach independently
Pruning after ALL Level 0 complete (static 40% threshold)

ToT: MCTS-Style Search

UCB1(branch) = avg_score + C * sqrt(ln(N) / n_branch)
Run parallel rollouts from each branch (subagents)
Use UCB1 to decide which branches get more rollouts

HE: Parallel Hypothesis Testing

Phase 1: Generate hypotheses
Phase 2: Identify independent evidence (parallel subagents)
Phase 3: Parallel evidence gathering
Phase 4: Synchronized hypothesis update + elimination

AT: Multi-Perspective via MoA

Proposer 1: Technology domain analogies (subagent)
Proposer 2: Nature/biology analogies (subagent)
Proposer 3: Business/economics analogies (subagent)
Aggregator: Cross-analogy synthesis (main session)

Pruning Strategies

PatternThresholdRationale
BoTStatic 40%Conservative breadth
ToTStatic top-1/top-2Aggressive, find single best
DPTSDynamic (best - 30%)Adaptive to landscape
HEEvidence-basedPrune when evidence eliminates
MoAAgreement-basedPrune minority after consensus

Anti-Patterns

  1. Parallelizing sequential dependencies - If step 2 needs step 1's output, don't parallelize
  2. Too many branches - 5-10 at Level 0 is reasonable; 20+ causes diminishing returns
  3. No merge strategy defined - Always know how to combine results before fan-out
  4. Ignoring shared state - Workers must write to isolated paths; merge in fan-in
  5. Parallel everything - Some problems are inherently sequential; accept it

Quick Reference

SituationPatternWhy
Independent file readsParallel tool callsBuilt-in, zero overhead
Independent researchParallel subagentsBackground execution
Coordinated editingAgent teams / worktreesAvoid conflicts
Explore unknown spaceDPTS + BoTDynamic pruning, parallel breadth
Find optimal optionMCTS + ToTSimulation-guided depth
Decomposable problemBSMClean partition and merge
Need ensemble confidenceMoA or RASCMultiple perspectives
Iterative refinementGoTMerge and cycle support
Test hypothesesParallel HEIndependent evidence gathering

Configuration

Note: The configuration below is illustrative — these are conceptual thresholds for reasoning about parallelization, not actual Claude Code configuration settings.

{
  "parallel_execution": {
    "max_workers": 10,
    "worker_timeout_minutes": 30,
    "pruning": {
      "bot_threshold": 0.40,
      "tot_keep_top": 2,
      "dpts_margin": 0.30
    },
    "merge_strategies": {
      "default": "aggregation",
      "conflict_resolution": "weighted_voting",
      "confidence_agreement_boost": 0.05
    }
  }
}

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.