leos-agent 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/adapters/cursor/agents/executor.md +17 -0
  2. package/adapters/cursor/agents/expert.md +70 -0
  3. package/adapters/cursor/agents/explore.md +16 -0
  4. package/adapters/cursor/agents/implementer.md +18 -0
  5. package/adapters/cursor/agents/investigator.md +18 -0
  6. package/adapters/cursor/agents/planner.md +28 -0
  7. package/adapters/cursor/agents/reviewer.md +33 -0
  8. package/adapters/opencode/agents.json +66 -0
  9. package/adapters/opencode/plugin.js +186 -0
  10. package/config/models.json +62 -0
  11. package/hooks/bash-guard.py +541 -0
  12. package/hooks/cursor-guard.py +84 -0
  13. package/hooks/hooks-cursor.json +11 -0
  14. package/hooks/hooks.json +20 -0
  15. package/hooks/session-start.py +121 -0
  16. package/package.json +16 -0
  17. package/roles/executor.md +15 -0
  18. package/roles/expert.md +67 -0
  19. package/roles/explore.md +13 -0
  20. package/roles/implementer.md +16 -0
  21. package/roles/investigator.md +15 -0
  22. package/roles/planner.md +25 -0
  23. package/roles/reviewer.md +30 -0
  24. package/scripts/render_adapters.py +326 -0
  25. package/scripts/state.py +127 -0
  26. package/settings.json +7 -0
  27. package/skills/.gitkeep +0 -0
  28. package/skills/brainstorming/SKILL.md +109 -0
  29. package/skills/debugging/SKILL.md +98 -0
  30. package/skills/delegation/SKILL.md +141 -0
  31. package/skills/executing-plans/SKILL.md +116 -0
  32. package/skills/finishing-a-branch/SKILL.md +123 -0
  33. package/skills/test-first/SKILL.md +90 -0
  34. package/skills/using-leo/SKILL.md +89 -0
  35. package/skills/using-leo/references/claude-mapping.md +11 -0
  36. package/skills/using-leo/references/codex-mapping.md +24 -0
  37. package/skills/using-leo/references/cursor-mapping.md +22 -0
  38. package/skills/using-leo/references/hermes-mapping.md +26 -0
  39. package/skills/using-leo/references/opencode-mapping.md +28 -0
  40. package/skills/verification/SKILL.md +102 -0
  41. package/skills/worktrees/SKILL.md +129 -0
  42. package/skills/writing-plans/SKILL.md +96 -0
  43. package/workflows/cost-tiered-fix.js +259 -0
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: delegation
3
+ description: >
4
+ Operational mechanics for dispatching subagents — a single spawn or a large
5
+ fan-out — the companion to the policy's "Delegate the labor" section.
6
+ Covers brief construction, model/effort pinning, the four-state return
7
+ contract, and ledger-backed progress tracking for long multi-agent runs.
8
+ when_to_use: >
9
+ Any time work is routed to a subagent (explore, investigator, executor,
10
+ implementer, reviewer, expert) rather than done inline — single dispatch or
11
+ fan-out. NOT for deciding *which* tier a task belongs in (that's the
12
+ routing table in the injected leo:using-leo policy); this skill covers what
13
+ to do once the tier is already chosen.
14
+ ---
15
+
16
+ # delegation
17
+
18
+ Core rule: a subagent gets one shot at the brief and no session history. If
19
+ the brief doesn't stand alone, the dispatch is already broken.
20
+
21
+ ## Writing the brief
22
+
23
+ Every dispatch is self-contained: goal, constraints, exact file paths, the
24
+ checks to run, and what the return must contain. Write it as if for a
25
+ stranger who will never see this conversation — because that's what a
26
+ subagent is. A brief missing a file path or a check produces a report that
27
+ looks done and isn't.
28
+
29
+ Bad: "fix the flaky auth test." Good: "`tests/auth/session_test.py::test_expiry`
30
+ fails intermittently (repro: run it 20x, ~1 in 8 fails). Fix the race, keep
31
+ the test's intent unchanged, don't touch other tests in the file. Run
32
+ `pytest tests/auth/session_test.py -x` 20 times clean before reporting done.
33
+ Return: files touched, the race you found, the check output." The second
34
+ version needs no follow-up question; the first invites three.
35
+
36
+ ## Pin model and effort
37
+
38
+ Every dispatch pins **model AND effort** from the routing table — opus for
39
+ judges (reviewer, investigator), sonnet for execution (implementer, executor
40
+ on normal work), haiku for mechanical work (executor on boilerplate). expert
41
+ never appears in a fan-out — one at a time, never fanned. An unpinned call
42
+ silently inherits the session's tier: in an opus session that means every
43
+ executor spawn quietly runs at opus, and a ten-item fan-out burns
44
+ opus-fan-out money for haiku-shaped work. Pin both fields on every spawn, not
45
+ just the ones that "obviously" need it.
46
+
47
+ ## The four-state return contract
48
+
49
+ A subagent's report must resolve to exactly one of four states. Don't accept
50
+ a report that hedges across two of them.
51
+
52
+ | State | Means | Your response |
53
+ |---|---|---|
54
+ | `done` | Work finished, matches the brief | Verify against artifacts — see leo:verification — never take the self-report at face value |
55
+ | `concerns` | Finished, but flags something worth a second look | Read the concerns before accepting; they're often the real finding |
56
+ | `needs-context` | Blocked on missing information you can supply | Send the missing piece to the same agent (SendMessage) so it keeps the context it already built; cold re-dispatch only if that agent is gone. Either way **once** — a second needs-context on the same gap means the brief itself is broken, escalate the tier |
57
+ | `blocked` | Blocked on something you can't hand over inline | Resolve the blocker, or escalate per the ladder — never a silent same-tier retry |
58
+
59
+ `needs-context` and `blocked` look similar; the test is whether the missing
60
+ piece is something *you* hold (needs-context — a file path, a decision, a
61
+ credential) or something neither of you can supply without more work
62
+ (blocked — a failing external service, a genuinely ambiguous requirement).
63
+
64
+ Each role's own prompt carries the state line it must emit, so the contract
65
+ is enforced at both ends. Two roles are deliberately narrowed: `reviewer`
66
+ emits only `done` / `needs-context` (severity already lives in
67
+ `blocking`/`non-blocking`, and the diff's own verdict in
68
+ `approved`/`needs-changes`), and `expert` never emits `blocked` — it is the
69
+ ceiling, so there is nothing left to escalate to. `status` is a separate axis
70
+ from `confidence`: status routes your next move, confidence rates the work.
71
+
72
+ ## Long multi-agent runs: the ledger
73
+
74
+ A run spanning many dispatches survives context compaction only if progress
75
+ is persisted outside the conversation. Use
76
+ `${CLAUDE_PLUGIN_ROOT}/scripts/state.py` (get / merge / path — flock-guarded,
77
+ atomic writes, keyed per repo) as the ledger, not ad hoc notes in the
78
+ transcript. Each entry: item id, status (one of the four states above, plus
79
+ `pending` / `in-progress`), artifact path (branch name, file, or diff). On
80
+ resume, read the ledger first — anything already `done` or `concerns` is not
81
+ re-dispatched; anything `blocked` is reported, not silently retried.
82
+
83
+ A ledger entry is small — `{"items": {"<id>": {"status": "done", "artifact":
84
+ "branch:fix/eng-123-slug"}}}` merged via `python3 "${CLAUDE_PLUGIN_ROOT}/scripts/state.py"
85
+ merge <skill-name> <owner/repo> '<patch>'` — but it's the only thing standing between a
86
+ compaction mid-run and forty items silently re-dispatched from item 1.
87
+ Update it after every dispatch resolves, not in a batch at the end: a crash
88
+ between "agent finished" and "ledger written" is exactly the gap this
89
+ exists to close.
90
+
91
+ `${CLAUDE_PLUGIN_ROOT}` above is the Claude Code spelling of the plugin root,
92
+ and it is substituted into this text only there. On another harness, read the
93
+ plugin-root form from that harness's appendix in the injected policy (Codex
94
+ uses a real `$PLUGIN_ROOT` env var, Cursor `$CURSOR_PLUGIN_ROOT`) — the path
95
+ after the root is identical everywhere.
96
+
97
+ For a batch of independent, well-scoped fixes, don't hand-roll this loop —
98
+ the reusable workflow at `${CLAUDE_PLUGIN_ROOT}/workflows/cost-tiered-fix.js`
99
+ (Workflow tool, `scriptPath`) already implements plan → tiered execute →
100
+ opus verify with escalation built in, including its own progress tracking.
101
+ Reach for it before writing a bespoke fan-out loop; write the ledger
102
+ approach above only when the run doesn't fit that workflow's shape (e.g. one
103
+ dispatch at a time inside a larger interactive flow, not a clean batch).
104
+ That workflow needs Claude Code's Workflow tool; on every other harness the
105
+ ledger above is the whole mechanism, so use it directly rather than looking
106
+ for a runner that isn't there.
107
+
108
+ ## Parallel dispatch: own your files
109
+
110
+ Fan-out is safe only when each spawn writes to **disjoint** files — no two
111
+ concurrent dispatches touching the same path. If the work can't be split
112
+ into disjoint file sets (one coherent change that happens to span many
113
+ files, like a single ticket fix), don't fan out — either run it sequentially
114
+ in one dispatch, or give each spawn its own isolated tree via leo:worktrees
115
+ so parallel edits can't collide even when the file sets overlap.
116
+
117
+ ## Self-talk to catch
118
+
119
+ - "I'll skip pinning effort, model is enough" — no; an unpinned effort on an
120
+ opus judge still runs at opus prices, at auto effort, which is not what
121
+ the routing table costed out.
122
+ - "The brief is short, they'll infer the rest" — a subagent infers nothing;
123
+ it has this brief and nothing else.
124
+ - "It said needs-context, I'll just re-ask the same way" — re-dispatching
125
+ with the identical brief reproduces the identical gap; either add the
126
+ missing piece or step up a tier. And prefer messaging the same agent over
127
+ a fresh spawn: a cold re-dispatch pays again for the context it already
128
+ built and can rediscover the same gap from a different angle.
129
+ - "Two spawns editing the same file will probably be fine, they touch
130
+ different functions" — same file is not disjoint; sequence them or
131
+ isolate with a worktree.
132
+ - "This ten-item fan-out is basically cost-tiered-fix, I'll just write the
133
+ loop myself" — the workflow already handles escalation and orphan
134
+ tracking; reinventing it inline drops that for no reason.
135
+
136
+ ## Works with
137
+
138
+ - leo:verification — how a `done` report gets checked against real
139
+ artifacts, not trusted as stated.
140
+ - leo:worktrees — file isolation for parallel dispatches that can't be made
141
+ disjoint by scope alone.
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: executing-plans
3
+ description: >
4
+ Checkpoint discipline for carrying out a written plan — batch execution
5
+ with a check at every batch boundary, plan-intent-wins-on-architecture /
6
+ reality-wins-on-mechanics arbitration, and one fix-then-re-review cycle
7
+ before stopping to report. Used by the implementer agent, or the main loop
8
+ when it executes a plan directly.
9
+ when_to_use: >
10
+ A written plan (from planner, an issue, or Leo's own outline) is about to
11
+ be turned into code. NOT for open-ended implementation with no plan
12
+ (normal execute-then-review flow) and NOT for the review step itself
13
+ (the reviewer agent judges the diff; this skill only carries out the plan).
14
+ ---
15
+
16
+ # executing-plans
17
+
18
+ Core rule: a plan is executed in checkpointed batches, never as one long
19
+ uninterrupted run. Each checkpoint is a place execution is allowed to stop
20
+ without having made things worse.
21
+
22
+ ## Before edit one
23
+
24
+ Sanity-check the plan against the tree it's about to touch:
25
+
26
+ - Base ref matches what the plan assumed — `git rev-parse HEAD` against the
27
+ base the plan was written against. Drifted → say so before touching
28
+ anything; the plan may already be stale.
29
+ - Files/symbols the plan names actually exist at the paths/shapes it
30
+ describes. A plan step that references a function that moved or a file
31
+ that's gone is a stop-and-report, not a guess-and-proceed.
32
+
33
+ This is cheap — a few Read/Grep calls — and skipping it is how a plan
34
+ written against yesterday's tree silently corrupts today's.
35
+
36
+ ## Execute in batches
37
+
38
+ Break the plan into batches along its own natural seams (usually: one
39
+ plan-step or one cohesive file group per batch). At each batch boundary:
40
+
41
+ 1. Finish the batch's edits.
42
+ 2. Run the narrowest relevant checks for what that batch touched — the
43
+ touched test file, a targeted typecheck, not the full suite every time.
44
+ 3. Green → advance to the next batch. Red → stop the batch right there; fix
45
+ it or report it. Never carry a red check into the next batch hoping it
46
+ resolves itself — a checkpoint exists precisely to catch this before the
47
+ failure compounds across three more batches of edits built on top of it.
48
+
49
+ This is the same shape as leo:delegation's tiering: cheap, frequent checks
50
+ bound the blast radius so the expensive step (review) isn't debugging a
51
+ pile of unrelated regressions.
52
+
53
+ ## Plan intent wins on architecture; reality wins on mechanical detail
54
+
55
+ Two different kinds of mismatch between plan and tree call for two different
56
+ responses:
57
+
58
+ - **Mechanical drift** (a renamed variable, a moved file, a slightly
59
+ different function signature than the plan assumed) — reality wins. Adapt
60
+ the mechanics silently and keep going; that's normal execution, not a
61
+ deviation worth flagging.
62
+ - **Architectural disagreement** (the plan's approach doesn't fit the actual
63
+ structure, a step contradicts how the system actually works, following it
64
+ as written would build on a wrong premise) — the plan's intent still wins
65
+ over improvising a fix, but only the plan's author can resolve a real
66
+ conflict. Stop and report the disagreement; never silently redesign around
67
+ it. Silent redesign is worse than executing a flawed plan, because it
68
+ hides the disagreement instead of surfacing it.
69
+
70
+ When genuinely unsure which kind of mismatch it is, treat it as
71
+ architectural and stop — reporting an unnecessary pause costs a message;
72
+ silently redesigning costs trust.
73
+
74
+ ## Behavior changes still default to test-first, done still means verification
75
+
76
+ A plan step that changes behavior doesn't get a pass on process because it's
77
+ already written down. Default to leo:test-first for those steps, and treat
78
+ "the plan is implemented" and "the plan is done" as different states — done
79
+ still means the change clears leo:verification, not just that every step got
80
+ executed.
81
+
82
+ ## One fix-then-re-review cycle
83
+
84
+ Once all batches are in, this hands off to the standard review gate — spawn
85
+ `reviewer` on the actual diff against the recorded base ref,
86
+ with the plan text as the original request. If it comes back with blocking
87
+ findings: fix at the executing tier, then re-review only the fix. That's
88
+ **one fix-then-re-review cycle**, full stop. A second block on the same
89
+ findings means stop the loop and report to Leo with options, expert
90
+ arbitration (the `expert` agent) among them — never a third pass, never quietly
91
+ loosening what counts as blocking to escape the loop.
92
+
93
+ ## Delegation and workspace boundaries
94
+
95
+ Executing a written plan is `implementer`'s job per leo:delegation — the
96
+ main loop only executes inline when it's already the implementer context or
97
+ the touch is genuinely trivial. If the plan spans a branch of nontrivial
98
+ size, it runs on a dedicated branch per leo:worktrees, and finishing it
99
+ follows leo:finishing-a-branch rather than improvising a merge/cleanup
100
+ sequence at the end.
101
+
102
+ ## Self-talk to catch
103
+
104
+ - "The plan says step 4, I'll just push through to step 7 before checking
105
+ anything" — that's skipping checkpoints, not saving time; a break at step
106
+ 5 now costs one batch's rework instead of three.
107
+ - "This isn't quite what the plan says but it's obviously what they meant" —
108
+ if it's mechanical, fine; if it's architectural, that's the silent
109
+ redesign this skill exists to block. Report it instead.
110
+ - "The re-review still isn't clean but it's close enough" — close enough on
111
+ a second block is the definition of stop-and-report, not a third fix.
112
+
113
+ ## Works with
114
+
115
+ leo:test-first, leo:verification, leo:delegation, leo:worktrees,
116
+ leo:finishing-a-branch — plus the `reviewer` and `expert` agents.
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: finishing-a-branch
3
+ description: >
4
+ End-of-branch state machine: what happens once implementation on a
5
+ branch/worktree is complete. Gates on a clean review verdict, then offers
6
+ a closed set of next steps — merge / PR / keep / discard — routes the
7
+ chosen path through the right ordering (land the work before removing the
8
+ worktree, remove the worktree before deleting the branch), and leaves the
9
+ repo clean.
10
+ when_to_use: >
11
+ A branch or worktree has reached "implementation done" and Leo needs to
12
+ decide what happens to it. Fires after execute-then-review completes, or
13
+ when Leo says finish/wrap up/close out/clean up this branch. NOT for
14
+ starting or managing a worktree mid-task (that's leo:worktrees) and NOT a
15
+ substitute for the review cycle itself (that's execute-then-review) — this
16
+ skill starts only once a review verdict already exists.
17
+ ---
18
+
19
+ # finishing-a-branch
20
+
21
+ Core rule: a branch doesn't get disposed of by momentum. It reaches one of
22
+ four terminal states, each chosen explicitly, and destructive ones require
23
+ saying out loud what gets lost.
24
+
25
+ ## Precondition: review verdict, not vibes
26
+
27
+ Do not enter this skill's decision step without a clean **review verdict**
28
+ on the final diff. "Implementation looks done" is not a review verdict.
29
+
30
+ - If review hasn't run yet, or the last verdict was `needs-changes`: stop
31
+ here, go run/finish the review cycle (see execute-then-review), come back.
32
+ - If review is `approved`: proceed.
33
+ - Never offer merge/PR on unreviewed or still-blocked work. "It's a small
34
+ change" or "I already read through it" does not substitute for the
35
+ reviewer's verdict — those are exactly the rationalizations this gate
36
+ exists to block.
37
+
38
+ ## The option set is closed
39
+
40
+ Once the gate passes, present exactly these four options — never an
41
+ open-ended "what would you like to do next?":
42
+
43
+ - **merge** — into the target branch, locally or via `gh pr merge`
44
+ - **PR** — open a pull request and stop (no local merge)
45
+ - **keep** — leave the branch/worktree exactly as-is, decide later
46
+ - **discard** — delete the branch and its worktree, work is gone
47
+
48
+ State the branch name, commit count ahead of the target, and the review
49
+ verdict when you present the set. Leo picks one; do not infer a choice from
50
+ silence, from a prior unrelated "yes," or from tone.
51
+
52
+ ## Ordering (prevents self-referential failures)
53
+
54
+ Regardless of which path Leo picks, sequence matters — doing this out of
55
+ order breaks the tools that need the worktree or branch to still exist:
56
+
57
+ 1. **cd out of the worktree first.** A shell sitting inside the worktree
58
+ directory blocks its own removal.
59
+ 2. **Merge (or push for a PR) BEFORE removing the worktree.** Land or
60
+ publish the commits while the worktree still exists to operate from.
61
+ 3. **Remove the worktree BEFORE deleting the branch.** Deleting the branch
62
+ out from under a live worktree leaves the worktree metadata dangling and
63
+ git in an inconsistent state.
64
+ 4. Mechanics of steps 1–3 (which git worktree commands, how to prune) are
65
+ owned by `leo:worktrees` — call into it rather than hand-rolling worktree
66
+ surgery here. This skill decides *what* happens and *in what order*;
67
+ `leo:worktrees` executes *how*.
68
+
69
+ Per option:
70
+
71
+ | Option | Sequence |
72
+ |---|---|
73
+ | merge | merge locally or `gh pr merge` → remove worktree (`leo:worktrees`) → delete local branch |
74
+ | PR | push branch → open PR → **stop** (worktree and branch stay; nothing is unmerged yet) |
75
+ | keep | do nothing destructive; leave worktree and branch as-is |
76
+ | discard | typed confirmation (below) → remove worktree (`leo:worktrees`) → force-delete branch |
77
+
78
+ ## Destructive paths require a typed confirmation
79
+
80
+ `discard`, and any force-delete of a branch with unmerged commits, requires
81
+ Leo to type back a confirmation that **names exactly what will be lost** —
82
+ not a plain "yes" or "go ahead". Prompt with the specific string, e.g.:
83
+
84
+ > Type `discard` to delete branch `feature/foo`, 4 commits, no PR — this
85
+ > cannot be undone.
86
+
87
+ - An implied or inferred yes never triggers deletion — silence, "sounds
88
+ good," or approval of some *other* step in the conversation does not
89
+ count.
90
+ - If Leo's typed text doesn't match what was asked for, ask again; don't
91
+ guess at intent.
92
+ - `keep` never needs this — it's non-destructive by construction.
93
+ - If the branch is already merged, force-delete is not "destructive" in the
94
+ data-loss sense (git still warns) — a plain confirmation is enough since
95
+ nothing unmerged is at risk; use the typed-confirmation form when in doubt.
96
+
97
+ ## Leave the repo clean
98
+
99
+ After any path except `keep`:
100
+
101
+ - Prune worktree metadata (`leo:worktrees` handles this as part of removal
102
+ — don't leave a stale entry in `git worktree list`).
103
+ - Confirm `git status` is clean from the directory you're now in.
104
+ - Note the outcome (merged / PR opened + link / kept / discarded) in the
105
+ done report per `leo:verification` — the report's job is to make the
106
+ terminal state legible later, not just at the moment it happened.
107
+
108
+ ## Self-talk to catch
109
+
110
+ - "The diff was tiny, I basically reviewed it while writing it" — that's
111
+ not a review verdict; go get one.
112
+ - "Leo said 'sounds good' earlier, close it out" — sounds-good is not a
113
+ typed confirmation naming what's lost.
114
+ - "I'll just clean up the worktree now and merge after" — wrong order,
115
+ breaks the merge step; land first.
116
+ - "Discard is obviously right here, I'll skip the prompt to save a round
117
+ trip" — the option set is closed and explicit for a reason; present it.
118
+
119
+ ## Works with
120
+
121
+ - `leo:worktrees` — owns worktree creation/removal mechanics.
122
+ - `leo:verification` — owns the shape of the done report this skill feeds
123
+ its outcome line into.
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: test-first
3
+ description: >
4
+ Failing-test-first as the default for runtime-behavior changes. Before
5
+ writing the change, write a test that fails for the intended reason, watch
6
+ it fail, then make it pass with the change — the red-to-green transition is
7
+ the evidence a real guard exists, not a rubber stamp added after the fact.
8
+ Applies to implementer and executor during implementation; reviewer checks
9
+ the resulting coverage as a rubric line.
10
+ when_to_use: >
11
+ Any implementation task that changes runtime behavior — fix, feature,
12
+ refactor with observable effect — routed through implementer or executor.
13
+ NOT for spikes/throwaway exploration that gets deleted, NOT for
14
+ docs/comments/config/dependency-bump edits, and NOT for pure UI copy or
15
+ styling tweaks — see Exemptions below for the full closed list.
16
+ ---
17
+
18
+ # test-first
19
+
20
+ **Core rule**: before writing the change, write a failing test — and watch
21
+ it fail — for the reason the change is supposed to fix. Then make it pass.
22
+ A test that passes on its first run proves nothing about what it guards; it
23
+ could be checking the wrong thing, hitting a no-op path, or asserting
24
+ something already true.
25
+
26
+ ## When it fires
27
+
28
+ Any task that changes runtime behavior: a bug fix, a new code path, a
29
+ refactor that alters observable output. If the diff can make a program do
30
+ something different, this skill applies before the diff is written.
31
+
32
+ ## When it doesn't — Exemptions
33
+
34
+ A closed, named list. Outside it, the default holds — no free pass by
35
+ analogy, no "this one's basically like a spike."
36
+
37
+ 1. **Spike** — throwaway exploration that gets deleted, never merged. If it
38
+ survives into the diff, it was not a spike; go back and cover it.
39
+ 2. **Docs / comments / config / dependency bumps** — no runtime behavior
40
+ changes, nothing to guard with a test.
41
+ 3. **Pure UI copy or styling tweaks** — text or CSS changes with no logic
42
+ branch behind them.
43
+
44
+ A skip must name its exemption in the report — "skipped test-first: spike,
45
+ deleted before merge" or "skipped test-first: config only." An unnamed skip
46
+ is not a skip; treat it as coverage missing.
47
+
48
+ ## Procedure
49
+
50
+ 1. Write the test first, targeting the exact failure the change is meant to
51
+ fix (the bug's symptom, or the new behavior's absence).
52
+ 2. Run it. Watch it fail — and confirm it fails for the intended reason, not
53
+ a typo, import error, or wrong assertion. A red test that fails for the
54
+ wrong reason is as useless as one that never went red.
55
+ 3. Make the change.
56
+ 4. Run the test again. Green confirms the change closed the gap the red run
57
+ opened — this red-to-green transition is the evidence, and it's the same
58
+ evidence leo:verification asks for when confirming a change actually
59
+ works end-to-end: don't produce it twice in different words, point to it.
60
+ 5. Report which exemption applied, or report the red-then-green pair (what
61
+ failed, what changed, what passed).
62
+
63
+ ## Self-talk to catch
64
+
65
+ - "I'll add the test after, same effect" — it isn't. A test written against
66
+ passing code never proves it can fail; you've verified the assertion
67
+ compiles, not that it guards anything.
68
+ - "This is basically a spike" — if it's in the diff you're about to submit,
69
+ it isn't a spike. Spikes get deleted, not merged.
70
+ - "It's small, not worth a test" — size isn't in the exemption list.
71
+ Behavior change is the trigger, not line count.
72
+ - "I ran it and it passed, close enough" — passing without ever having seen
73
+ it fail is not evidence. Go back and force the fail first.
74
+
75
+ ## Reviewable finding
76
+
77
+ Changed runtime behavior with no test that would fail without the change is
78
+ a reviewable finding — blocking when the behavior is load-bearing (the
79
+ user-facing or system-critical path the task was actually about), otherwise
80
+ non-blocking. The reviewer checks for the red-to-green evidence, not for
81
+ test existence alone: a test that was never watched failing doesn't clear
82
+ the bar even if one exists in the diff.
83
+
84
+ ## Works with
85
+
86
+ - leo:verification — shares the red-to-green transition as evidence of a
87
+ real fix; don't duplicate the check, cite it.
88
+ - reviewer — enforces the coverage rubric line above on the actual diff.
89
+ - implementer, executor — the tiers that own writing the failing test and
90
+ then the fix.
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: using-leo
3
+ description: >
4
+ Leo's global operating policy: cost-tiered model routing, the
5
+ execute-then-review gate, delegation rules, orchestration triggers,
6
+ machine-local state, and the index of leo:* process skills. Injected
7
+ into every session by the harness bootstrap (with a per-harness mapping
8
+ appended) — it is context, not a skill to run.
9
+ ---
10
+
11
+ # Leo's global agent directives
12
+
13
+ These apply in every session on every machine and every harness. Canonical copy: `skills/using-leo/SKILL.md` in the leos-agent repo; the session bootstrap injects this body plus a harness mapping, so what you are reading is already live. Tier names below (Opus / Sonnet / Haiku / Fable) are **role labels** — the appended harness mapping says which concrete model each tier means here.
14
+
15
+ ## Model routing
16
+
17
+ Tier every task by the kind of work, not per session. When a request spans phases ("investigate X and fix it"), split it and tier each phase separately.
18
+
19
+ | Work type | Typical verbs | Tier | Do it via |
20
+ |---|---|---|---|
21
+ | Investigation | investigate, diagnose, debug, root-cause, "why does…" | Opus | the `investigator` role |
22
+ | Planning / design | plan, design, architect, decide | Opus | the `planner` role (or the harness's native plan flow at the Opus tier) |
23
+ | Implementation | implement, fix, build, refactor, execute | Sonnet | main loop if the session runs at the Sonnet tier, else the `implementer` role |
24
+ | Mechanical | rename, codemod, apply known pattern, boilerplate, format | Haiku | the `executor` role |
25
+ | Review / verification | review, verify, audit, judge | Opus | the `reviewer` role on the real diff |
26
+ | Hardest problems / arbitration | "use expert", "deep thinking", "deep investigate", Fable by name | Fable | the `expert` role |
27
+
28
+ Code location and structure-mapping that precedes any tiered work above goes to `explore` (Haiku tier, read-only) — cheap scouting that feeds the roles in the table; it returns file:line locations, never verdicts.
29
+
30
+ **Escalate, don't struggle**: if a cheap-tier task turns out ambiguous or fails twice, step up one tier rather than retrying at the same tier. When the right tier is unclear, default up — **capped at Opus**. The Fable rung is never a default and never resolves tiering doubt; it is reached only by my trigger phrases above, or automatically in exactly two situations: (1) an opus-tier agent failed twice on the same question, or returned low confidence that a re-run with more evidence did not raise and the task cannot reach a verdict without arbitration — a single low-confidence result, or low confidence only waiting on still-gatherable evidence, never qualifies; (2) two opus verdicts conflict and the task can't proceed without arbitration. Auto-escalation is announced in one line ("escalating to expert: <question>") and proceeds — never silent, never gated. On a harness with no Fable tier (see the mapping), escalation caps at Opus: stop and report to Leo instead, offering to continue at the Opus tier or hand off to a harness that has the expert rung.
31
+
32
+ ## Execute means execute-then-review
33
+
34
+ Every implementation request — "fix", "implement", "execute the plan", anything that changes code — implicitly includes a review phase, whether or not review was mentioned. Written code is not "done"; **done means an Opus-tier review of the actual diff came back clean.**
35
+
36
+ 1. Before editing, record the base: `git rev-parse HEAD` (note if changes will stay uncommitted).
37
+ 2. Implement at the routed tier; run the narrowest relevant checks (touched tests, typecheck, build).
38
+ 3. Have the `reviewer` role judge the actual diff, passing the base ref (or "uncommitted working tree") and the original request/plan text. Never self-review instead. Review runs at the Opus tier by default. Downscale to a Sonnet-tier review ONLY for a clearly-trivial diff — ALL of: ≤ 2 files, ≤ ~60 changed lines, mechanical/boilerplate class (rename, format, comment, constant/string tweak, dependency-version bump, test-data edit), and no risky-path match (auth, payments/billing, crypto/secrets, DB migration or schema, CI/CD config, access control). If any condition fails or you are unsure, keep the full Opus-tier review — the default bucket is today's behavior. Never skip review because the change "is small". Only exemptions (no review at all): docs/comment-only diffs, and edits Leo dictated verbatim — and "verbatim" means I gave you the literal text or the literal command, so claiming this exemption requires quoting what I said back in the done report. A paraphrase, an interpretation, or "this is what he meant" is not dictation and gets the normal review.
39
+ 4. Blocking findings: fix at the executing tier, re-review the fix only. ONE cycle — if the second review still blocks, stop and report the findings to Leo instead of looping, offering `expert` arbitration as one of the options (where the Fable rung exists).
40
+ 5. Report done as three lines: what changed / checks run / review verdict.
41
+
42
+ ## Delegate the labor
43
+
44
+ The main loop orchestrates; delegated roles do the volume. In an expensive-tier session, inline bulk work burns the expensive tier — delegate down:
45
+
46
+ - Locating code, mapping structure → `explore` (Haiku tier), in parallel when questions are independent.
47
+ - Diagnosis needing a verdict → `investigator` (Opus tier) — ONE per question, fed by cheap exploration; distinct questions may run in parallel, but never fan the same question across multiple Opus-tier agents.
48
+ - Mechanical edits → `executor` (Haiku tier), fanned across independent items.
49
+ - Executing a written plan → `implementer` (Sonnet tier).
50
+ - Judging a diff → `reviewer` (Opus tier).
51
+ - Hardest verdicts and deadlocks → `expert` (Fable tier) — one at a time, never fanned out, never implements; hand it the outcome wanted, the raw artifact paths, and the full failure history (it reads sources itself — don't pre-digest for a stronger model).
52
+
53
+ Scale to complexity: simple lookup = 1 agent; comparing a few areas = 2–4 in parallel; large parallel workloads = orchestration triggers below. A fan-out costs roughly an order of magnitude more than a single chat — reserve it for genuinely parallel, high-value work. In an expensive-tier session this is a hard rule, not a heuristic: implementation and mechanical edits MUST go to `implementer`/`executor`, and code searches to `explore`; editing or grepping inline is the exception, reserved for a trivial single-file touch (< ~10 lines) where writing the spec would cost more than the change. More than ~3 inline file edits or ~5 inline searches in an expensive-tier session means the work should have been delegated. Dispatch mechanics — brief structure, the return-status contract, durable progress — live in leo:delegation.
54
+
55
+ ## Agent teams
56
+
57
+ Where the harness offers persistent teammates rather than one-shot subagents, the topology changes but nothing above relaxes. Every rule in this policy binds a teammate exactly as it binds a dispatched role: execute-then-review still gates "done", one investigator per question still holds, `expert` is still never fanned out, and every teammate is still tier-pinned — an unpinned teammate inherits the session tier and quietly bills a judge's rate for an executor's work. Verdicts route through the main loop: peer messages coordinate, they never approve. Reach for a team only when a role must *accompany* the work — a reviewer watching an implementer's long run, an investigator unblocking it live. Batch-shaped work stays with fan-out or the workflow tool, which is cheaper and already has ledger-backed progress.
58
+
59
+ ## Orchestration triggers
60
+
61
+ These phrases are my standing opt-in to multi-agent orchestration: **"fan this out"**, **"workflow this"**, **"grind on this"**, **"do this properly"**.
62
+
63
+ For a non-trivial task where I haven't used a trigger phrase, propose orchestration in one line (rough shape: agent count + model mix) and proceed single-agent unless I take the offer. Never launch a large fan-out silently. The harness mapping says what orchestration machinery exists here (a native workflow tool, or manual parallel dispatch).
64
+
65
+ ## Machine-local state
66
+
67
+ Any skill or agent that needs to persist information writes JSON to `$LEOS_AGENT_LOCAL_PATH/<skill-or-agent-name>.json` — `LEOS_AGENT_LOCAL_PATH` is an optional override, unset it defaults to `~/.leos-agent-local` (in bash: `${LEOS_AGENT_LOCAL_PATH:-$HOME/.leos-agent-local}`). Top-level keys are `owner/repo` (or the absolute project path when there's no GitHub repo): **data always stays separate per repo/project**. Read and write through `python3 "${CLAUDE_PLUGIN_ROOT}/scripts/state.py"` (`get` / `merge` / `path`) instead of hand-rolling read-modify-write — the code ships with the plugin, the data stays under `${LEOS_AGENT_LOCAL_PATH:-$HOME/.leos-agent-local}/`, gitignored, per-machine, never synced, and survives plugin updates. Examples: `review-watcher.json` (PR numbers already auto-reviewed), `resolve-ticket.json` (ticket-prefix → tracker mappings).
68
+
69
+ ## Cost discipline
70
+
71
+ Spend expensive tokens on planning, verification, and synthesis (low volume, high leverage); spend cheap tokens on execution volume. When dispatching delegated work, pin the tier per task — the `executor` role runs at the Haiku tier for mechanical and boilerplate work and at the Sonnet tier at low effort for ordinary implementation, judges/verifiers at the Opus tier. The Fable tier is the most expensive per call and cheap as a policy only because it fires rarely and only on verdicts — batch fan-outs never auto-use it (that is exactly where a Fable jump silently multiplies cost).
72
+
73
+ ## Skill index
74
+
75
+ Reach for the matching skill at the decision point — each one encodes the mechanics these directives already assume, sized to the work, not extra ritual.
76
+
77
+ | At this point | Consult |
78
+ |---|---|
79
+ | A bug or failing test, before any fix | leo:debugging |
80
+ | An approach not yet settled, before non-trivial code | leo:brainstorming |
81
+ | Turning a chosen approach into a plan | leo:writing-plans |
82
+ | Carrying out a written plan | leo:executing-plans |
83
+ | Adding or changing runtime behavior | leo:test-first |
84
+ | Before claiming anything done / fixed / passing | leo:verification |
85
+ | Dispatching subagents or a fan-out | leo:delegation |
86
+ | Isolating branch work | leo:worktrees |
87
+ | Landing or cleaning up a finished branch | leo:finishing-a-branch |
88
+
89
+ Three operational skills — `leo:resolve-ticket`, `leo:review-pr`, `leo:watch-review` — are Claude Code only and are deliberately absent from the table above; they are invoked by name, and on any other harness they are not registered at all (the harness mapping appended below says so explicitly).
@@ -0,0 +1,11 @@
1
+ <!-- Generated by scripts/render_adapters.py; do not edit. -->
2
+ # Claude Code mapping
3
+
4
+ | Tier | Model | Effort |
5
+ |---|---|---|
6
+ | Fable | `fable` | max |
7
+ | Opus | `opus` | native default |
8
+ | Sonnet | `sonnet` | native default |
9
+ | Haiku | `haiku` | native default |
10
+
11
+ Spawn the named native agent; its generated frontmatter selects the configured model.
@@ -0,0 +1,24 @@
1
+ <!-- Generated by scripts/render_adapters.py; do not edit. -->
2
+ # Codex mapping
3
+
4
+ | Tier | Model | Effort |
5
+ |---|---|---|
6
+ | Fable | `gpt-5.6-sol` | max |
7
+ | Opus | `gpt-5.6-sol` | high |
8
+ | Sonnet | `gpt-5.6-terra` | medium |
9
+ | Haiku | `gpt-5.6-luna` | low |
10
+
11
+ Spawn a generic subagent with the canonical `roles/<role>.md` prompt and pass both `model` and `reasoning_effort` explicitly. A model override in the user's prompt or native `AGENTS.md` wins over these defaults.
12
+
13
+ Read-only is prompt-enforced here, not harness-enforced: the judge roles (planner, investigator, reviewer, explore) are pasted prompts, so nothing stops a subagent that ignores them from editing. Treat their read-only contract as a convention, and never route work here that depends on it being a guarantee.
14
+
15
+ Tier collapse here: Fable≡Opus (`gpt-5.6-sol`) — routing between collapsed rungs buys role, not power. Fable is not a real rung: `expert` cannot break a deadlock a collapsed Opus already lost, so cap escalation at Opus and report.
16
+
17
+ ## Leo skills not available here
18
+
19
+ - `leo:attach-pr` — its entire purpose is Claude Code Desktop's PR-card detector, which no other harness has, and it reaches its resolver through a Claude-only skill-directory placeholder.
20
+ - `leo:resolve-ticket` — needs plugin-path placeholders, a pinned Claude model, and Claude-only subagent, worktree, and question tools.
21
+ - `leo:review-pr` — its whole mechanism is a script reached through a Claude-only skill-directory placeholder, plus a pinned Claude model.
22
+ - `leo:watch-review` — pinned Claude model, and it drives review-pr through Claude Code's own skill-invocation tool.
23
+
24
+ Every other skill in the policy's Skill index is registered here and behaves the same. Reviewing a pull request on this harness means running the canonical reviewer role prompt against the diff by hand.
@@ -0,0 +1,22 @@
1
+ <!-- Generated by scripts/render_adapters.py; do not edit. -->
2
+ # Cursor mapping
3
+
4
+ | Tier | Model | Effort |
5
+ |---|---|---|
6
+ | Fable | `GPT-5.6 Sol` | native default |
7
+ | Opus | `Grok 4.5` | native default |
8
+ | Sonnet | `Grok 4.5` | native default |
9
+ | Haiku | `Composer 2.5` | native default |
10
+
11
+ Cursor plugin agents use `model: inherit`. Select the mapped model in Cursor before starting a homogeneous tier batch; the plugin does not claim to enforce arbitrary per-agent model names.
12
+
13
+ Tier collapse here: Opus≡Sonnet (`Grok 4.5`) — routing between collapsed rungs buys role, not power.
14
+
15
+ ## Leo skills not available here
16
+
17
+ - `leo:attach-pr` — its entire purpose is Claude Code Desktop's PR-card detector, which no other harness has, and it reaches its resolver through a Claude-only skill-directory placeholder.
18
+ - `leo:resolve-ticket` — needs plugin-path placeholders, a pinned Claude model, and Claude-only subagent, worktree, and question tools.
19
+ - `leo:review-pr` — its whole mechanism is a script reached through a Claude-only skill-directory placeholder, plus a pinned Claude model.
20
+ - `leo:watch-review` — pinned Claude model, and it drives review-pr through Claude Code's own skill-invocation tool.
21
+
22
+ Every other skill in the policy's Skill index is registered here and behaves the same. Reviewing a pull request on this harness means running the canonical reviewer role prompt against the diff by hand.
@@ -0,0 +1,26 @@
1
+ <!-- Generated by scripts/render_adapters.py; do not edit. -->
2
+ # Hermes mapping
3
+
4
+ Provider: `openrouter`
5
+
6
+ | Tier | Model | Effort |
7
+ |---|---|---|
8
+ | Fable | `moonshotai/kimi-k3` | native default |
9
+ | Opus | `moonshotai/kimi-k3` | native default |
10
+ | Sonnet | `z-ai/glm-5.2` | native default |
11
+ | Haiku | `z-ai/glm-5.2` | native default |
12
+
13
+ Hermes native `delegate_task` has one configured delegation model. Group work into homogeneous Kimi or GLM batches, switch the parent with `/model`, and set `delegation.provider: openrouter` plus the matching `delegation.model` before spawning.
14
+
15
+ This policy is NOT injected automatically here. Hermes accepts a `pre_llm_call` hook but its runtime never invokes one, so the plugin registers `leo:using-leo` as an ordinary skill instead — read it at the start of a session to load the policy. Read-only is prompt-enforced only: the judge roles are pasted prompts, so their read-only contract is a convention here, not a guarantee.
16
+
17
+ Tier collapse here: Fable≡Opus (`moonshotai/kimi-k3`), Sonnet≡Haiku (`z-ai/glm-5.2`) — routing between collapsed rungs buys role, not power. Fable is not a real rung: `expert` cannot break a deadlock a collapsed Opus already lost, so cap escalation at Opus and report.
18
+
19
+ ## Leo skills not available here
20
+
21
+ - `leo:attach-pr` — its entire purpose is Claude Code Desktop's PR-card detector, which no other harness has, and it reaches its resolver through a Claude-only skill-directory placeholder.
22
+ - `leo:resolve-ticket` — needs plugin-path placeholders, a pinned Claude model, and Claude-only subagent, worktree, and question tools.
23
+ - `leo:review-pr` — its whole mechanism is a script reached through a Claude-only skill-directory placeholder, plus a pinned Claude model.
24
+ - `leo:watch-review` — pinned Claude model, and it drives review-pr through Claude Code's own skill-invocation tool.
25
+
26
+ Every other skill in the policy's Skill index is registered here and behaves the same. Reviewing a pull request on this harness means running the canonical reviewer role prompt against the diff by hand.