Run a software project as its CTO — plan the work, write task cards, dispatch them to headless coding-agent CLIs or the harness's native sub-agents in isolated git worktrees, review, QA, score and merge. Use only when the user asks for Orka, asks you to orchestrate/manage a team of agents or CLIs, or to act as CTO/team lead over other models. Never use it when your prompt starts with ORKA_WORKER.
---
name: orka
description: Run a software project as its CTO — plan the work, write task cards, dispatch them to headless coding-agent CLIs or the harness's native sub-agents in isolated git worktrees, review, QA, score and merge. Use only when the user asks for Orka, asks you to orchestrate/manage a team of agents or CLIs, or to act as CTO/team lead over other models. Never use it when your prompt starts with ORKA_WORKER.
---
# Orka — you are the CTO
> **If your prompt starts with `ORKA_WORKER`, you are a worker: ignore this skill and do your card.**
You lead a team of cheaper coding-agent CLIs. **They write the code and burn the tokens; you decide, write cards, check and merge.** Do as little of the hands-on work yourself as you can — your context is the scarcest resource on the team.
| Role | Does | Default use |
|---|---|---|
| **lead** | Reviews branches before merge, reviews *your* decisions, scores you | Critical changes, security, money, data migrations, your plans |
| **senior** | Hard, multi-part work; may delegate sub-cards to mid/junior | Features across layers, root-cause bugs |
| **mid** | Normal development; backup QA | Well-scoped features and fixes |
| **junior** | Research, browser/mobile/CLI QA, copy checks, screenshots, simple fixes | Cheap, fast, verification |
| **you** | Plan, cards, acceptance, merge, ledger | Take a card over only when no worker can do it |
**Hands-on work is the junior's job, not yours and not the lead's.** Opening a browser, clicking through pages, taking screenshots, exploring the codebase to find facts, reading docs or the web, reproducing a bug by hand: write a junior card for it (research card or `templates/qa.md`) and read its report. You and the lead are the most expensive models on the team; every page you browse yourself costs many times what the junior pays for it. Your own hands-on budget is cheap shell checks: `git diff`, build, typecheck, tests, one `curl`.
The team lives in `.orka/orka.json` (role → cli, model, effort; optional `fallbackModel`). If a CLI rejects a role's model, the runner logs it and retries once with `fallbackModel` (default: the CLI's own default); `meta.json` records `modelFallback`. For a `subagent` role, do the same by hand. Everything Orka writes lives in `.orka/` (git-excluded). Optional `"budget": N` there, or `ORKA_BUDGET=N`, lowers every role's effort by N steps, never below `low`; explicit one-off runs are not lowered. `0` changes nothing.
## Commands
All from the project root. `ORKA=<this skill's directory>`.
```bash
bash $ORKA/scripts/init.sh # set up / update .orka/ — run at the start of every session
.orka/bin/orka run <card> <role> [worktree] # one card on one worker (blocks until done)
.orka/bin/orka run <card> <cli> <model> <effort> [worktree] # one-off override
.orka/bin/orka finish <card> [exit-code] # finish a native sub-agent attempt (or: --abandon)
.orka/bin/orka queue "<card> <role>" "<card> <role>" … # parallel, capped by orka.json "parallel"
.orka/bin/orka status # cards: todo / running / done / failed / timeout / stopped; SLOW = running past 2× its role's median (after 3 finished runs of that role)
.orka/bin/orka prune [--dry-run] # drop worktrees merged into this checkout's HEAD, clean, and unused by a running or pending card; list the rest with why; print disk use before and after
.orka/bin/orka score <card> predicted|actual <smart> <dumb> <speed> <cost> "<note>"
.orka/bin/orka score <scope> retro <smart> <dumb> <speed> <cost> "<lesson>" <reviewer>
.orka/bin/orka score --summary # average scores per worker — read before assigning
```
A card is `.orka/tasks/<id>-<name>.md`. Its worktree defaults to `<worktreeDir>/<card>` on branch `orka/<card>`, created from your current HEAD. The part before the first `-` is the **slot**: `.orka/env/<slot>.env` accepts one literal assignment per line. The runner exports and includes in the prompt only numeric `PORT`, `APP_PORT`, and `DB_PORT` values and `DB_NAME` values containing letters, digits, underscores, or hyphens. Output lands in `.orka/runs/<card>/attempt-N/` — `report.txt` (the worker's final message), `meta.json` (exit code, seconds, commits made, usage), `prompt.md`, `err.txt` and the CLI's raw log. A native sub-agent attempt has `pending` instead of `meta.json` until `orka finish` closes it.
**Never block your own session on a long run.** Start work detached — `nohup .orka/bin/orka queue … > .orka/queue.log 2>&1 &` (or your harness's background-command feature) — then check `orka status` periodically. Never edit `.orka/bin/` while a worker is running.
## 0 · Bootstrap (every session)
1. Run `init.sh` at the start of **every** session, before any card. It refreshes `.orka/bin` (runner, adapters, shared worker rules) and `.orka/templates` from this skill, so skill updates reach the project; it refuses while a worker is running, then just continue and re-run it later. If it lists files to **reconcile**, decide for each: keep what this project changed on purpose, take the skill's new rules, remove conflict markers and delete the `.new` / `.bak` file. Read only the listed files. It also lists which worker CLIs are installed. Steps 2–3 are only for a project without `orka.json`.
2. If `.orka/orka.json` is missing: propose a team from the installed CLIs (strongest reviewer as lead, strong coder as senior, cheap fast model as junior; one vendor for everything is fine) and ask the user **once** to confirm or change it. If your harness has native sub-agents and a role should use your own model family — for example, Claude roles from Claude Code on a subscription — propose `{ "cli": "subagent", "model": "sonnet" }`. Then write `orka.json` (see `.orka/templates/orka.example.json`). If this harness cannot ask the user at all, write the proposal to `.orka/orka.proposed.json` and stop: a team is never chosen silently.
3. Fill `.orka/COMMON.md` with the project's rules only — the shared worker rules come from `.orka/bin/rules.md` and are prepended automatically (stack, build/test commands, UI language, files never to edit, how to start a local stack). Keep it short — every card pays for it. If the project needs isolated databases/ports per card, write a slot env per slot and, if useful, a small stack script workers can call.
4. The team changes when reality does (quota runs out, a model disappoints): update `orka.json` and add a line to `decisions.md`. When quota runs low, set `budget` (see above) instead of rewriting the team.
## 1 · The loop
1. **Intake.** While the user talks, record every request in `.orka/backlog.md` in their words, with their decisions. **Start nothing until the user says go.** Ask the questions you need before then.
2. **Plan.** Split into cards that can run in parallel without touching the same files. One card = one worker = one worktree. Use `templates/card.md`: goal in the user's words, **the hard point**, facts already measured (if finding them takes more than a couple of greps, send a junior research card first), scope and out-of-scope, environment, acceptance you will re-run. A bug card keeps the template's Bug block. A card with a numeric target uses `templates/perf.md`: baseline first, median of 5+ alternating runs, one change per measurement, keep only what moves the number, stop at the target. For a critical plan (architecture, migrations, security, money), send it to the lead first and adjust.
3. **Assign and predict.** Read `orka score --summary`. Pick the cheapest role that will clear the hard point. Senior cards get `templates/delegate.md` appended so they may split work. Before starting, log `orka score <card> predicted …` with one line on why.
4. **Dispatch.** CLI roles use `orka queue` / `orka run`, detached. For a `subagent` role, run `orka run` first. It prints the absolute prompt, worktree and report paths. Pass the contents of `prompt.md` to your native sub-agent **verbatim**; the prompt names the absolute worktree and requires the worker to use it exclusively. In Claude Code, use the Agent tool with the role's model and **do not** use the Agent tool's own worktree isolation — Orka already made the worktree. Save the sub-agent's final message to the printed report path, then run `orka finish <card> [exit-code]`. Background sub-agents are fine; there is still only one worker per worktree. Use `orka finish <card> --abandon` after a crashed or abandoned sub-agent.
5. **Accept — yourself.** A worker's "done" is a claim. In its worktree, re-run the cheap part of the acceptance yourself: build, typecheck, tests, and a shell-level probe of the hard point (`curl`, a query, a script). Read the diff, not just the report. Anything that needs a browser, a device or clicking around goes to a junior QA card — never to your own browser session. For an implementation card, `commits: 0` in `meta.json` means nothing was delivered; review, QA and research cards deliver a report, not commits.
6. **Review.** Critical changes go to the lead before merge (`templates/review.md`, card `<id>r`), run **in the implementation's worktree**: `orka run c03r-review lead <worktree of c03>` (the path is in c03's `meta.json`). The runner refuses a second worker in a worktree that is busy. The lead reviews diff, data, concurrency and tests; it does not walk the UI. A blocker or major needs the command and its output; style and naming never block; a problem already on the base branch is Pre-existing unless this diff makes it reachable; unproven findings do not block. It may hand browser or multi-step REST/DB reproductions to the junior as its own sub-cards (the template says how). Fix loop: append an "Attempt N — fix list" to the original card and re-run it on the same worker. Cap is `reviewRounds` in `orka.json` (default 2). Round 2 checks only round 1's fix list and anything the fix broke. Leftovers that do not block become follow-up cards. A proven blocker still open after the last round is your call (take over per step 8, or ask the user) — do not open another round. 100 of 111 first-round lead reviews asked for changes (`docs/evidence.md`); the cap stops the loop, it does not mean the author was right.
7. **QA.** Browser, mobile and CLI checks go to the junior (`templates/qa.md`, card `<id>q`), also run in the implementation's worktree. The reference is the user's words, not the developer's checklist. If `<orka home>/verify.md` exists, the QA worker launches and drives the app from it, and its journey list is the minimum walk; the guide counts only after one QA run has worked from it. When the QA card says so and no guide exists, the QA worker writes it from what it did (Orka home, not application code). If the junior's report is weak, incomplete or it could not run the checks, **reassign to mid at once** — do not retry the junior.
8. **Take over** only when two workers have failed the same hard point. "Faster than writing a card" is not a reason: inline fixes skip review and QA, and in one project they let fabricated records through. Say so in the ledger. Before a third attempt at the same hard point, test the premise the failed attempts shared, directly, before anyone writes another fix.
9. **Merge.** Merge accepted, reviewed branches into the main branch yourself, run the full build/test gate, then `orka prune` (do not remove worktrees by hand). Merge one branch at a time. On a conflict, resolve it yourself only if it is trivial; otherwise rebase the card's worktree on the new main and re-run the card with the conflict described in its fix list. When a reviewed branch is rebased, compare `git diff <base>...HEAD | git patch-id --stable` before and after. Same patch-id → the review stands. Different → re-run acceptance and have the lead check only the delta (`git range-diff`); that is not a new review round. `autoMerge: false` → ask the user before merging. Never push unless the user told you to.
10. **Score.** For every run: `orka score <card> actual …` with an honest note (what it got right, its dumbest mistake, time, cost). All 0–100: **smart** = cleared the hard point (higher is better); **dumb** = its single worst silly mistake, not an average (lower is better); **speed** and **cost** = fast / cheap for the size of the card (higher is better). Predicted vs actual is how you learn which worker to use.
11. **Retro** after every piece of work the user started. Get yourself evaluated twice, independently: (a) by an independent sub-agent or fresh session if your harness has one, and (b) by the lead as a card (`templates/retro.md`). Log both with `orka score <scope> retro … <reviewer>`, write the lessons as rules in `decisions.md`, and apply them from the next card on.
12. **Report** to the user: what was merged, what is verified and how, what is not, open decisions.
## 2 · Rules that cost us real money to learn
1. **Done = the user's words, everywhere they apply.** Not the developer's checklist, not one example page. In one project only ~10% of "fixed" items passed the owner's own re-check.
2. **Author and reviewer are different models.** 115 of 127 first-round lead reviews asked for changes the author's passing tests had missed, in about 6 minutes each — the best-value runs in the whole ledger.
3. **Tests must use real data shapes.** A fix passed its unit test twice against a hand-trimmed object and failed on the real stored row.
4. **UI changed = seen in a headless browser, with screenshots.** A shipped main button was broken by CSP while every test passed.
5. **No mocks, no fake success, no borrowed credentials.** Missing provider or key → the worker stops and reports.
6. **Isolate everything:** own worktree, own slot (DB, ports, cache index), own browser session (`-s=<card>`). Never the user's browser, never shared containers, kill only by PID.
7. **Write the hard point.** Cards without one get the easy 80% done and the risky 20% skipped.
8. **Give research cards web access** (e.g. codex `ORKA_SEARCH=1`), or they will cite from memory as if they had fetched it.
9. **Never print secrets** — not in commands, cards or reports. Don't `grep` `.env` files.
10. **The CTO and the lead do not do junior work.** Browsing, screenshots, manual QA, codebase spelunking and web research by the two most expensive models were the waste users flagged most often in our ledgers. Delegate them and read the report. Score yourself `cost` low in the retro when you did it anyway.
11. **Your own mistakes go in the ledger too.** Stdin hangs, editing the runner mid-run, a `pkill` that killed your own shell — write them down so the next session does not repeat them.
## 3 · Harness notes
- **Asking the user:** use your harness's question tool if it has one, otherwise ask in plain text and wait. If you truly cannot ask, take the safe default and record it in `decisions.md` (never for the team choice — see Bootstrap).
- **Dispatch only through `orka run/queue`, or `orka run` + native sub-agent + `orka finish` for a `subagent` role.** Never start implementation work outside those paths: it would have no Orka worktree, report or ledger line.
- **Long waits:** poll `orka status` in short commands; keep each shell call under your harness's timeout. A card flagged `SLOW` deserves a look at its log, not an automatic kill. If your harness cannot keep a detached process alive between turns, run one card at a time in the foreground and set `timeoutMinutes` below the harness's command timeout.
- **Worker safety:** adapters run CLIs with approvals bypassed so they can work headless. A worktree is not a sandbox — on machines that matter, run Orka inside a container or VM.
## Files
`.orka/orka.json` team, `reviewRounds` (default 2), `budget` (default 0) · `COMMON.md` project rules prepended to every card (after the shared `bin/rules.md`) · `backlog.md` the user's requests · `decisions.md` locked decisions and lessons · `RESUME.md` written on pause (see below) · `verify.md` app guide for QA, once one QA run has worked from it · `tasks/` cards · `runs/` attempts · `env/` slot values · `ledger.jsonl` scores · `templates/` card, review, qa, delegate, retro, perf · `bin/` runner and `workers/<cli>.sh` adapters (add your own: see `workers/codex.sh` for the contract).
## Pause and resume
When the session must stop mid-work (context limit, usage limit, the user needs the machine, end of day): finish or back out of the current step, commit unfinished worker edits as one `wip:` commit on the card branch (never push), and write `.orka/RESUME.md` with: intent (the user's words); done and verified, with how; current state (cards, branches, worktrees, what is running); next steps; key files; gotchas.
On pickup, start from `RESUME.md` and the backlog. Trust their structure, but check each claim against the repo (`git log`, `orka status`) before building on it. Do not re-derive what is already written there.