Belay is a Claude Code plugin for people who hand work to subagents and run long sessions. It does four things:
- It picks the model and effort for each delegated task by risk. Mechanical work runs cheap, critical work runs strong, and no worker inherits your session model without a decision.
- It gets a second opinion from a different model family at two points: before a plan is executed, and before a risky change merges.
- It keeps progress in a checkpoint file, so any session on any model can pick up where the last one stopped.
- It carries traps, decisions and your standing instructions across conversation compactions, so a long session doesn't forget them.
Belay is four skills and a set of hooks. It has no queues, daemons or state stores. If a piece is missing, you get plain Claude Code.
A real session (full transcript, or replay it with asciinema play docs/demo.cast).
The first time Belay meets a project, it asks one question:
You: Add CSV export for invoices in billflow.
Claude: Billflow has no
.claude/workflow.mdyet. It looks like a pre-launch app, so I'd say tier T2. Confirm? (you confirm) Saved. Routing: L2 standard task, so Sonnet at medium effort with a spot-check review.
The answer is saved in the project, and the question doesn't come back.
As a plugin, which is the recommended way. In Claude Code:
/plugin marketplace add cwaku/belay
/plugin install belay@belay
Or as a plain copy:
git clone https://github.com/cwaku/belay.git
cd belay && ./install.shPick one. Installing both ways registers every skill and every hook twice.
install.sh copies the skills and hooks into ~/.claude (or $CLAUDE_CONFIG_DIR if you set it) and adds the hook entries to settings.json. It backs that file up first, keeps its permissions, and writes through a symlink instead of replacing it. A second run changes nothing, because it replaces its own hook entries instead of adding a second set.
Skills trigger by their description, which works most of the time. A standing instruction in your global CLAUDE.md is stronger, because it loads into every session. install.sh copies templates/CLAUDE.md there if you don't have one. If you do, it leaves yours alone and you merge the few bullets yourself.
- Claude Code with plugin support.
- bash. The scripts run on bash 3.2, which is what macOS ships.
- python3, 3.8 or newer, for the compaction hooks to save and restore notes. Without it they only shape the summary.
- Optionally the Codex CLI, logged in with
codex login, for the two review skills. Without it they say so and fall back to internal review.
The review skills also use two optional tools. jq finds the newest Sol or Astra model in the Codex CLI's model list (Astra for the first pass of a gate, Sol for plan reviews and re-reviews). Without jq they use Codex's configured default. timeout (or gtimeout) cuts off a hung review. Without it a review runs with no cap. To use a different reviewer CLI, edit the two command lines in those skills.
| Skill | What it does |
|---|---|
task-router |
Decides who does each piece of work. Project tier (T1 production, T2 personal product, T3 throwaway) times task level (L1 mechanical up to L4 critical) picks the model, the effort, and how much review the result gets. Reviewers are routed too, so a spot-check runs cheaper than a phase gate. When a worker fails, it retries at higher effort before moving to a bigger model. A task type that passes three reviews in a row with no findings moves down one level. |
codex-plan-review |
Sends your plan to OpenAI Codex before any work is dispatched. Only blocking findings (correctness, security, unmet requirements) can send a plan back. The loop stops at four passes, or sooner if it stalls, and every finding is checked against the code before it changes anything. |
codex-gate-review |
The same reviewer at phase gates and on L4 tasks. It reads the real diff, the test output from an actual run, and your acceptance criteria, never summaries. If Codex is down, the review ledger says so and the internal review carries on alone. An outage never blocks a merge. |
handoff-checkpoint |
Writes down where things stand after each batch of work: the task graph, decisions made, test state, a ledger of the reviews that ran, and a required "next action" line. A resuming session checks git before it redispatches anything, so finished work isn't done twice. |
Claude Code replaces a long conversation with one summary when you run /compact, when the context fills up, and when the conversation sits idle. In Claude Code 2.1.332, idle compaction fired about 55 minutes after the last reply once a conversation was past 200k tokens. Other versions may differ.
The next compaction summarizes that summary, so detail fades each round. Belay's hooks keep the parts that matter out of that chain:
- Before a summary is written, they ask the summarizer to end it with a handoff note: goal, active files, current state, changes made, failed attempts, traps, decisions, your standing instructions in your own words, how to verify, what is still running, and the next step.
- They save every summary to disk, word for word, with the branch and commit of the session's worktree.
- Right after a compaction, they print a block into the session with what earlier notes recorded and what the repo looks like now.
- The live state of up to 8 git worktrees, the session's own first: branch, commit and how many files are uncommitted.
- Where your checkpoint file is and how long since it changed.
- The failed attempts, traps, decisions and standing instructions from this session's earlier notes, newest first, with repeats dropped. Each note shows how many commits landed since it was written.
- The messages you typed before the previous compaction, newest first, dated and quoted.
The block is at most about 8KB. When everything doesn't fit, the notes and the messages split the space and the oldest entries drop off. Git work in one run stops after about 5 seconds, and the block then leaves out the parts that need git.
The block is written so that old text isn't taken for a fresh request:
- It says the earlier notes are older than the summary, and that the summary and you win where they differ.
- Messages under 60 characters are left out, so a bare "push" or "go ahead" is never replayed.
- It ends by saying nothing in it is a new request.
Notes are plain text files in ~/.claude/belay/handoff/<project>/<session>/, or under $CLAUDE_CONFIG_DIR if you set it. BELAY_HANDOFF_DIR overrides both. Only you can read them, and deleting them is safe. Errors go to errors.log in the handoff folder, never into your session.
- The hook can't tell an instruction you lifted from one a summary lost. An old entry still prints, under the line saying the summary wins. The summary instructions ask the summarizer to mark a lifted instruction as lifted instead of dropping it.
- Old messages of 60 characters or more are replayed, dated and marked as history.
- The checkpoint line counts commits by commit date, so a rebase raises the count.
- The restore runs from the
SessionStarthook, which Claude Code fires after every compaction. ThePreCompactandPostCompacthooks add a second copy of the instructions and save each summary the moment it's written. Whether those two fire on idle compactions hasn't been checked, and nothing depends on them: a summary they miss is saved at the next compaction. - The note format was tried in real sessions only with manual compactions of short conversations. How closely a summarizer follows it on a very long session hasn't been measured.
If you'd rather Claude Code didn't compact idle conversations at all, set "idleCompaction": false in your settings.json.
You prompt the way you always have. Belay activates on delegation: a plan being executed, or a task being handed to a subagent. It doesn't act on every message.
- In a project you've already tiered, routing is silent. The decision shows up in the task brief.
- In a new project you get one tier question, once.
- Small direct work, like fixing a typo, activates nothing. Work you don't delegate runs on your session model, and Belay never switches that model for you. When it routes, it compares the session model to the project's tier (T1
fable, T2opus, T3sonnet) and tells you once if you're running above it. Your choice always wins. - A big feature in a production project gets a plan review, routed dispatch, checkpoints along the way and a gate review at the end. The merge always stops and asks you.
Activation is instruction-driven, so a session can skip it. Saying "use task-router" brings it back. For hard enforcement, add a PreToolUse hook that flags any Agent call without an explicit model.
Each project declares its tier in <project>/.claude/workflow.md (template), along with its own critical surfaces: the things that always get the most protection. For an API that might be auth endpoints and data deletion. For a trading system, order execution.
If the file doesn't exist, task-router infers a tier, confirms it with you once, and writes the file. The tier shifts the whole review ladder, so coursework doesn't pay for production-grade review and production code doesn't get coursework-grade review.
Belay installs its own four skills and its hooks. The rest of your environment (plugins, personal skills, your own hooks, your global CLAUDE.md) lives in ~/.claude/ and doesn't move by itself. Two scripts handle that: export-setup.sh bundles your setup on the old machine, and import-setup.sh restores it on the new one.
The scripts live in this repo, not in the marketplace plugin. To export or import, you need a clone of this repo on that machine.
On the old machine, from a belay clone:
./scripts/export-setup.sh # writes my-setup/ (plugin names, skills, hooks, CLAUDE.md)Commit my-setup/ to a dotfiles repo and push it.
On the new machine, with belay installed and your dotfiles cloned:
git clone https://github.com/cwaku/belay.git
cd belay
./scripts/import-setup.sh --from ~/your-dotfiles--from reads the setup from your dotfiles repo instead of a local my-setup/. Two flags skip the picker:
./scripts/import-setup.sh --from ~/your-dotfiles --recommended # the plugins that pair with Belay
./scripts/import-setup.sh --from ~/your-dotfiles --all # everything you exportedThe importer installs jq through your system package manager if it's missing, backs up ~/.claude/settings.json before merging, and won't overwrite an existing skill, hook script or global CLAUDE.md, so it's safe to run again if a step fails.
It walks through each plugin and skill and asks what you want. Three plugins pair with Belay and default to yes: superpowers for plan execution, claude-mem for memory across sessions, and code-review for the internal pass the gate review runs beside. Everything else defaults to no.
Hooks are the scripts in ~/.claude/hooks/ and the settings.json entries that run them. The exporter copies both, and leaves out entries that run anything else. A hook runs by itself on every event it matches, so the importer installs them only with --all or a yes at the prompt, which lists the scripts and commands first. --recommended skips them. The importer registers only commands that run a script in ~/.claude/hooks/, and stops before changing anything if hooks.json holds any other. That check can't vouch for the scripts themselves, so import only a setup you trust. A hook that depends on a skill, a plugin or a tool like jq needs that on the new machine too.
An export holds plugin names, marketplace repos, your personal skills, your hook scripts and your global CLAUDE.md. The last three can hold private text, so read them before you publish, and scan the folder:
grep -rniE "api[_-]?key|secret|token|password" my-setup/The export folder is gitignored in this repo. The author's claude-dotfiles shows the layout that --from reads.
Before you publish:
- Exported skills are often someone else's work. Keep their attribution and check the upstream license, or leave them out:
EXPORT_SKIP="omarchy" ./scripts/export-setup.sh. - Plugin data stays put. A memory plugin's database doesn't travel, only its installation.
- Marketplaces you added interactively can't be read from settings. The importer detects those and prints the
/plugincommands that finish the job.
The reviewer is a different model family because a model reviewing its own family's output shares its blind spots. That second opinion is spent at plans and gates only. Reviewing every task adds latency without finding more defects.
Review loops are capped because two reviewers that disagree can loop forever. A loop gets a third and a fourth pass only while each pass finds fewer confirmed problems than the last. When a refuted finding comes back or the count stops falling, you decide, and the override is logged.
The skills name models by family (sonnet, opus, fable), and the Codex skills look up their model at run time. Nothing needs editing when a new version ships.
Belay leaves out routing that learns from data, agent federation, background workers and external state stores. The routing it has is a fixed table and a few written rules. Heavier platforms exist if you want those. Every piece Belay doesn't have is a piece that can't break or need maintenance.
Project-specific skills, like a repo's own preflight checks, belong in that repo's .claude/skills/, versioned with the code they protect.
Bug reports and pull requests are welcome. CONTRIBUTING.md covers what fits, how to run the tests, and the rules for hooks and skills. Report security problems privately, as SECURITY.md describes.
The tests need only python3:
python3 -m unittest discover -s testsCI runs them on Linux and on macOS for every pull request.