/octo:flow-parallelfrom octo
Decomposes large changes, migrations, or multi-issue fixes into parallel work packages with quality gates. Useful for coordinating complex implementations across multiple independent streams.
Ships in octo. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
DO NOT call Skill() again. DO NOT load any more skills. Execute directly.
This skill uses ENFORCED execution mode. You MUST follow this exact 7-step sequence.
Architectural Principle: Each work package runs in an independent Claude Code process. The launcher explicitly loads the verified Octopus plugin directory so each worker has its agents, workflow skills, and quality gates, even when the parent uses Codex.
Ask via AskUserQuestion BEFORE any other action.
You MUST gather these inputs from the user — without scope, count, and dependency answers, the decomposition will be generic and produce overlapping work packages that cause merge conflicts:
AskUserQuestion with these questions:
1. **Compound task**: What compound task should be decomposed?
- Use inline args if provided (e.g., /octo:parallel "build auth system")
- If no args: ask "What compound task should I decompose into parallel work packages?"
2. **Work package count**: How many work packages?
- Options: "3 (Recommended)", "4", "5", "Custom (up to 10)"
- Default: 3-5 is optimal
3. **Dependencies**: Are the work packages independent?
- "Fully independent - no dependencies between packages (Recommended)"
- "Some dependencies - packages may need to share interfaces"
- "Sequential dependencies - packages must complete in order"
If user provided a description inline with the command (e.g., /octo:parallel build a full auth system with OAuth, RBAC, and audit logging), use that as the task description but STILL ask remaining questions (count, dependencies).
If user says "skip" for any question, use defaults: 3 work packages, fully independent.
DO NOT PROCEED TO STEP 2 until questions answered.
MANDATORY: You MUST use the Bash tool to run this provider check BEFORE displaying the banner. Do NOT skip it. Do NOT assume availability.
bash "${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${HOME}/.claude-octopus/plugin}}/scripts/helpers/check-providers.sh"
Use the ACTUAL results below. PROHIBITED: Showing only "🔵 Claude: Available ✓" without listing all providers.
Display this banner with real provider status BEFORE any decomposition:
🐙 CLAUDE OCTOPUS ACTIVATED - Team of Teams Mode
Parallel Phase: Decomposing compound task into N independent work packages
Architecture:
Main (this session) - Orchestrator: decompose, launch, monitor, aggregate
WP-1..WP-N (claude -p) - Independent workers with full plugin capabilities
Each worker:
- Runs as independent claude -p process in its own git worktree
- Loads full Octopus plugin
- Has own context, tools, and quality gates
- Produces output.md + exit-code
- Tracked in agent registry (~/.claude-octopus/agents/registry.json)
Estimated Time: 5-15 minutes (depending on task complexity)
DO NOT PROCEED TO STEP 3 until banner displayed.
Before decomposing, read any prior context:
# Initialize state if needed
if [[ -d ".octo" ]]; then
echo "Found existing .octo/ state directory"
else
echo "No prior .octo/ state found - starting fresh"
fi
# Check for prior discover/spec context
if [[ -f ".octo/STATE.md" ]]; then
echo "Prior state found:"
cat .octo/STATE.md
fi
if [[ -f ".octo/PROJECT.md" ]]; then
echo "Prior project context found:"
cat .octo/PROJECT.md
fi
Use any prior context (discover findings, spec definitions, project state) to inform the WBS decomposition.
DO NOT PROCEED TO STEP 4 until state read.
Claude analyzes the compound task and produces a Work Breakdown Structure.
Decomposition rules:
Create the coordination directory and WBS:
# Create parallel coordination directory
mkdir -p .octo/parallel
# Write wbs.json
cat > .octo/parallel/wbs.json << 'WBSEOF'
{
"task": "<compound task description>",
"created": "<ISO timestamp>",
"work_packages": [
{
"id": "WP-1",
"name": "<work package name>",
"scope": "<what this WP covers>",
"expected_outputs": ["<list of files this WP should produce>"],
"dependencies": [],
"wave": 1,
"branch": "<a branch name unique to this work package>",
"status": "pending"
}
]
}
WBSEOF
You MUST write actual WBS content based on your analysis of the compound task. The JSON above is a template — populate it with real decomposition. Template or placeholder WBS produces vague instructions that agents interpret differently, causing duplicate work or missed scope.
Validation gate: wbs_generated — Verify .octo/parallel/wbs.json has a nonempty list of uniquely identified work packages:
# Validate WBS was created
if [[ ! -f ".octo/parallel/wbs.json" ]]; then
printf '%s\n' 'WBS validation: FAILED - file not found' >&2
exit 1
fi
python3 -I - <<'PY_WBS' || exit 1
import json
import re
import sys
def reject_constant(value):
raise ValueError(f"{value} is not a valid JSON value")
try:
with open(".octo/parallel/wbs.json", encoding="utf-8") as wbs:
document = json.load(wbs, parse_constant=reject_constant)
except (OSError, RecursionError, ValueError):
sys.exit("WBS validation: FAILED - could not read valid JSON")
packages = document.get("work_packages") if isinstance(document, dict) else None
if not isinstance(packages, list) or not packages:
sys.exit("WBS validation: FAILED - work_packages must be a nonempty list")
package_ids = set()
for package in packages:
package_id = package.get("id") if isinstance(package, dict) else None
if not isinstance(package_id, str) or not re.fullmatch(r"WP-[1-9][0-9]*", package_id):
sys.exit("WBS validation: FAILED - each work package needs a WP-N ID")
if package_id in package_ids:
sys.exit(f"WBS validation: FAILED - duplicate package ID {package_id}")
package_ids.add(package_id)
PY_WBS
printf '%s\n' 'WBS validation: PASSED'
Stop before Step 4.5 if WBS validation fails.
After generating the WBS but BEFORE dependency validation, cross-check the decomposition with a second model. Single-model decomposition often produces work packages with hidden dependencies, ambiguous interface contracts, or scope gaps that cause merge conflicts and duplicated work.
If an external provider is available, dispatch the WBS for adversarial review through Octopus routing:
WBS_CONTENT=$(<".octo/parallel/wbs.json")
review_provider=""
command -v codex >/dev/null 2>&1 && review_provider="codex"
[[ -z "$review_provider" ]] && command -v agy >/dev/null 2>&1 && review_provider="agy"
if [[ -n "$review_provider" ]]; then
"${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${HOME}/.claude-octopus/plugin}}/scripts/orchestrate.sh" spawn "$review_provider" \
"Review this Work Breakdown Structure for a parallel execution pipeline. Your job is to find problems BEFORE agents start working.
1. What DEPENDENCIES between work packages were missed? (e.g., WP-2 needs a type definition from WP-1 but doesn't declare it)
2. What INTERFACE CONTRACTS are ambiguous? (e.g., two WPs will create conflicting exports, or expect different API signatures)
3. Do any work packages OVERLAP in scope? (e.g., both WP-1 and WP-3 might modify the same file)
4. Are there GAPS — things no work package covers?
WBS:
${WBS_CONTENT}" 2>/dev/null || true
fi
After receiving the challenge:
dependencies arraySkip with --fast or when user explicitly requests speed over thoroughness.
If any work package has non-empty dependencies, validate the dependency graph and assign wave numbers.
Skip this step if all work packages have "dependencies": [] — they all get wave 1 (backward compatible).
Run dependency validation and wave assignment:
python3 << 'DEPEOF'
import json, sys
with open('.octo/parallel/wbs.json') as f:
wbs = json.load(f)
packages = wbs['work_packages']
ids = {wp['id'] for wp in packages}
deps = {wp['id']: wp.get('dependencies', []) for wp in packages}
# Check for missing references
errors = []
for wp_id, wp_deps in deps.items():
for dep in wp_deps:
if dep not in ids:
errors.append(f"WP {wp_id} depends on unknown {dep}")
if errors:
print("DEPENDENCY VALIDATION: FAILED")
for e in errors:
print(f" ERROR: {e}")
sys.exit(1)
# Cycle detection (DFS)
WHITE, GRAY, BLACK = 0, 1, 2
color = {wp_id: WHITE for wp_id in ids}
def has_cycle(node, path):
color[node] = GRAY
for dep in deps[node]:
if color[dep] == GRAY:
cycle = path[path.index(dep):] + [dep]
return cycle
if color[dep] == WHITE:
result = has_cycle(dep, path + [dep])
if result:
return result
color[node] = BLACK
return None
for wp_id in ids:
if color[wp_id] == WHITE:
cycle = has_cycle(wp_id, [wp_id])
if cycle:
print(f"DEPENDENCY VALIDATION: FAILED - Cycle detected: {' -> '.join(cycle)}")
sys.exit(1)
# Topological sort and wave assignment
waves = {}
assigned = set()
def get_wave(wp_id):
if wp_id in waves:
return waves[wp_id]
if not deps[wp_id]:
waves[wp_id] = 1
return 1
max_dep_wave = max(get_wave(d) for d in deps[wp_id])
waves[wp_id] = max_dep_wave + 1
return waves[wp_id]
for wp_id in ids:
get_wave(wp_id)
# Update WBS with wave assignments
for wp in packages:
wp['wave'] = waves[wp['id']]
with open('.octo/parallel/wbs.json', 'w') as f:
json.dump(wbs, f, indent=2)
max_wave = max(waves.values())
print(f"DEPENDENCY VALIDATION: PASSED")
print(f"Waves assigned: {max_wave}")
for w in range(1, max_wave + 1):
wave_wps = [wp_id for wp_id, wave in waves.items() if wave == w]
print(f" Wave {w}: {', '.join(wave_wps)}")
DEPEOF
If validation fails: Report the error to the user and STOP. Do not proceed with invalid dependencies.
DO NOT PROCEED TO STEP 5 until dependencies validated (or step skipped for independent WPs).
Before generating any launch scripts, select the shared base and resolve it once.
Use the printed BASE_COMMIT in every script, including later waves and retries.
In a fresh shell, restore that exact value rather than resolving the ref again.
New package branches start at that commit. Retries retain their later commits
and edits when the existing branch descends from the frozen base; otherwise stop
without resetting or discarding their work.
# Freeze the selected base once before rendering any worker launchers.
: "${BASE_REF:?Select the shared base ref before generating workers}"
BASE_COMMIT=$(git rev-parse --verify "$BASE_REF^{commit}") || exit 1
printf 'BASE_COMMIT=%s\n' "$BASE_COMMIT"
For each work package in the WBS, create an instructions file and a launch script.
Replace <base-ref> below with that same full BASE_COMMIT, never a branch name.
For each WP-N, create:
instructions.mdmkdir -p ".octo/parallel/WP-N"
cat > ".octo/parallel/WP-N/instructions.md" << 'INSTREOF'
# Work Package WP-N: <name>
## Task
<Clear description of what this work package must accomplish>
## Scope Boundaries
- IN SCOPE: <what this WP covers>
- OUT OF SCOPE: <what other WPs handle — explicit boundaries>
## Expected Output
- Files to create/modify: <explicit file paths — MANDATORY>
- Location: <where outputs go in the project>
## Integration Contract
- This WP produces: <what downstream consumers can expect>
- This WP consumes: <what it needs from the project, NOT from other WPs>
## Quality Requirements (MANDATORY)
- Code must compile/parse without errors
- Follow existing project conventions (naming, structure, patterns)
- Run any existing tests related to your changes — do NOT skip tests
- Run the project linter if one exists (eslint, ruff, golangci-lint, etc.)
- No `type: ignore`, `@ts-ignore`, `any` casts, or suppression comments unless the existing code already uses them
- No placeholder code — no `TODO`, `FIXME`, or stub implementations
- Verify your changes work by running or testing them before completing
- If you break existing tests, fix them — do not delete or skip them
## Committing (MANDATORY if you changed any file)
- Commit your work to this package's own branch before you finish. The worktree is removed once
your commit exists and the tree is clean. Uncommitted work is retained for recovery.
- Stage explicit paths. Never `git add -A` or `git add .` — the coordination directory and other
packages' stray files must not enter your commit.
## Dependency Context
- This WP depends on: <list of dependency WP IDs, or "none">
- Outputs from completed dependencies will be provided below when available
INSTREOF
CRITICAL: Every instructions.md MUST contain explicit file paths — parallel agents interpret vague scope independently, so without explicit paths two WPs may modify the same file or leave gaps between them. Vague descriptions like "create the auth module" are PROHIBITED — specify exact paths like src/auth/oauth.ts.
launch.shv8.44.0: Each work package runs in its own git worktree for full file isolation. This prevents write contention when multiple agents modify files simultaneously.
cat > ".octo/parallel/WP-N/launch.sh" << 'LAUNCHEOF'
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
PROJECT_ROOT="<absolute-project-root-path>"
WP_ID="WP-N"
WP_BRANCH="<wp-branch-name>"
BASE_REF="<base-ref>"
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${HOME}/.claude-octopus/plugin}}"
REGISTRY=""
# Every exit path must leave exit-code and .done behind, or the orchestrator's
# monitor loop waits for a marker that never arrives and only the wave timeout
# ends the run.
fail() {
echo "${1}" >&2
if [[ -x "$REGISTRY" ]]; then
"$REGISTRY" update "$WP_ID" --status failed --error "${1}" 2>/dev/null || true
fi
echo "${2:-1}" > "$SCRIPT_DIR/exit-code"
touch "$SCRIPT_DIR/.done"
exit "${2:-1}"
}
# A retry must not inherit the previous run's completion status.
rm -f "$SCRIPT_DIR/.done" "$SCRIPT_DIR/exit-code" || fail "ERROR: cannot clear completion markers"
# Resolve plugin inputs before creating the package worktree.
RESOLVED_PLUGIN_ROOT="$(cd -- "$PLUGIN_ROOT" 2>/dev/null && pwd -P)" ||
fail "ERROR: cannot resolve the Octopus plugin directory"
jq -e '.name == "octo"' "$RESOLVED_PLUGIN_ROOT/.claude-plugin/plugin.json" >/dev/null 2>&1 ||
fail "ERROR: cannot verify the Octopus plugin manifest at $RESOLVED_PLUGIN_ROOT"
REGISTRY="$RESOLVED_PLUGIN_ROOT/scripts/agent-registry.sh"
# Hook environments can otherwise redirect Git away from PROJECT_ROOT.
while IFS= read -r git_var; do unset "$git_var"; done < <(git rev-parse --local-env-vars)
# v8.44.0: Create isolated worktree for this work package.
# Each package checks out its OWN branch. git refuses to check one branch out
# in two worktrees, so reusing the session branch fails every package after the
# first, and a shared branch would also pile unrelated packages onto one ref.
cd "$PROJECT_ROOT" || fail "ERROR: cannot enter $PROJECT_ROOT"
PROJECT_ROOT="$(pwd -P)"
RESOLVED_BASE=$(git rev-parse --verify "$BASE_REF^{commit}") || fail "ERROR: shared base commit is unavailable"
[[ "$BASE_REF" == "$RESOLVED_BASE" ]] || fail "ERROR: shared base must be the frozen full commit ID"
WORKTREE_DIR="${PROJECT_ROOT}/../.octo-worktree-${PROJECT_ROOT##*/}-${WP_ID}"
COMMON_DIR="$(git rev-parse --git-common-dir)" || fail "ERROR: not a Git repository"
COMMON_DIR="$(cd "$COMMON_DIR" && pwd -P)" || fail "ERROR: cannot resolve repository identity"
git worktree prune 2>/dev/null || true
if [[ -d "$WORKTREE_DIR" ]]; then
# Retry: reuse the existing worktree instead of discarding the work in it.
cd "$WORKTREE_DIR" || fail "ERROR: cannot enter $WORKTREE_DIR"
else
git worktree add -b "$WP_BRANCH" "$WORKTREE_DIR" "$BASE_REF" \
> "$SCRIPT_DIR/worktree.log" 2>&1 ||
git worktree add "$WORKTREE_DIR" "$WP_BRANCH" \
>> "$SCRIPT_DIR/worktree.log" 2>&1 ||
fail "ERROR: failed to create worktree at $WORKTREE_DIR (see worktree.log)"
fi
# Reject stale directories from another project, branch, or non-worktree path.
cd "$WORKTREE_DIR" || fail "ERROR: cannot enter $WORKTREE_DIR"
WORKTREE_DIR="$(pwd -P)"
validate_worktree() {
local worktree_top worktree_common_dir worktree_branch
worktree_top="$(git -C "$WORKTREE_DIR" rev-parse --show-toplevel)" || fail "ERROR: not a Git worktree; retained $WORKTREE_DIR"
worktree_top="$(cd "$worktree_top" && pwd -P)" || fail "ERROR: cannot resolve worktree root; retained $WORKTREE_DIR"
worktree_common_dir="$(git -C "$WORKTREE_DIR" rev-parse --git-common-dir)" || fail "ERROR: cannot identify worktree repository; retained $WORKTREE_DIR"
worktree_common_dir="$(cd "$WORKTREE_DIR" && cd "$worktree_common_dir" && pwd -P)" || fail "ERROR: cannot resolve worktree repository; retained $WORKTREE_DIR"
worktree_branch="$(git -C "$WORKTREE_DIR" symbolic-ref --quiet --short HEAD)" || fail "ERROR: worktree has detached HEAD; retained $WORKTREE_DIR"
[[ "$worktree_top" == "$WORKTREE_DIR" && "$worktree_common_dir" == "$COMMON_DIR" && \
"$worktree_branch" == "$WP_BRANCH" ]] || fail "ERROR: worktree repository or branch does not match this package; retained $WORKTREE_DIR"
git -C "$WORKTREE_DIR" merge-base --is-ancestor "$BASE_REF" HEAD || fail "ERROR: worktree does not include the frozen base commit; retained $WORKTREE_DIR"
}
validate_worktree
# Register agent in registry
if [[ -x "$REGISTRY" ]]; then
"$REGISTRY" register "$WP_ID" "$WP_BRANCH" "$WORKTREE_DIR" 2>/dev/null || true
fi
cd "$WORKTREE_DIR" || fail "ERROR: cannot enter $WORKTREE_DIR"
unset CLAUDECODE
# v8.32.0: Credential isolation — work packages don't need provider keys
unset OPENAI_API_KEY AGY_AUTH_TOKEN ANTIGRAVITY_API_KEY OPENROUTER_API_KEY PERPLEXITY_API_KEY
# No `set -e` around this call: a non-zero claude -p must still record its exit
# code and .done rather than abort the script before either is written.
claude -p --plugin-dir "$RESOLVED_PLUGIN_ROOT" < "$SCRIPT_DIR/instructions.md" > "$SCRIPT_DIR/output.md" 2>"$SCRIPT_DIR/agent.log"
EXIT_CODE=$?
# The worker can change branches, detach HEAD or replace the repository. Admit
# the resulting worktree again before reporting completion or removing it.
validate_worktree
echo $EXIT_CODE > "$SCRIPT_DIR/exit-code"
# Update agent registry with completion status
if [[ -x "$REGISTRY" ]]; then
if [[ "$EXIT_CODE" -eq 0 ]]; then
"$REGISTRY" update "$WP_ID" --status done 2>/dev/null || true
else
"$REGISTRY" update "$WP_ID" --status failed --error "Exit code $EXIT_CODE" 2>/dev/null || true
fi
fi
# Remove only clean worktrees with commits on the package branch. Git can
# remove a worktree containing ignored files even without a force flag.
LOCAL_FILES="$(git -C "$WORKTREE_DIR" status --porcelain --untracked-files=normal --ignored 2>/dev/null)" ||
fail "ERROR: cannot inspect worktree status; retained $WORKTREE_DIR"
# Status and worktree removal both honor index flags that can hide local work.
# Read NUL-delimited entries so unusual filenames cannot hide a flagged entry.
HIDDEN_INDEX="$(python3 - "$WORKTREE_DIR" <<'PY'
import subprocess
import sys
entries = subprocess.check_output([
'git', '-C', sys.argv[1], 'ls-files', '-v', '-z',
]).split(b'\0')
print(int(any(entry[:1].upper() == b'S' or entry[:1].islower() for entry in entries)))
PY
)" || fail "ERROR: cannot inspect worktree index flags; retained $WORKTREE_DIR"
COMMITS="$(git -C "$WORKTREE_DIR" rev-list --count "$BASE_REF..HEAD" 2>/dev/null)" ||
fail "ERROR: cannot inspect worktree commits; retained $WORKTREE_DIR"
echo "$COMMITS" > "$SCRIPT_DIR/commit-count"
cd "$PROJECT_ROOT"
if [[ "$HIDDEN_INDEX" == 1 ]]; then
echo "KEPT $WORKTREE_DIR: index flags may hide uncommitted work on $WP_BRANCH" \
>> "$SCRIPT_DIR/agent.log"
elif [[ -z "$LOCAL_FILES" && "$COMMITS" -gt 0 ]]; then
git worktree remove "$WORKTREE_DIR" 2>/dev/null ||
fail "ERROR: cannot remove worktree; retained $WORKTREE_DIR"
elif [[ -n "$LOCAL_FILES" ]]; then
echo "KEPT $WORKTREE_DIR: uncommitted changes or ignored files present on $WP_BRANCH" \
>> "$SCRIPT_DIR/agent.log"
else
echo "KEPT $WORKTREE_DIR: no commits beyond $BASE_REF on $WP_BRANCH" \
>> "$SCRIPT_DIR/agent.log"
fi
touch "$SCRIPT_DIR/.done"
LAUNCHEOF
chmod +x ".octo/parallel/WP-N/launch.sh"
You MUST replace all three placeholders: <absolute-project-root-path> with the actual project
root (use pwd), <wp-branch-name> with this package's own branch from the WBS, and <base-ref>
with the full BASE_COMMIT printed above. Embed that same commit ID in every
package and wave, never a moving ref such as origin/<trunk>.
Worktree fallback: if git worktree is unavailable (shallow clone, detached HEAD), the launch
script fails closed and records a non-zero exit code plus .done, so the wave reports the failure
instead of hanging. A worktree that still holds uncommitted changes or ignored files is kept, and the
reason is appended to agent.log.
Worktrees with skip-worktree or assume-unchanged index flags are also retained,
because Git status can hide local edits or deletions under those flags.
Validation gate: instructions_written — Verify all instruction files exist:
# Count WPs from wbs.json
if ! wp_count=$(python3 -I - 2>/dev/null <<'PY_WP_COUNT'
import json
import sys
with open(".octo/parallel/wbs.json", encoding="utf-8") as wbs_file:
wbs = json.load(wbs_file)
packages = wbs.get("work_packages") if isinstance(wbs, dict) else None
if not isinstance(packages, list) or not packages:
sys.exit(1)
print(len(packages))
PY_WP_COUNT
); then
printf '%s\n' 'Instruction files validation: FAILED - could not read a nonempty work package list' >&2
exit 1
fi
# Verify each WP has instructions.md and launch.sh
missing=0
for ((i = 1; i <= wp_count; i++)); do
if [[ ! -f ".octo/parallel/WP-$i/instructions.md" ]]; then
echo "MISSING: .octo/parallel/WP-$i/instructions.md"
missing=$((missing + 1))
fi
if [[ ! -f ".octo/parallel/WP-$i/launch.sh" ]]; then
echo "MISSING: .octo/parallel/WP-$i/launch.sh"
missing=$((missing + 1))
fi
done
if [[ "$missing" -eq 0 ]]; then
echo "Instruction files validation: PASSED ($wp_count work packages)"
else
echo "Instruction files validation: FAILED ($missing files missing)" >&2
exit 1
fi
DO NOT PROCEED TO STEP 6 until all instruction files validated.
Launch work packages in dependency waves. Wave 1 runs first; Wave 2 starts only after Wave 1 completes (with outputs injected); and so on.
If all WPs are in Wave 1 (no dependencies), this behaves identically to the original launch — backward compatible.
Before starting any worker, check the declared output files in the saved work breakdown. Two packages can share a file only when one depends on the other, directly or through another package. The same rule applies when one output file would occupy a directory needed by another output. A later wave alone does not declare a dependency.
Wave-based launch sequence:
PROJECT_ROOT="$(pwd)"
WBS_FILE=".octo/parallel/wbs.json"
# Capture the plan once. Step 5 may have run in a different shell.
WAVE_PLAN=$(python3 - "$WBS_FILE" <<'WAVEPLAN'
import json
import os
from pathlib import Path
import re
import sys
try:
with open(sys.argv[1], encoding="utf-8") as source:
packages = json.load(source)["work_packages"]
if not isinstance(packages, list) or not packages:
raise ValueError("work_packages must be a nonempty list")
plan = {}
outputs = {}
for package in packages:
package_id = package["id"]
wave = package.get("wave", 1)
dependencies = package.get("dependencies", [])
if not isinstance(package_id, str) or not re.fullmatch(r"WP-[1-9][0-9]*", package_id):
raise ValueError("each work package needs a WP-N ID")
if package_id in plan:
raise ValueError(f"duplicate package ID {package_id}")
if type(wave) is not int or not 1 <= wave <= len(packages):
raise ValueError(f"{package_id} has an invalid wave")
if not isinstance(dependencies, list) or any(not isinstance(dep, str) for dep in dependencies):
raise ValueError(f"{package_id} has an invalid dependency list")
paths = package.get("expected_outputs", [])
if not isinstance(paths, list) or any(not isinstance(path, str) or not path.strip() for path in paths):
raise ValueError(f"{package_id} needs a list of output file paths")
plan[package_id] = (wave, dependencies)
outputs[package_id] = {os.path.realpath(path) for path in paths}
for package_id, (wave, dependencies) in plan.items():
if any(dep not in plan or plan[dep][0] >= wave for dep in dependencies):
raise ValueError(f"{package_id} needs all dependencies in earlier waves")
prerequisites = {}
owners_by_output = {}
for package_id in sorted(plan, key=lambda item: plan[item][0]):
dependencies = plan[package_id][1]
required = set(dependencies)
for dependency in dependencies:
required.update(prerequisites[dependency])
prerequisites[package_id] = required
for path in sorted(outputs[package_id]):
owners_by_output.setdefault(path, []).append(package_id)
for path, owners in owners_by_output.items():
# Check path components so adjacent names such as lib and lib-old stay independent.
for output in (Path(path), *Path(path).parents):
for owner in owners_by_output.get(str(output), ()):
for package_id in owners:
if (owner == package_id or owner in prerequisites[package_id]
or package_id in prerequisites[owner]):
continue
raise ValueError(
f"{owner} declares {os.path.relpath(output)!r} and {package_id} "
f"declares {os.path.relpath(path)!r} without a dependency between them"
)
except (OSError, KeyError, TypeError, ValueError) as error:
sys.exit(f"Cannot launch Parallel workers: invalid work breakdown: {error}")
print(max(wave for wave, _ in plan.values()))
for package_id, (wave, dependencies) in plan.items():
print(wave, package_id, *dependencies)
WAVEPLAN
) || exit 1
read -r MAX_WAVE <<< "$WAVE_PLAN"
TIMEOUT=600 # 10 minutes per wave
echo "Executing $MAX_WAVE wave(s)..."
for ((WAVE=1; WAVE<=MAX_WAVE; WAVE++)); do
echo ""
echo "=== WAVE $WAVE ==="
echo ""
WAVE_WPS=$(awk -v wave="$WAVE" 'NR > 1 && $(1) == wave { print $(2) }' <<< "$WAVE_PLAN") || exit 1
# Validate every dependency before modifying instructions or launching this wave.
for WP_ID in $WAVE_WPS; do
DEPS=$(awk -v id="$WP_ID" '$(2) == id { for (i = 3; i <= NF; i++) print $i }' <<< "$WAVE_PLAN") || exit 1
for DEP in $DEPS; do
DEP_DIR=".octo/parallel/$DEP"
if [[ ! -f "$DEP_DIR/.done" || "$(cat "$DEP_DIR/exit-code" 2>/dev/null)" != 0 ]]; then
echo "Wave $WAVE blocked: dependency $DEP of $WP_ID has not completed successfully. Inspect its retained evidence before retrying." >&2
exit 1
fi
done
done
# Inject outputs from successful dependency WPs into instructions
for WP_ID in $WAVE_WPS; do
WP_NUM="${WP_ID#WP-}"
WP_DIR=".octo/parallel/$WP_ID"
DEPS=$(awk -v id="$WP_ID" '$(2) == id { for (i = 3; i <= NF; i++) print $i }' <<< "$WAVE_PLAN") || exit 1
if [[ -n "$DEPS" ]]; then
echo "Injecting dependency outputs into $WP_ID..."
echo "" >> "$WP_DIR/instructions.md"
echo "## Outputs from Dependencies" >> "$WP_DIR/instructions.md"
for DEP in $DEPS; do
DEP_DIR=".octo/parallel/$DEP"
if [[ -f "$DEP_DIR/output.md" ]]; then
echo "" >> "$WP_DIR/instructions.md"
echo "### From $DEP:" >> "$WP_DIR/instructions.md"
head -c 4000 "$DEP_DIR/output.md" >> "$WP_DIR/instructions.md"
fi
done
fi
done
# Launch WPs in this wave with 12s stagger
WAVE_COUNT=0
for WP_ID in $WAVE_WPS; do
WP_NUM="${WP_ID#WP-}"
echo "Launching $WP_ID at $(date '+%H:%M:%S')..."
# Clear before background launch, so the monitor cannot see a stale result.
rm -f ".octo/parallel/$WP_ID/.done" ".octo/parallel/$WP_ID/exit-code" || exit 1
bash ".octo/parallel/$WP_ID/launch.sh" &
WP_PID=$!
echo "$WP_PID" > ".octo/parallel/$WP_ID/pid"
echo " $WP_ID launched (PID: $WP_PID)"
WAVE_COUNT=$((WAVE_COUNT + 1))
# 12-second stagger within wave (skip after last)
REMAINING=$(echo "$WAVE_WPS" | wc -w | tr -d ' ')
if [[ "$WAVE_COUNT" -lt "$REMAINING" ]]; then
echo " Waiting 12 seconds before next launch..."
sleep 12
fi
done
# Monitor this wave
START_TIME=$(date +%s)
COMPLETED=0
WAVE_TOTAL=$(echo "$WAVE_WPS" | wc -w | tr -d ' ')
echo "Monitoring Wave $WAVE ($WAVE_TOTAL WPs, timeout: ${TIMEOUT}s)..."
while [[ "$COMPLETED" -lt "$WAVE_TOTAL" ]]; do
COMPLETED=0
for WP_ID in $WAVE_WPS; do
if [[ -f ".octo/parallel/$WP_ID/.done" ]]; then
COMPLETED=$((COMPLETED + 1))
fi
done
ELAPSED=$(( $(date +%s) - START_TIME ))
echo "Wave $WAVE progress: $COMPLETED/$WAVE_TOTAL complete (${ELAPSED}s elapsed)"
if [[ "$COMPLETED" -lt "$WAVE_TOTAL" && "$ELAPSED" -gt "$TIMEOUT" ]]; then
echo "TIMEOUT: Wave $WAVE did not complete within ${TIMEOUT}s. Dependent launches stopped; workers and evidence are retained. Wait for completion or cancel the owned workers before retrying." >&2
exit 1
fi
if [[ "$COMPLETED" -lt "$WAVE_TOTAL" ]]; then
# v8.45.0: Fire reaction engine between poll cycles
REACTIONS="${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${HOME}/.claude-octopus/plugin}}/scripts/reactions.sh"
if [[ -x "$REACTIONS" ]]; then
"$REACTIONS" check-all 2>/dev/null || true
fi
sleep 15
fi
done
# A .done marker means termination, not success. Missing or invalid status
# must also stop the next wave rather than becoming a successful prerequisite.
for WP_ID in $WAVE_WPS; do
if [[ "$(cat ".octo/parallel/$WP_ID/exit-code" 2>/dev/null)" != 0 ]]; then
echo "Wave $WAVE failed: $WP_ID has no successful exit status. Inspect its retained evidence before retrying." >&2
exit 1
fi
done
echo "Wave $WAVE complete: $COMPLETED/$WAVE_TOTAL succeeded."
done
echo ""
echo "All waves executed."
Validation gate: processes_launched — Verify PID files exist for all WPs.
IMPORTANT: The launch and monitor commands above should be run via the Bash tool. You may need to combine them or run the monitor as a separate polling step. The monitor loop will block until each wave completes or times out.
DO NOT PROCEED TO STEP 7 until all waves complete.
After all work packages complete (or timeout), aggregate results.
Read all outputs and exit codes:
# Restore the count in this shell, rather than relying on launch-time locals.
WP_COUNT=$(python3 -I -c '
import json
with open(".octo/parallel/wbs.json", encoding="utf-8") as stream:
packages = json.load(stream)["work_packages"]
if not isinstance(packages, list) or not packages:
raise SystemExit("Cannot summarize results: work_packages must be a nonempty list")
print(len(packages))
') || exit 1
echo "=== WORK PACKAGE RESULTS ==="
echo ""
FAILED=0
SUCCEEDED=0
for i in $(seq 1 "$WP_COUNT"); do
WP_DIR=".octo/parallel/WP-$i"
if [[ -f "$WP_DIR/.done" && -f "$WP_DIR/exit-code" ]]; then
EXIT_CODE=$(cat "$WP_DIR/exit-code")
else
EXIT_CODE="N/A (not completed)"
fi
if [[ "$EXIT_CODE" == "0" ]]; then
STATUS="SUCCESS"
SUCCEEDED=$((SUCCEEDED + 1))
else
STATUS="FAILED (exit code: $EXIT_CODE)"
FAILED=$((FAILED + 1))
fi
echo "WP-$i: $STATUS"
if [[ -f "$WP_DIR/output.md" ]]; then
OUTPUT_SIZE=$(wc -c < "$WP_DIR/output.md" | tr -d ' ')
echo " Output: $OUTPUT_SIZE bytes"
else
echo " Output: MISSING"
fi
echo ""
done
echo "=== SUMMARY ==="
echo "Total: $WP_COUNT | Succeeded: $SUCCEEDED | Failed: $FAILED"
Then read each output.md using the Read tool and review quality before declaring success:
output.md files from completed WPsagent.log content@ts-ignore, type: ignore, noqa, eslint-disable)TODO, FIXME, not implemented, stub functions)skip, xit, xdescribe, pytest.mark.skip)Present results in this format:
=== TEAM OF TEAMS - RESULTS ===
Compound Task: <original task>
Work Packages: N total | N succeeded | N failed
WP-1: <name> - [SUCCESS/FAILED]
<summary of what was accomplished>
WP-2: <name> - [SUCCESS/FAILED]
<summary of what was accomplished>
...
Integration Notes:
- <any cross-WP concerns>
- <files that may need reconciliation>
Failed Work Packages (if any):
- WP-X: <error summary from agent.log>
Coordination Files: .octo/parallel/
Validation gate: all_work_packages_complete — All WPs have .done files and exit codes checked.
Agent registry summary (v8.44.0):
# Show agent registry status for this parallel run
REGISTRY="${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${HOME}/.claude-octopus/plugin}}/scripts/agent-registry.sh"
if [[ -x "$REGISTRY" ]]; then
echo ""
echo "=== AGENT REGISTRY ==="
"$REGISTRY" list
fi
Created and managed by this skill:
.octo/parallel/
wbs.json # Work Breakdown Structure
WP-1/
instructions.md # Task instructions for this WP
launch.sh # Launch script (runs claude -p)
output.md # Agent output (created by claude -p)
agent.log # Agent stderr log (created by launch.sh)
exit-code # Process exit code (created by launch.sh)
pid # Process ID (created by orchestrator)
.done # Completion marker (created by launch.sh)
WP-2/
...
WP-N/
...
If a work package fails (non-zero exit code):
agent.log for error detailsIf monitoring times out:
If claude command is not available:
command -v claudeUser: /octo:parallel build a full authentication system with OAuth, RBAC, and audit logging
Decomposition:
WP-1: OAuth Integration
- OAuth provider setup (Google, GitHub)
- Token management and refresh
- Callback handlers
Files: src/auth/oauth.ts, src/auth/providers/
WP-2: RBAC Implementation
- Role and permission models
- Authorization middleware
- Role assignment API
Files: src/auth/rbac.ts, src/middleware/authorize.ts
WP-3: Audit Logging
- Audit event model
- Logging middleware
- Audit query API
Files: src/audit/logger.ts, src/audit/events.ts
Each WP runs as independent claude -p with full Octopus plugin.
Results aggregated after all complete.
User: /octo:parallel migrate all components in src/components/ from class components to functional React with hooks
Decomposition:
WP-1: Form components (src/components/forms/)
WP-2: Layout components (src/components/layout/)
WP-3: Data display components (src/components/tables/, src/components/charts/)
WP-4: Navigation components (src/components/nav/)
Each WP migrates its directory, runs existing tests, fixes any failures.
No overlapping files — safe to merge all results.
User: /octo:parallel fix issue #12, issue #15, and issue #22
Decomposition (after reading each issue):
WP-1: Fix #12 — login redirect loop (src/auth/login.ts)
WP-2: Fix #15 — pagination off-by-one (src/api/pagination.ts)
WP-3: Fix #22 — dark mode toggle not persisting (src/hooks/useTheme.ts)
No file overlaps detected — all three run in Wave 1.
Each WP runs related tests before marking complete.
User: /octo:parallel build a confluence scraper in go, a markdown-to-obsidian converter, a qdrant vectorizer, and a CLI search tool
Decomposition:
WP-1: Confluence scraper (cmd/scraper/) — Wave 1
WP-2: Markdown-to-Obsidian converter (cmd/converter/) — Wave 2 (depends on WP-1 output format)
WP-3: Qdrant vectorizer (cmd/vectorizer/) — Wave 2 (depends on WP-2 output format)
WP-4: CLI search tool (cmd/search/) — Wave 2 (depends on WP-3 schema)
Wave 1 completes first, output format injected into Wave 2 instructions.
Each WP builds, runs go test, and verifies the binary works.
What SKILL.md sets; muted values are Claude Code's defaults
highnpx claudepluginhub nyldn/claude-octopus --plugin octo64 skills in this plugin
/council-verdictsStarter: interpret a council run's verdict artifacts — quorum, dissent, cross-lab validity, and what to do next/debate-kickoffStarter: frame a decision as a multi-model debate — picks sides, seats providers, and launches /octo:debate with a well-formed motion/flow-defineMulti-AI requirements scoping using available external providers (Double Diamond Define phase). Priority triggers: octo define, octo scope, co-define, co-scope. DO NOT use for implementation, research, review/validation, or built-in commands./flow-deliverMulti-AI validation, scoring, and review using available external providers (Double Diamond Deliver phase)/flow-developMulti-AI implementation using available external providers (Double Diamond Develop phase). DO NOT use for simple code edits, reading/reviewing code, built-in commands, or trivial single-file changes./flow-discoverMulti-AI research using available external providers (Double Diamond Discover phase)Other plugins' skills for the same job