am2rican5:parallel-agent-orchestration
Orchestrate multiple Claude agents working in parallel on a shared codebase with task locking, conflict avoidance, and autonomous work loops. Use when user says "run parallel agents", "orchestrate agents", "multi-agent workflow", "coordinate agents on shared codebase", "parallelize this work", or "run multiple agents simultaneously". Key capabilities include task decomposition, lock-file coordination, git worktree isolation, and branch-per-agent strategies. Do NOT use for single-agent task execution (use task-runner agent instead) or for learning about testing patterns (use test-driven-autonomous-dev instead).
What this skill does
# Parallel Agent Orchestration ## Critical Rules - NEVER spawn parallel agents without explicit user confirmation of the work plan - NEVER allow two agents to work on the same file simultaneously — verify file-level independence first - ALWAYS set up a task-locking mechanism before launching parallel work - ALWAYS verify task independence before parallelizing — if tasks share state, they must run sequentially - WHEN a merge conflict occurs, STOP and ask the user how to resolve — do not auto-resolve - WHEN an agent finishes, it MUST release its lock before picking up new work ## Instructions ### Step 1: Assess Task Decomposability Analyze the work the user wants to parallelize: 1. List all subtasks or work items 2. For each pair of tasks, check: do they touch the same files? Do they depend on each other's output? 3. Classify each task as **independent** (can run in parallel) or **dependent** (must run after another task) 4. Present the dependency graph to the user for confirmation IF all tasks touch the same files or share heavy state → recommend sequential execution and **stop**. IF tasks are clearly independent → proceed to Step 2. ### Step 2: Set Up Task Locking Directory Create a locking mechanism to prevent duplicate work: 1. Create a `_tasks/` directory in the working area (or use an existing task tracking system) 2. Create one file per task in `_tasks/available/` with the task description 3. Apply the lock-file protocol: agents claim tasks before starting, release on completion or failure. See `references/lock-protocol.md` for the full protocol (lock file format, claim-before-start, completion, failure, stale lock recovery). ### Step 3: Configure Conflict Avoidance Strategy Choose an isolation strategy based on the work: **Option A: Git Worktrees (Recommended for file-heavy work)** - Create one worktree per agent: `git worktree add ../agent-<n> -b agent-<n>/work` - Each agent operates in its own worktree on its own branch - Merge results back to main branch after all agents complete - Best when agents touch many files across the codebase **Option B: Branch-Per-Agent (Lightweight)** - Each agent works on its own branch: `agent-<n>/<task-name>` - Agents commit and push to their branches independently - Merge branches sequentially after all agents complete - Best when tasks are well-scoped to specific directories **Option C: File-Level Partitioning (Simplest)** - Assign specific files to each agent upfront — no overlap allowed - Agents work in the same branch but never touch each other's files - Best when tasks map cleanly to distinct files Present options to the user and let them choose. ### Step 4: Set Up the Autonomous Loop Configure each agent to run the autonomous loop: scan for tasks → claim → execute → complete/fail → repeat. See `references/lock-protocol.md` for the full loop definition. Launch agents using Claude Code's Task tool with `run_in_background: true` for parallel execution. Each agent gets: - A clear system prompt describing its role and the task format - The path to the `_tasks/` directory - The conflict avoidance strategy from Step 3 ### Step 5: Monitor Progress While agents run: 1. Periodically check `_tasks/` directory for progress 2. Report: `N completed / M total (K in progress, F failed)` 3. IF any agent has been locked on a task for >30 minutes → flag it 4. IF all tasks are complete or failed → proceed to Step 6 ### Step 6: Merge and Verify After all agents finish: 1. If using worktrees or branches → merge all agent branches back 2. Run the project's test suite to verify nothing broke 3. Report final status: what was completed, what failed, any conflicts ## Examples ### Example: Parallelizing Test Fixes User says: "Fix all failing tests in the auth, billing, and notifications modules" Result: Three agents launched with file-level partitioning, each owning one module directory. All modules fixed in parallel, merge back cleanly. ### Example: Parallel Code Migration User says: "Migrate all API endpoints from Express to Fastify" Result: Shared middleware migrated sequentially first (dependency), then route files parallelized with branch-per-agent strategy. See `references/examples.md` for detailed walkthroughs of both scenarios. ## Troubleshooting ### Merge conflicts after parallel work **Cause:** Two agents edited the same file or adjacent lines. **Solution:** This shouldn't happen if file-level independence was verified in Step 1. Review the dependency analysis. For future runs, use stricter file partitioning. ### Stale lock files **Cause:** An agent crashed or timed out without releasing its lock. **Solution:** Check the lock file timestamp. If >30 minutes old and the agent is no longer running, manually move the lock file to `_tasks/failed/` and reassign the task. ### Two agents picked the same task **Cause:** Race condition — both checked availability simultaneously. **Solution:** The lock-file protocol should prevent this. If it happens, check that agents are using atomic file operations. The second agent should detect the existing lock and skip to the next task. ### Agent stuck in a loop **Cause:** Agent keeps failing the same task and reclaiming it. **Solution:** After 2 failures on the same task, the agent should mark it as `blocked` and move to the next task. Review blocked tasks manually.
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.