| id | b1a8d88f-1096-47b0-aaab-eebc900a17d1 |
|---|---|
| name | parallel-processing |
| version | 1.0.0 |
| level | methodology |
| description | High-speed execution pattern via parallel Map-Reduce, delegating chunks of work to concurrent sub-agents or deterministic parallel scripts. |
This workflow enables high-speed parallel execution of large tasks by sharding work and fanning it out to either concurrent generalist sub-agents (for cognitive tasks) or parallel shell scripts (for deterministic tasks).
Before attempting bulk processing, categorize the nature of the task.
- Cognitive: Does the task require reasoning, synthesis, or making contextual decisions? (e.g., "Analyze architecture", "Refactor variable names based on context", "Security audit").
- Path: Use Concurrent Sub-Agents.
- Deterministic: Is the task purely mechanical with clear rules? (e.g., "Find and replace string X", "Format files", "Lint codebase").
- Path: Use Parallel Shell Scripts (e.g., PowerShell 7
ForEach-Object -Parallel).
- Path: Use Parallel Shell Scripts (e.g., PowerShell 7
Chunk the workload into independent, non-overlapping segments.
- Identify the total scope (e.g., "50 files in
/src"). - Divide the scope into discrete chunks (e.g., 5 chunks of 10 files).
- CRITICAL CONSTRAINT: Ensure no chunks mutate the same files or share mutable state to prevent race conditions.
Execute the appropriate parallel strategy.
Invoke multiple generalist tool calls in a single turn.
- Assign Persona: Prepend each request with a highly specific persona instructions. Example: "Role: Senior Backend Engineer. Task: Audit these 10 files for race conditions..."
- Assign Shard: Pass exact file paths or sub-directories for that specific chunk.
- Execute: Fire all
generalistcalls simultaneously. Wait for the host environment to return all results in the next turn.
Generate and execute a highly optimized script.
- Activate the
powershell-7-efficiencyskill if necessary. - Use
Get-ChildItem ... | ForEach-Object -Parallel { ... }to blast through the workload natively.
After all parallel tasks complete, perform synthesis.
- Review Outputs: Read the returns from all concurrent sub-agents or script logs.
- Handle Failures: Identify any chunks that failed or timed out. Re-run those specific shards if necessary.
- Aggregate: Synthesize the findings or modifications into a single cohesive report or final commit.
- If the context window limit is approached during a massive Fan-In, write the intermediate results to a temporary file in
.gemini/tmp/instead of printing them directly to the conversation.