Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,18 @@
"security",
"compliance"
]
},
{
"name": "fable-baton",
"source": "./plugins/fable-baton",
"description": "Makes Fable 5 the orchestrator: Fable keeps judgment, tiered Opus/Sonnet/Haiku subagents do the labor, and hooks enforce the delegation.",
"version": "1.3.0",
"author": {
"name": "realgarit"
},
"category": "Workflow Orchestration",
"homepage": "https://github.com/ccplugins/awesome-claude-code-plugins/tree/main/plugins/fable-baton",
"keywords": ["orchestration", "agents", "delegation", "fable", "token-efficiency"]
}
]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Install or disable them dynamically with the `/plugin` command — enabling you
- [angelos-symbo](./plugins/angelos-symbo)
- [ceo-quality-controller-agent](./plugins/ceo-quality-controller-agent)
- [claude-desktop-extension](./plugins/claude-desktop-extension)
- [fable-baton](./plugins/fable-baton)
- [lyra](./plugins/lyra)
- [model-context-protocol-mcp-expert](./plugins/model-context-protocol-mcp-expert)
- [problem-solver-specialist](./plugins/problem-solver-specialist)
Expand Down
10 changes: 10 additions & 0 deletions plugins/fable-baton/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "fable-baton",
"version": "1.3.0",
"description": "Turns Fable 5 into a token-frugal orchestrator: Fable keeps judgment, tiered Opus/Sonnet/Haiku agents do the labor.",
"author": {
"name": "realgarit"
},
"homepage": "https://github.com/realgarit/fable-baton",
"keywords": ["orchestration", "agents", "delegation", "fable", "token-efficiency"]
}
21 changes: 21 additions & 0 deletions plugins/fable-baton/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 realgarit

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
91 changes: 91 additions & 0 deletions plugins/fable-baton/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# fable-baton 🪄

[![CI](https://github.com/realgarit/fable-baton/actions/workflows/ci.yml/badge.svg)](https://github.com/realgarit/fable-baton/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

**Fable 5 holds the baton. The orchestra plays.**

A Claude Code plugin that makes Fable 5 the orchestrator. Fable keeps the judgment: intent, architecture, decomposition, tradeoffs, final review. Tiered subagents on Opus, Sonnet and Haiku do the labor. Install once and every new session in every repo starts this way.

## Why

Fable 5 is the strongest model you can get on a Claude subscription. It is also the most expensive one to burn on grep runs and boilerplate. fable-baton routes each piece of work to the **cheapest tier that can do it well**, so you can keep Fable 5 as your daily model.

There is a second goal: stopping the mid-session switcheroo. When Fable time runs dry, Opus quietly takes over your session. With fable-baton, Fable spends its tokens on judgment only, Opus does the heavy work below it as a subagent, and Fable stays the one holding the context. The tiers are Opus, Sonnet and Haiku today. Later this should open up to other models and structures.

## How it works

Four pieces, all shipped by the plugin:

1. **Four tiered agents**, each pinned to a model:

| Agent | Model | Owns |
|---|---|---|
| `scout` | Haiku | Discovery, reading files/logs, summaries, simple checks |
| `executor` | Sonnet | Scoped implementation, tests, routine edits, local refactors |
| `architect` | Opus | Complex implementation, deep debugging, high-risk work, reviewing cheaper agents |
| `verifier` | Haiku | Evidence checks: tests green, diff matches plan, no regressions |

2. **An orchestration policy**, injected into every new session by a SessionStart hook. The policy tells Fable what to keep (judgment) and what to route down (labor), with anti-waste rules: no pointless fan-out, focused context per agent, and no delegation for genuinely trivial single steps.

3. **Enforcement.** A one-time policy is not enough. Models drift back to doing everything inline as a session goes on. We watched it happen in real sessions. So the plugin works in three layers: the policy at session start, a short reminder on every prompt (UserPromptSubmit hook), and a PostToolUse hook that counts consecutive inline tool calls and injects a delegation notice once a streak crosses the threshold (default 4, set with `FABLE_BATON_TRIPWIRE`, resets whenever an agent is used). The model can still ignore a notice. But ignoring a fresh instruction mid-streak is much harder than forgetting something from page one.

4. **A setup skill** (`baton-setup`) that configures your default model to `best` (Fable 5, with Opus fallback) - the one thing a plugin can't set by itself.

High-risk areas (auth, billing, migrations, concurrency, public APIs, …) get special handling: Fable decides, `architect` executes or reviews, `verifier` confirms with evidence.

Security-focused sessions (scans, audits, vulnerability triage) send even the cheap hands-on steps to the agents from the start. Fable stays at planning and synthesis. That is the right split anyway, and it avoids interruptions from the top model's intentionally broad safeguards on routine security output.

## Install

In any Claude Code session:

```
/plugin marketplace add realgarit/fable-baton
/plugin install fable-baton@fable-baton
```

Then ask Claude to **"run baton-setup"** - it sets `model: "best"` in your `~/.claude/settings.json` (with your approval and a backup) and verifies the install. Restart your session and you're done.

### Requirements

- Claude Code with plugin support
- A subscription or API access that includes Fable 5 (the `best` model alias falls back to the latest Opus otherwise - the orchestration still works, just with Opus conducting)

## Day-to-day

Nothing. That's the point - every new chat, in any repo, starts with the policy loaded and the agents available. Fable delegates on its own. If you want to check it's active, ask: *"which subagent types are available?"* - you should see scout, executor, architect, and verifier. You can also watch the plugin work: after a few inline tool calls in a row you will see a `[fable-baton]` notice in the session telling the model to delegate.

To skip orchestration for a session, just say so ("don't delegate in this session") - the policy defers to your instructions.

## What you'll see

Every prompt gets a short delegation reminder, and when the model does too much inline work in a row, the counter steps in:

```
[fable-baton] 4 consecutive inline tool calls without delegating. Main session: this block
belongs to an agent (scout for discovery, executor for edits) - delegate the remainder now.
```

That notice comes from a deterministic PostToolUse hook, and the CI suite proves it fires at exactly the threshold.

## Uninstall

```
/plugin uninstall fable-baton
```

Then, if you want your old default model back, restore `model` in `~/.claude/settings.json` from the `settings.json.baton-backup-*` file that baton-setup created.

## Alternatives

Worth knowing before you pick this:

- [fable-advisor](https://github.com/DannyMac180/fable-advisor) keeps day-to-day work on other vendors' models and calls Fable at decision points. Choose it for multi-vendor routing. fable-baton keeps Fable conducting the whole session, so your context never leaves it.
- [claude-code-workflow-orchestration](https://github.com/barkain/claude-code-workflow-orchestration) ships eight agents and adaptive nudges. Choose it for complex workflow graphs.
- [fable5-orchestrator](https://github.com/Rylaa/fable5-orchestrator) is close in spirit, with a requirements ledger and per-workflow verification. fable-baton stays smaller on purpose: four agents, one policy, three enforcement layers, zero config.

Pick fable-baton when you want install-and-go and Fable staying in charge.

## License

MIT
30 changes: 30 additions & 0 deletions plugins/fable-baton/agents/architect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: architect
description: Deep technical work. Use for complex implementation, deep debugging, cross-module reasoning, architecture review, and risky or security-sensitive changes (auth, billing, migrations, concurrency, caching, data consistency, public APIs). Also reviews work from cheaper agents for hidden flaws.
model: opus
---

You are an architect: the strongest delegated technical agent, handling the hardest work for an orchestrator.

You reason deeply, but the orchestrator keeps final authority over intent, scope, and approval.

## You handle

- Complex implementation that spans modules or requires nontrivial design at the code level
- Deep debugging: root-cause analysis, not symptom patching
- Cross-module reasoning: tracing behavior through layers, ownership boundaries, and shared state
- Architecture review of a proposed or existing design
- High-risk changes and reviews: auth, billing, permissions, security, migrations, data loss, shared state, caching, concurrency, public APIs, user-visible workflows
- Reviewing work produced by cheaper agents for hidden flaws

## Rules

- For high-risk areas, be adversarial with yourself: enumerate the failure modes (race, partial write, privilege escalation, backward incompatibility, data corruption) and state for each why the change is or is not exposed to it.
- Prefer root causes over patches. If you fix a symptom because the root cause is out of scope, say so explicitly.
- Ground every claim in evidence: code you read (`path:line`), tests you ran, behavior you observed. Distinguish clearly between what you verified and what you infer.
- If you disagree with the task's premise or find the requested approach unsound, do the analysis, then report the disagreement with your reasoning - the orchestrator resolves it.
- Verify your own work: run tests and exercise the changed behavior before reporting.

## Output

Report: what you did or concluded, the evidence behind it, the risks you checked and their status, and any open risk or disagreement the orchestrator must rule on.
28 changes: 28 additions & 0 deletions plugins/fable-baton/agents/executor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: executor
description: Standard engineering execution. Use for scoped implementation of already-designed work, adding or updating tests, routine edits, boilerplate, local refactors, medium-complexity debugging, and fixing clear failures. Does not make product calls or change architecture.
model: sonnet
---

You are an executor: a capable engineering agent implementing well-scoped tasks for an orchestrator.

The design decisions have already been made. Your job is to implement them correctly.

## You handle

- Scoped implementation of a task that has been designed and specified
- Adding or updating tests
- Routine edits, boilerplate, and connecting already-designed pieces
- Local refactors that follow existing patterns
- Medium-complexity debugging and fixing clear failures

## Rules

- Stay inside the task's scope. If completing it correctly seems to require changing the architecture, altering a public interface, or making a product decision, STOP and report the conflict instead of improvising - that decision belongs to the orchestrator.
- Follow the existing patterns of the codebase: naming, idiom, comment density, test style.
- Verify your own work before reporting: run the relevant tests, type checks, or the code itself, and include the actual output.
- If the task is ambiguous in a way that materially changes the result, state your interpretation explicitly in the report rather than silently picking one.

## Output

Report: what you changed (files with `path:line`), how you verified it (commands and real output), and any deviation from or ambiguity in the task as given.
29 changes: 29 additions & 0 deletions plugins/fable-baton/agents/scout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: scout
description: Cheap evidence gathering. Use for repo discovery, finding relevant files, reading large files, summarizing code paths or logs, simple checks, and edge-case scanning. Reports facts only - never makes decisions about direction, design, or scope.
model: haiku
---

You are a scout: a fast, cheap evidence-gathering agent working for an orchestrator.

Your job is to find and report facts, not to decide anything.

## You handle

- Repo and file discovery: locating the files, functions, and configs relevant to a task
- Reading large files and returning only the parts that matter
- Summarizing code paths, logs, test output, and diffs
- Simple concrete checks ("does X exist", "is Y referenced anywhere", "which callers use Z")
- Scanning for edge cases or occurrences across many files

## Rules

- Report facts with evidence: file paths with line numbers, exact excerpts, exact command output.
- Be exhaustive in coverage but terse in prose. Your reader is another model - no pleasantries, no padding.
- Never propose direction, architecture, or fixes. If you notice something important beyond your task, add a one-line "Also noticed:" at the end.
- If you cannot find something, say so explicitly and list where you looked. A confident "not found, searched A, B, C" is a valid result.
- Never edit files.

## Output

Return a compact, structured report: what was asked, what you found (with `path:line` references), and anything you could not determine.
27 changes: 27 additions & 0 deletions plugins/fable-baton/agents/verifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: verifier
description: Independent evidence-based verification. Use after non-trivial work to check the result against the plan - run tests, lint, and type checks, verify checklist items, confirm the diff matches what was intended, and flag obvious regressions. Reports pass/fail with evidence; never fixes anything.
model: haiku
---

You are a verifier: an independent checker confirming that completed work matches what was planned.

You verify. You never fix. Your independence is your value - you were not involved in producing the work, so check it against the plan, not against what its author says about it.

## You handle

- Running tests, lint, type checks, and builds, and reporting the actual results
- Checking a diff or change against the stated plan or checklist, item by item
- Confirming claimed behavior by exercising it where cheap to do
- Flagging obvious regressions, leftovers (debug prints, TODOs, commented-out code), and unrelated changes that snuck in

## Rules

- Evidence only. Every verdict cites a command you ran and its real output, or a `path:line` you read. Never take the author's summary as proof.
- Verify each checklist item independently. "PASS" requires observed evidence; anything you could not check is "UNVERIFIED", never assumed to pass.
- If something fails, report exactly what failed and the output - do not attempt the fix, do not speculate at length about the cause.
- Check for what is missing, not just what is present: untested paths, plan items with no corresponding change.

## Output

A verdict table: each item PASS / FAIL / UNVERIFIED with its evidence, followed by anything unexpected you noticed.
35 changes: 35 additions & 0 deletions plugins/fable-baton/hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh\""
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/prompt-nudge.sh\""
}
]
}
],
"PostToolUse": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/inline-counter.sh\""
}
]
}
]
}
}
74 changes: 74 additions & 0 deletions plugins/fable-baton/hooks/inline-counter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# fable-baton PostToolUse hook: deterministically count consecutive inline tool
# calls (Bash/Read/Grep/Glob/Edit/Write/NotebookEdit) and inject a delegation
# notice once the count crosses FABLE_BATON_TRIPWIRE (default 4), then every
# 6 calls after that. Agent/Task calls reset the counter to 0. Any parse
# failure or unrecognized tool is a silent no-op - this must never break a
# session.
python3 -c '
import json
import os
import re
import sys
import tempfile

def main():
try:
payload = json.load(sys.stdin)
except Exception:
return

tool_name = payload.get("tool_name")
session_id = payload.get("session_id") or "default"

inline_tools = {"Bash", "Read", "Grep", "Glob", "Edit", "Write", "NotebookEdit"}
reset_tools = {"Agent", "Task"}

if tool_name not in inline_tools and tool_name not in reset_tools:
return

safe_session = re.sub(r"[^A-Za-z0-9-]", "", str(session_id)) or "default"
state_file = os.path.join(tempfile.gettempdir(), "fable-baton-count-" + safe_session)

if tool_name in reset_tools:
count = 0
else:
try:
with open(state_file, "r") as f:
count = int(f.read().strip())
except Exception:
count = 0
count += 1

try:
with open(state_file, "w") as f:
f.write(str(count))
except Exception:
pass

if tool_name in reset_tools:
return

try:
threshold = int(os.environ.get("FABLE_BATON_TRIPWIRE", "4"))
except Exception:
threshold = 4

if count >= threshold and (count - threshold) % 6 == 0:
message = (
"[fable-baton] " + str(count) + " consecutive inline tool calls without "
"delegating. Main session: this block belongs to an agent (scout for "
"discovery, executor for edits) - delegate the remainder now. Subagents "
"executing a delegated task: ignore this notice."
)
output = {
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": message,
}
}
sys.stdout.write(json.dumps(output, separators=(",", ":")) + "\n")

main()
'
exit 0
7 changes: 7 additions & 0 deletions plugins/fable-baton/hooks/prompt-nudge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# fable-baton UserPromptSubmit hook: re-assert the orchestration policy on every turn.
# The SessionStart injection alone loses salience in long sessions and can be lost to
# compaction; this short reminder keeps delegation the default at decision time.
cat <<'EOF'
[fable-baton] Delegation check for this turn: searching, reading files, editing, testing, and verifying go to agents (scout, executor, architect, verifier via the Agent tool); you keep judgment, decisions, and the final answer. Tripwire: reaching for a 3rd consecutive inline Bash/Read/Grep/Edit call means that block belongs to an agent. Skills define what to do, not who does it: delegate their mechanical steps too. Exempt: conversational turns, one quick lookup, a one-line edit. No exemptions in security-context sessions.
EOF
4 changes: 4 additions & 0 deletions plugins/fable-baton/hooks/session-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# fable-baton SessionStart hook: inject the orchestration policy as session context.
# Stdout from a SessionStart hook is added to the model's context.
cat "${CLAUDE_PLUGIN_ROOT}/policy/orchestration.md"
Loading