Workflow Orchestrator
Read the full workflow from .claude/commands/workflow.md and execute it.
For CI waits, default to check_suite.completed + workflow_run.completed for the
full 40-character PR head SHA. Opt in to check_run.completed only for early
per-job failure or job-specific progress. Reconcile all current GitHub checks on
every resume; one suite/workflow completion includes failures and is not all-CI
success. Subscriptions stay active after delivery: while required checks are
pending on the same SHA, retain the existing subscription and fallback and end
your turn again; do not recreate them on each wake. Keep one bounded fallback schedule for missing terminal webhooks; follow
docs/guides/ci-wait-recovery.md for registration, reconciliation and cleanup.
Quick Summary
- Decompose — break the user's request into discrete subtasks with dependencies
- Dispatch — send subtasks to other agents via
dispatch_task(with/doinstructions) and verify each task started with the intended title, profile, and constraints - Wait — persist state and a stable workflow-step
waitKey, registerwait_for_subtasks, and end the turn - React — dispatch dependent tasks as predecessors complete, retry failures
- Complete — summarize results when all subtasks finish
Why This Exists
SAM owns durable child-task status and can wake a sleeping parent exactly once when a registered wait resolves. The orchestrator therefore releases its prompt turn instead of maintaining an expensive foreground poller. Bounded foreground polling is a compatibility fallback only when the connected server does not advertise wait_for_subtasks or reports that durable wake delivery is disabled.
Staging Debugging Access
All agents have access to $CF_TOKEN for direct Cloudflare API queries against staging. When monitoring subtasks that deploy to staging, use the CF API to verify their work landed correctly — query D1 for data state, read KV for feature flags, check DNS for routing. See .claude/rules/32-cf-api-debugging.md for the full cheat sheet.
State Persistence
Maintain .workflow-state.md (local-only, snapshot-visible; never commit) as external memory. Write it before registering a wait and re-read it whenever SAM wakes the session. This survives sleep, recovery, and context compaction. See .claude/commands/workflow.md for the full state file format.