chain

chain is a command for Claude Code from enricai/leerie. It costs 32 tokens per session (1,614 once invoked), scanned A, original, MIT.

A command for managing a chain of Leerie runs across several sequential waves. Each wave runs multiple jobs, merges their branches, and uses the resulting staging branch as the starting point for the next wave.

In plain words
What is it for?
Running multiple Leerie jobs in stages, checking their status, stopping or resuming runs, and synthesizing completed branches between waves.
Why use it?
It coordinates dependent groups of engineering tasks that cannot all start from the same code state. The laptop sequences the waves and handles branch merging and pull-request finalization.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the leerie plugin — 2 skills, 2 commands shipped together

Good fit Running multiple Leerie jobs in stages, checking their status, stopping or resuming runs, and synthesizing completed branches between waves.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add enricai/leerie
Claude Code
/plugin install leerie

Made for: Claude Code.

Or install leerie, the plugin that ships this one along with the rest of its 2 skills, 2 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for chain

README.md
[![agentmods](https://agentmods.dev/badge/commands/enricai/leerie/chain.svg)](https://agentmods.dev/commands/enricai/leerie/chain)
Your own site
<a href="https://agentmods.dev/commands/enricai/leerie/chain"><img src="https://agentmods.dev/badge/commands/enricai/leerie/chain.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,614 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00032 $0.01614
Opus 5 $0.00016 $0.00807
Sonnet 5 $0.00006 $0.00323
Haiku 4.5 $0.00003 $0.00161

Measured 7d ago against content hash b66aff1e7dbe, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

chain scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/chain.md · 170 lines

How it starts

The opening of the file, as written. The whole thing — 170 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Manage Leerie Chains

The user wants to perform a chain operation:

$ARGUMENTS

A chain is N parallel ./leerie --runtime fly invocations per wave, with synth-merge between waves to build the next wave's base branch. The laptop is the sequencer; there is no Fly coordinator machine. Each per-job worker takes the existing single-run path unchanged (provision → seed-auth + seed-repo → orchestrator → decide_teardown trap on laptop → fetch_branchhost_finalizedestroy_machine).

Wave N+1 starts only after every wave-N job has finalized on the laptop (branch pushed to origin, PR opened). Between waves the laptop runs chain.git_ops.synth_merge_branches to build the staging branch leerie/stage/<chain-id>-wave-<N+1>. (DESIGN.md §19.)

GitHub credentials are touched only by the laptop, via the existing host_finalize mechanism. Workers never see them.

The single-run verbs (status, kill, stop, resume, finalize, attach) are ID-dispatched: a UUID positional argument operates on the chain (iterates $LEERIE_STATE_HOST_DIR/runs/*/run.json filtered by the chain_id field, dispatches the single-run verb per discovered run); a Fly machine id operates on a single run (historical behavior). UUID format: 8-4-4-4-12 hyphenated. The five deprecated dash-prefixed chain aliases have been hard-removed (no shim) — use the bare verbs below.

Steps

Parse the first word of $ARGUMENTS to decide the subcommand:

submit — start a new chain

Required: at least one --wave flag. Each --wave value is a comma-separated list of prompt-file paths; the launcher reads each file and passes its contents as the run prompt to a background ./leerie --runtime fly invocation. Wave index is assigned by --wave flag order (0, 1, 2, …).

bash "${CLAUDE_PLUGIN_ROOT}/leerie" chain \
  --wave <path/to/a1.md,path/to/a2.md> \
  --wave <path/to/b1.md>

The launcher mints a fresh chain_id (UUID), prints a submission banner with the chain id and per-wave job counts, then enters the wave loop. The wave loop runs in the foreground of the user's terminal; if the user wants to detach, they can Ctrl-C (the trap propagates SIGTERM to all in-flight wave children, each of which runs its own decide_teardown to clean up its Fly machine).

Read the full file on GitHub · 170 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 170 lines · 32 tokens per session scan A b66aff1e7dbe

Subscribe to this mod's changes

chain is a command published in the GitHub repository enricai/leerie (10 stars, last pushed 5d ago), licensed MIT. It adds 32 tokens to every session and 1,614 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.