From CAST — Claude Agent Specialist Team
Executes a CAST plan by reading the Agent Dispatch Manifest and dispatching agents in dependency order — parallel batches simultaneously, sequential batches one at a time. Supports plan file path, 'next' for most recent plan, or 'resume' from checkpoint.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cast:orchestrateThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
This is the `/orchestrate` skill. It reads a plan's Agent Dispatch Manifest and executes the agent queue directly from the main session.
This is the /orchestrate skill. It reads a plan's Agent Dispatch Manifest and executes the agent queue directly from the main session.
Native Dynamic Workflows (Phase 10) are preferred for new non-critical dispatches. This skill is the stable LEGACY fallback.
$ARGUMENTS
If a file path was provided as an argument: use it directly.
If argument is next or no argument: find the most recent plan file:
ls -t ~/.claude/plans/*.md | head -1
If argument is resume: find any checkpoint log in ~/.claude/cast/orchestrator-checkpoint-*.log. Read the most recent one to extract the plan path and last completed batch.
If no plan file can be found, output: "No plan file found in ~/.claude/plans/. Run /plan first to write one."
Read the plan file. Find the ## Agent Dispatch Manifest section and parse the json dispatch block.
If no manifest exists: report "No Agent Dispatch Manifest found in [plan file]." and stop.
Check for a checkpoint:
PLAN_HASH=$(echo -n "$PLAN_FILE_PATH" | shasum -a 256 | cut -c1-8)
CHECKPOINT_FILE=~/.claude/cast/orchestrator-checkpoint-${PLAN_HASH}.log
If the checkpoint exists, read the last completed batch ID and skip batches with id <= that number.
DISPATCH_BACKEND=$(python3 ~/.claude/scripts/orchestrate-dispatch.py get-dispatch-backend 2>/dev/null || echo 'cast')
python3 ~/.claude/scripts/orchestrate-dispatch.py log-dispatch \
--backend "$DISPATCH_BACKEND" --plan "$PLAN_FILE_PATH" 2>/dev/null || true
If DISPATCH_BACKEND is "coordinator" or "auto", print: [CAST] dispatch_backend=$DISPATCH_BACKEND — COORDINATOR_MODE not yet supported; falling back to cast dispatch. and continue.
Create one TaskCreate entry per batch (subject = "Batch N: [description]").
Read target_branch from the manifest JSON (parsed in Step 2), then:
CURRENT_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
TODAY=$(date +%Y%m%d); CUTOVER=20260603
Case 1 — target_branch absent AND today < CUTOVER: warn [CAST-ORCHESTRATE] DEPRECATION WARNING: omits target_branch. Plans without target_branch will fail from 2026-06-03. Log and proceed.
Case 2 — target_branch absent AND today ≥ CUTOVER: BLOCK. target_branch is required in the manifest (enforced since 2026-06-03). Stop.
Case 3 — target_branch matches current branch: log [CAST-ORCHESTRATE] Branch check passed: $CURRENT_BRANCH and continue.
Case 4 — target_branch present but branch mismatch: print current vs target, stop and wait for explicit "y"/"yes" before proceeding to Step 3. Prevents C3-on-C2-branch errors.
Print the batch list as an informational summary. Do not wait for input. Proceed immediately.
Agent Dispatch Queue — [Plan Name]
═══════════════════════════════════════════════
Batch 1 (sequential): agent-name
Batch 2 (parallel) : agent-a, agent-b
═══════════════════════════════════════════════
Total: N agents across M batches
Executing in 10 seconds...
Run the interrupt window:
for i in $(seq 10 -1 1); do printf "\r Starting in %2ds..." $i; sleep 1; done; echo
If you receive a message containing "abort" before Batch 1 dispatches, print "Aborted." and stop.
At the start of this step, before dispatching any batch, set:
export CAST_ORCHESTRATE_ACTIVE=1
This suppresses CAST-CHAIN and CAST-REVIEW hook noise for the duration of the orchestrate session.
Before each batch:
in_progress/orchestrate resume."owns_files — if two agents claim the same file, report FILE OWNERSHIP CONFLICT and stop.test-runner AND any of {code-reviewer, security, frontend-qa}, report CO-SCHEDULING CONFLICT and either stop or auto-serialize test-runner into its own sequential batch before dispatching the rest. (test-runner's suite-timeout/kill path can reap co-scheduled sibling review processes — observed 2026-06-14.)Prompt construction for Agent tool calls:
Before passing the prompt field from the ADM to the Agent tool, prepend a context preamble. Use the full preamble for implementation agents and the minimal preamble for lightweight agents:
Full preamble — use for: code-writer, debugger, security, researcher, planner, test-writer, bash-specialist
[CAST SHARED CONTEXT]
Project: claude-agent-team
Repo: $CAST_REPO_DIR (or infer from git root)
Stack: Bash + Python + SQLite | BATS tests in tests/
DB access: always use scripts/cast_db.py (db_write, db_query, db_execute)
Conventions: YAGNI, DRY, exit 0 on all async hooks, exit 2 to block PreToolUse
Working dir: $CAST_REPO_DIR (or infer from git root)
[END CAST SHARED CONTEXT]
Minimal preamble — use for: commit, push, test-runner, code-reviewer, frontend-qa, merge, docs, devops, morning-briefing
[CAST CONTEXT]
Repo: $CAST_REPO_DIR (or infer from git root)
[END CAST CONTEXT]
Then wrap with:
[AGENT TASK]
{prompt from ADM goes here}
[END AGENT TASK]
Apply the appropriate preamble tier to ALL agent dispatches — both parallel and sequential batches.
Parallel batches ("parallel": true): dispatch all agents simultaneously in one response using the Agent tool.
Sequential batches ("parallel": false): dispatch the single agent, wait for response.
After each agent responds:
DONE, DONE_WITH_CONCERNS, BLOCKED, NEEDS_CONTEXT. If missing AND length > 50 chars, retry once: "Your response is missing a Status block. End with Status: DONE (or DONE_WITH_CONCERNS / BLOCKED / NEEDS_CONTEXT)." On retry failure, attempt status file fallback (below).Status file fallback (Phase 4.9): Before declaring BLOCKED, run:
FILE_STATUS=$(python3 ~/.claude/scripts/orchestrate-dispatch.py recent-status --agent "$AGENT_NAME" --max-age 300 2>/dev/null)
If non-empty, use as recovered Status and log contract_passed=-1 to quality_gates. Only treat as BLOCKED if both retry AND file fallback fail.
Test-runner file truth (Phase 4.11): For test-runner, file status wins over prose — run:
FILE_STATUS=$(python3 ~/.claude/scripts/orchestrate-dispatch.py recent-status --agent test-runner --max-age 300 2>/dev/null)
If file differs from prose, trust file and log [CAST] test-runner prose said X but file says Y — trusting file. This rule applies BEFORE Phase 4.9.
python3 ~/.claude/scripts/orchestrate-dispatch.py log-quality-gate \
--batch-id "$BATCH_ID" --agent "$AGENT_NAME" \
--status "$STATUS_LINE" --contract-passed "$CONTRACT_PASSED" \
--retry-count "$RETRY_COUNT" 2>/dev/null || true
($CONTRACT_PASSED = 1 if valid Status found first try, 0 otherwise; $RETRY_COUNT = 0 or 1; $STATUS_LINE = extracted Status line or "MISSING")
Route based on Status:
Status: DONE → mark task completed, write checkpoint, continueStatus: DONE_WITH_CONCERNS → log concern text, mark completed, continueStatus: BLOCKED or no Status after retry → write checkpoint and stop: "Batch N blocked. Human intervention required. Blocker: [reason]"Status: NEEDS_CONTEXT → stop and request clarification before continuingFile presence check — after DONE/DONE_WITH_CONCERNS, run git status --short and git diff --stat HEAD | tail -20. Read 2-3 files the agent claimed to modify. If no changes but edits claimed, retry once or escalate — do NOT silently continue.
After each batch: mark task completed, print [BATCH N COMPLETE], then:
mkdir -p ~/.claude/cast && echo "[BATCH $BATCH_ID COMPLETE] $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$CHECKPOINT_FILE"
source ~/.claude/scripts/cast-events.sh && cast_emit_event 'task_completed' 'orchestrate-skill' "batch-$BATCH_ID" '' '<summary>' '<STATUS>'
Token budget check (between batches): python3 ~/.claude/scripts/cast-token-budget-check.py --threshold 50000 2>/dev/null — if exit 1, log warning. Advisory; do not stop.
After all batches or early exit: unset CAST_ORCHESTRATE_ACTIVE.
Print a ≤200-word summary (what each batch did, any concerns). Then:
rm -f "$CHECKPOINT_FILE"
source ~/.claude/scripts/cast-events.sh
cast_emit_event 'task_completed' 'orchestrate-skill' 'session' '' 'All batches complete' 'DONE'
When
VerifyPlanExecutionToolbecomes available, call it before the terminal event and log verdict toquality_gates. Seedocs/native-tools-reference.md.
The following agents automatically dispatch their successor agents when status = DONE:
These fire automatically after each upstream agent completes and should not be re-dispatched manually in the plan.
Before dispatching any commit agent:
git add <exact-files-for-this-commit> — not the commit agent. The commit agent CANNOT git add (HARD RULE — its task is compose-and-commit only).Blocker class: commit agent BLOCKED on "nothing to commit" = orchestrator forgot to stage.
Agent Teams (experimental): When
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, parallel batches may use team-lead mode. Seedocs/native-tools-reference.md. Falls back to hub-and-spoke when unavailable.
[CAST-TRUNCATED] fires on REAL output truncation only (model output cut mid-stream). MISSING_FORMALITY (complete-looking response, absent Status block) does NOT fire [CAST-TRUNCATED] — it logs an agent_protocol_violations row and triggers the existing Status-retry path (no banner).
SendMessage-resume: A resume grants a fresh turn budget. Scope dispatches to fit caps rather than relying on resumes. When resuming a capped agent, state exactly what work remains.
If [CAST-TRUNCATED] fires on a gate agent (test-runner, code-reviewer, security): do NOT auto-retry. Use inline fallback — test-runner: bash tests/run.sh --tap 2>&1 | tail -20; code-reviewer: apply checklist manually; security: grep for anti-patterns. Log as Status: DONE_WITH_CONCERNS and cast.db entry agent_name='<role>-INLINE-FALLBACK' with contract_passed=1 (0 if issues found). If inline fallback cannot complete: BLOCK and stop.
/orchestrate resumenpx claudepluginhub ek33450505/claude-agent-team --plugin castProvides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Searches MemPalace before answering questions about past work, people, projects, or prior decisions. Returns verbatim stored content instead of guessing from model memory.