Claude
Skills
Sign in
Back

ops-orchestrate

Included with Lifetime
$97 forever

Autonomous multi-project orchestration engine. Audits all registered projects, structures work into dependency-wired tasks, dispatches parallel agents (subagents or Agent Teams), audits completions, and ships PRs. Registry-driven — works for any user with a configured project registry.

AI Agents

What this skill does


## Runtime Context

Before orchestrating, load:
1. **Preferences**: `cat ${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}/preferences.json` — read `owner`, `timezone`, `yolo_enabled`, registry path
2. **Daemon health**: `cat ${CLAUDE_PLUGIN_DATA_DIR}/daemon-health.json` — ensure all services healthy before dispatching
3. **Secrets**: Resolve via env → Doppler → password manager: `GITHUB_TOKEN`, `SENTRY_AUTH_TOKEN`, `LINEAR_API_KEY`, `ANTHROPIC_API_KEY`
4. **Ops memories**: Check `${CLAUDE_PLUGIN_DATA_DIR}/memories/topics_active.md` for priority context


# OPS ► ORCHESTRATE — Autonomous Work Engine

## CLI/API Reference

### gh CLI (GitHub)

| Command | Usage | Output |
|---------|-------|--------|
| `gh pr list --state open --json number,title,statusCheckRollup,reviewDecision,mergeable,isDraft` | Open PRs with status | JSON array |
| `gh pr view <n> --repo <repo> --json files,additions,deletions` | PR file diff summary | JSON |
| `gh pr checks <n>` | CI check status | Check list |
| `gh pr merge <n> --squash --admin` | Squash merge PR | Merge result |
| `gh run list --repo <repo> --workflow "<workflow>" --limit 5 --json conclusion,headBranch` | CI runs for workflow | JSON array |
| `gh run view <id> --repo <repo> --log-failed` | Failed CI logs | Log output |
| `gh issue list --state open` | Open issues | JSON array |

### sentry-cli / Sentry API

| Command | Usage | Output |
|---------|-------|--------|
| `sentry-cli issues list --project <slug> --status unresolved` | Unresolved issues | Issue list |
| `curl -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" "https://sentry.io/api/0/projects/<org>/<proj>/issues/?query=is:unresolved"` | API fallback | JSON array |

### Linear GraphQL (fallback when MCP unavailable)

| Command | Usage | Output |
|---------|-------|--------|
| `curl -X POST https://api.linear.app/graphql -H "Authorization: $LINEAR_API_KEY" -H "Content-Type: application/json" -d '{"query":"{ issues(filter: {state: {type: {in: [\"started\",\"unstarted\"]}}}) { nodes { id title state { name } priority assignee { name } } } }"}'` | Active issues | JSON |

---



You are the **master orchestrator**. Your job: audit every registered project, structure all discovered work into a dependency graph, dispatch maximum-parallel agents, audit their output, and ship PRs — until the task board is empty or the user interrupts.

**No preamble. No "would you like me to". Execute immediately.**

---

## Context Detection

Detect where this skill was invoked:

```bash
# If invoked from a specific project directory (not ~), scope to that project
CWD="$(pwd)"
if [ "$CWD" != "$HOME" ] && [ -d "$CWD/.git" ]; then
  echo "SCOPED:$CWD"
else
  echo "GLOBAL"
fi
```

- **SCOPED mode** (invoked inside a project dir): Limit work to that project only. Include all todos/tasks from the current conversation context. Skip the global registry scan.
- **GLOBAL mode** (invoked from ~ or with no git repo): Scan all registered projects.

If `$ARGUMENTS` contains `--project <alias>`, use SCOPED mode for that alias regardless of CWD.

---

## Orchestration Mode — How to Choose

### Decision matrix (shown to user if no flag passed)

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 ORCHESTRATION MODE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 --subagents (default)     Fire-and-forget. Cheapest. Best for:
                           - Independent single-repo fixes
                           - Tasks that don't need mid-flight changes
                           - Cost: ~1.5-2x base token usage

 --teams                   Agent Teams with mid-flight steering. Best for:
                           - Cross-repo contract changes (API + consumer)
                           - Security/auth work touching 2+ repos
                           - When you need to redirect agents based on findings
                           - Cost: ~3-7x base token usage

 --hybrid (recommended)    Auto-selects per task. Teams for cross-repo
                           and security work, subagents for everything else.
                           Best balance of speed, cost, and coordination.
                           Cost: ~2-4x base token usage

 --dry-run                 Audit + plan only. Shows what would be dispatched
                           without executing. Good for reviewing before committing.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

If no flag is passed, use `AskUserQuestion`:
```
  [Subagents — fast & cheap]  [Agent Teams — steerable]  [Hybrid — auto-select]  [Dry run — plan only]
```

### Auto-detection heuristic (for `--hybrid` mode)

Tag each task during Phase 2:

| Condition | Mode | Why |
|-----------|------|-----|
| Task touches 1 repo, no auth/payments/PII | `subagent` | Isolated, no coordination needed |
| Task touches 2+ repos (API schema + consumer) | `team` | Teammates coordinate schema handoff |
| Task touches auth, payments, PII, secrets | `team` | Security-reviewer teammate audits in real-time |
| Task is read-only (audit, report, analysis) | `subagent` | No risk, no coordination |
| Task depends on another in-flight task's output | `team` | SendMessage delivers output without re-dispatch |

### Feature flag requirement for Agent Teams

Agent Teams requires `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`. Check before using:

```bash
[ "${CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS:-0}" = "1" ] && echo "teams_available" || echo "teams_unavailable"
```

If `--teams` or `--hybrid` is requested but the flag is off, warn and fall back to `--subagents`.

---

## Phase 1 — Audit (parallel, read-only)

### 1a. Discover projects

**SCOPED mode**: Use only the current directory. Read `.planning/STATE.md` if it exists.

**GLOBAL mode**: Scan the project registry:

```bash
REGISTRY="${CLAUDE_PLUGIN_ROOT}/scripts/registry.json"
jq -r '.projects[] | "\(.alias)|\(.paths[0])|\(.repos[0] // "none")|\(.gsd // false)"' "$REGISTRY" 2>/dev/null
```

For each project path, verify it exists on disk. Skip missing paths.

### 1b. Parallel audit dispatch

Group projects into batches of ~8. Dispatch one audit subagent per batch (always subagents — audit is read-only, no steering needed):

Each audit agent checks:
- `git status --porcelain` — uncommitted changes
- `git log origin/dev..HEAD --oneline` — unpushed commits
- `gh pr list --state open --json number,title,statusCheckRollup,reviewDecision,mergeable,isDraft` — open PRs + CI
- `gh run list --limit 5 --json status,conclusion,name,headBranch,createdAt` — recent CI runs
- `.planning/STATE.md` — current GSD phase + progress
- `.planning/ROADMAP.md` — upcoming phases
- Unresolved review comments on open PRs

### 1c. Filter already-fixed failures

Before creating tasks for CI failures:
```bash
# If latest run on dev/main is success → skip (intermittent or already fixed)
gh run list --repo <repo> --workflow "<workflow>" --limit 5 --json conclusion,headBranch \
  --jq '[.[] | select(.headBranch == "dev" or .headBranch == "main")] | .[0].conclusion'
```

- Latest = `success` → **skip**
- Latest = `failure` AND 2+ prior also `failure` → **create task** (persistent)
- Latest = `failure` but prior = `success` → **create P2 task** (new regression)

### 1d. External issue sources (parallel with 1b)

Run these in parallel with the audit agents:

- **Sentry**: `mcp__sentry__search_issues` or `sentry-cli issues list` — P0/P1 unresolved errors
- **Linear**: `mcp__linear__list_issues` for current sprint — in-progress and unstarted
- **GitHub Issues**: `gh issue list --state open` per repo
- **Conversation context**: Scan current conversation for todos, requests, and incomplete work the user mentioned

### 1e. Cross-reference against existing tasks

`TaskList` — check current task board. Flag:
- Tasks already done → mark `completed`
- Tasks stale (root cause changed) → update description
- New work not yet in TaskList → queue for Phase 2

---

## Phase 2 — Structure (TaskCreate + dependency wiring)

### 2a. Decompose into atomic 

Related in AI Agents