speckit-parallelize-subagents
Skill18 starsChanged 4 months agoMITView on GitHub
Spec Kit Parallelize It (sub-agents + worktrees variant) — execute a Spec Kit tasks.md with parallel sub-agents, each isolated in its own git worktree branched from the current Spec Kit branch and merged straight back into it on completion. Walks the task list in order and keeps N sub-agents (default 3) continuously busy by batching the [P]-marked tasks into parallel chunks, while running non-[P] tasks as sequential barriers on the lead. Each task is marked [x] in tasks.md the moment its worktree merges cleanly. An optional phase-number argument caps how far to go: parallelize only up to that phase, then stop and hand back so a fresh session can resume — useful when a 15-phase task list would otherwise bloat one context window. Needs no experimental flags. Use after /speckit-tasks has generated a tasks.md AND when you want git-worktree isolation with sub-agents (not the shared-tree Agent Teams engine — for that, use speckit-parallelize-agent-teams). Trigger on "/speckit-parallelize-subagents", "parallelize the spec kit tasks with sub-agents", "run tasks.md in parallel worktrees", "parallelize it with subagents up to phase N".
In this repository67 other files it gives its agents.
- agent-onboardingSkill
- android-backgroundSkill
- android-cliSkill
- android-compose-architectureSkill
- android-compose-componentsSkill
- android-data-layerSkill
- android-di-koinSkill
- android-error-handlingSkill
- android-integration-testingSkill
- android-jacoco-setupSkill
- android-jvm-test-coverageSkill
- android-module-structureSkill
- android-navigationSkill
- android-presentation-mviSkill
- android-preview-figma-verifySkill
- android-ui-screenshot-verifySkill
- android-ui-testingSkill
- android-ui-verifySkill
- android-unit-testingSkill
- android-version-catalogSkill
- architecture-decision-recordSkill
- careful-planningSkill
- compose-adaptive-layoutsSkill
- figma-to-android-vectorSkill
- finalizeSkill
- git-commitSkill
- handoffSkill
- kmp-compose-architectureSkill
- kmp-compose-componentsSkill
- kmp-data-layerSkill
- kmp-di-koinSkill
- kmp-error-handlingSkill
- kmp-integration-testingSkill
- kmp-migration-analyzerSkill
- kmp-module-structureSkill
- kmp-navigationSkill
- kmp-presentation-mviSkill
- kmp-ui-testingSkill
- kmp-unit-testingSkill
- kotlin-coroutinesSkill
- kotlin-flowsSkill
- kotlin-mutation-testingSkill
- openspec-artifact-review-lightSkill
- openspec-artifact-reviewSkill
- project-breakdownSkill
- react-data-layerSkill
- react-error-handlingSkill
- react-integration-testingSkill
- react-presentation-mviSkill
- react-project-structureSkill
- react-routingSkill
- react-screen-architectureSkill
- react-securitySkill
- react-server-stateSkill
- react-ui-componentsSkill
- react-unit-testingSkill
- speckit-parallelize-agent-teamsSkill
- spring-api-layerSkill
- spring-di-configurationSkill
- spring-integration-testingSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 10 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Consider the user input before proceeding (if not empty).
- Very specific: line 36
Run .specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks from the repo root.
- Distinctive: line 38
Read these into your context — you will inline the relevant parts into sub-agent prompts so sub-agents never read them themselves:
- Distinctive: line 44
If any required file is missing, STOP.
- Distinctive: line 68
If there are no pending tasks within the threshold, STOP and report nothing to do.
- Distinctive: line 72
Every worktree branches from this branch and merges back into it, so it must exist and be clean.
- Very specific: line 76
If .gitignore lacks .worktrees/, append it and commit (the Agent tool stores worktrees there).
- Distinctive: line 86
every phase before T's phase is fully done (phases are barriers — Spec Kit's "no user-story work until Foundational completes" etc.), and
- Very specific: line 87
every id in T's (Depends on …) note is done and merged into the base branch, and
- Very specific: line 88
every earlier non-[P] task in the *same phase* is done (a sequential task gates everything after it).
- Very specific: line 101
Use the Agent tool with isolation: "worktree".
- Distinctive: line 132
When a sub-agent reports DONE {id} with its branch, from the base branch run:
- Distinctive: line 148
After a phase's tasks are all done and merged (and nothing is in flight):
- Very specific: line 150
Run build_command on the base branch.
- Very specific: line 151
If the phase contained test tasks, run test_command.
- Very specific: line 152
Commit the phase checkpoint if there's anything staged: git commit -am "chore(phase {N}): checkpoint" (merges are already committed.
- Distinctive: line 158
When you finish the last phase within the threshold (or the whole file):
- Very specific: line 160
Make sure no worktrees are still in flight and every merged task is [x] in tasks.md.
- Distinctive: line 174
If you stopped early because of a threshold, do not start the next phase — hand back so the user can resume fresh.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
User Input
$ARGUMENTSConsider the user input before proceeding (if not empty).
This is the sub-agents + worktrees variant. Each parallel task runs in its own git worktree (via the Agent tool's isolation: "worktree"), branched from the current Spec Kit branch, and you merge it back into that same branch when it finishes. It needs no experimental flags. If you instead want all teammates to share one working tree with no merging (Claude Code Agent Teams), use speckit-parallelize-agent-teams.
You are the coordinator. You parse the task list, dispatch worktree sub-agents, merge their branches back, keep them busy, and own tasks.md as the single source of truth. Sub-agents do the implementation work; you schedule, merge, gate, and record.
Step 0: Parse the invocation
From $ARGUMENTS, extract two optional values:
- agents — the max number of concurrent sub-agents. Look for
agents=N,workers=N,N agents, or a bare "use N". Default 3. This is a hard cap: never run more than this many sub-agents at once. - phase threshold — the last phase to execute. Look for
phase=P,through P,until phase P,up to phase P. Default: none → execute every phase. If a phase number is given, execute phases1..Pinclusive, then stop and hand back (Step 7). Only honor a threshold when it is given explicitly; otherwise run the whole file.
Any other text is free-form guidance — keep it in mind.
Step 1: Discover and load context
- Run
.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasksfrom the repo root. If it is missing or returns non-zero, STOP and report. - Parse the JSON for
FEATURE_DIR. Read these into your context — you will inline the relevant parts into sub-agent prompts so sub-agents never read them themselves:
FEATURE_DIR/tasks.md(required)FEATURE_DIR/spec.md(required)FEATURE_DIR/plan.md(required).specify/memory/constitution.md(if present)
If any required file is missing, STOP.
- From
plan.md, extractbuild_commandandtest_command. If either is missing, ask the user before proceeding.
Step 2: Parse tasks.md into a schedulable graph
Walk tasks.md top to bottom. For each task line - [ ] TNNN ... capture:
- id (
T044), status ([ ]pending /[x]done), and skip any removed task (struck through,~~T052~~, or marked[REMOVED]). - parallelizable —
[P]present right after the id. Spec Kit's contract: a[P]task touches different files and has no dependency on an incomplete task. That guarantee is what lets independent worktrees merge back without conflicts. - phase — the enclosing
## Phase N:header and its kind (Setup / Foundational / User Story / Polish-or-Cross-Cutting). - explicit dependencies — ids named in a
(Depends on T0xx)note. A[P]task can still depend on an earlier task in its own group (e.g.T024 [P] (Depends on T023)); honor that — see "intra-batch dependencies" below. - has tests — whether the phase contains any test task (used to decide whether to run
test_commandat its checkpoint).
Report the parse:
Parsed tasks.md — engine: sub-agents + worktrees, agents: {N}, threshold: {phase P | none}
- Phase 1 Setup: {n} tasks ({p} parallel)
- Phase 2 Foundational: {n} tasks ({p} parallel)
- Phase 3 US1: {n} tasks ({p} parallel)
...
Executing phases 1..{P or last}.If there are no pending tasks within the threshold, STOP and report nothing to do.
Step 3: Prepare the Spec Kit branch
Every worktree branches from this branch and merges back into it, so it must exist and be clean.
git rev-parse --abbrev-ref HEAD. If onmain/master/trunk, creategit checkout -b speckit/<feature-slug>. Otherwise stay. Remember this as the base branch — all worktrees are created from it and all merges land on it.git status --porcelain. If dirty, STOP and report uncommitted changes.- If
.gitignorelacks.worktrees/, append it and commit (the Agent tool stores worktrees there).
Step 4: Execute phase by phase, keeping N sub-agents busy
Process phases in order, 1 through the threshold (or the last phase). For each phase, schedule its tasks as a small dependency graph and keep up to agents worktree sub-agents in flight at all times that there is runnable [P] work.
Readiness rule (recompute after every merge)
A pending, non-removed task T is ready when:
- every phase before T's phase is fully done (phases are barriers — Spec Kit's "no user-story work until Foundational completes" etc.), and
- every id in T's
(Depends on …)note is done and merged into the base branch, and - every earlier non-
[P]task in the same phase is done (a sequential task gates everything after it).
Among ready tasks:
[P]tasks run concurrently, each in its own worktree. Dispatch ready[P]tasks to sub-agents up to theagentscap. As each sub-agent finishes, merge it (below), mark the task, and immediately dispatch the next ready[P]task — that "refill on completion" loop is what keeps every agent as busy as it can be.- A non-
[P]task is a barrier. It may only start when nothing is in flight (let all worktrees merge first), and nothing else starts until it finishes. Run barrier tasks yourself, on the base branch in the main working tree — no worktree, no merge. (Setup and Foundational phases are often entirely sequential; you may run those phases on the base branch directly.)
Intra-batch dependencies: if a ready [P] task depends on another task in the same batch (e.g. T024 depends on T023), do NOT run them in two separate worktrees at once — the second worktree wouldn't contain the first's changes. Either give both to one sub-agent as an ordered chunk in a single worktree, or run the dependency first and only mark the dependent ready in the next round (after the dependency merges).
Keeping agents busy with the Agent tool: dispatch each worktree sub-agent with isolation: "worktree" and run_in_background: true, so you are re-invoked as each one completes and can merge + refill individually rather than waiting for a whole batch. If you prefer simplicity, a batch-and-wait loop (dispatch up to N, wait for all, merge all, refill) is acceptable — it just lets a fast agent idle until its batch-mates finish.
Dispatching a task to a worktree sub-agent
Use the Agent tool with isolation: "worktree". Give each sub-agent a self-contained prompt — it doesn't share your conversation, so inline everything it needs:
Implement Spec Kit task {id}: {full task line text}.
You are running inside a git worktree branched from the Spec Kit branch; your working
directory is the worktree root and all paths are relative to it. Touch ONLY the file
path(s) named in this task. Do not edit tasks.md. Commit your work in this worktree.
## Story / feature context
{paste the relevant User Story section from spec.md, or the phase's goal for Setup/Foundational/Polish}
## Technical context
{paste tech stack, project structure, paths, and conventions from plan.md}
## Constitution
{paste constitution.md, or omit this heading if there is none}
## Build command
{build_command}
## Rules
- Do exactly this task (and the minimal wiring it requires: imports, DI, nav, build files).
- If the task list pairs a test with the code it covers and both are in your chunk, write the test first.
- Run the build command for the parts you touched if feasible. Then commit with: feat({id}): {short summary}.
- Report "DONE {id}" with your branch name and a one-line summary, or "BLOCKED {id}: {what you need}". After 3 failed build attempts, report BLOCKED rather than thrash.
- If the inlined context is insufficient, report BLOCKED naming exactly what's missing. Do NOT read spec.md, plan.md, constitution.md, or tasks.md, and do not touch files outside this task.Merging a finished worktree (you own the base branch and tasks.md)
When a sub-agent reports DONE {id} with its branch, from the base branch run:
git merge <agent-branch> --no-edit- Clean merge → flip
- [ ] {id}to- [x] {id}intasks.md. Because the lead ownstasks.mdand sub-agents never touch it, there is one authoritative record. - Conflict in
tasks.mdonly (a sub-agent shouldn't touch it, but defensively):git checkout --ours tasks.md,git add tasks.md, continue the merge. - Conflict in code files: this means two tasks that were supposed to be
[P]/file-disjoint overlapped. STOP and report which task ids and files conflict — don't guess a resolution.
On BLOCKED, do not merge; leave the task [ ], note the reason, and keep scheduling the rest. A blocked task's dependents simply never become ready. The sub-agent's branch stays available for inspection.
Because each new worktree is created from the updated base branch, later tasks automatically see everything merged before them.
Phase checkpoint
After a phase's tasks are all done and merged (and nothing is in flight):
- Run
build_commandon the base branch. If it fails, STOP and report which phase/tasks/merge is implicated. - If the phase contained test tasks, run
test_command. If it fails, STOP and report. - Commit the phase checkpoint if there's anything staged:
git commit -am "chore(phase {N}): checkpoint"(merges are already committed; this just captures any lead-run barrier work).
Then move to the next phase.
Step 5: Threshold reached or all phases done — hand back
When you finish the last phase within the threshold (or the whole file):
- Make sure no worktrees are still in flight and every merged task is
[x]intasks.md. - Report:
Done through Phase {P or last}.
- Tasks completed/merged: {done}/{attempted} (blocked: {list ids + reasons, or "none"})
- Build: PASS Tests: PASS (or "n/a")
- Branch: speckit/<slug> Last commit: {hash}
{If a threshold stopped you early:}
- Stopped at the Phase {P} threshold. Remaining: Phases {P+1}..{last}.
Resume in a FRESH session with: /speckit-parallelize-subagents phase={next milestone}
(a new session keeps the next chunk's context clean — that's the point of the threshold).If you stopped early because of a threshold, do not start the next phase — hand back so the user can resume fresh.
Failure handling (any step)
- Build/test failure at a checkpoint → STOP, name the phase, tasks, and the merge that introduced it; leave work committed up to the prior passing checkpoint.
- Code merge conflict between two "parallel" tasks → STOP and report the ids/files; they were not actually file-disjoint.
- A sub-agent goes unresponsive or BLOCKED → leave its task
[ ], keep scheduling everything that doesn't depend on it; never merge or mark a blocked task done. Its branch remains for the user to inspect.
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
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.

