SuperAPI AI Directory

sprag

sprag is a model delegation routing tool for Claude Code and Codex. It uses rules to hand off tasks such as queries, status checks, builds, and tests to lower-cost models and effort levels, thereby reducing usage costs; each delegated run records the price difference versus the baseline and displays it in the status bar. The tool also includes features such as document-to-Markdown conversion, status bar warnings, and team rule management.

Open website

About this tool

sprag is the delegation layer for Claude Code and Codex, used to assign different types of tasks to the appropriate models and effort levels in order to reduce costs while maintaining accuracy.

Main capabilities include:

  1. Model and effort routing: based on task type, queries, status checks, builds, and test runs are delegated to low-cost tiers such as Haiku; when a cheaper run might make mistakes, it is escalated to a higher effort level or a stronger model (for example, multi-file queries use Sonnet with high effort, and open web research uses xhigh).
  2. Rules come from session logs: delegation rules are analyzed and generated from session logs already written locally by Claude Code and Codex, and each rule requires user approval; every delegated run writes the price difference to a ledger.
  3. Rule replay verification: each rule is checked against an openable replay case, and the npm package ships with the same table, viewable by running sprag proof.
  4. Document compression: documents enter the context in compact Markdown form (for example, a 540,000-token document becomes 23,000 tokens).
  5. Status bar: shows the cost and savings for each session, and displays a warning label at the start of the line when cache, context, or rate limits need attention.
  6. macOS menu bar tool Sprag Bar: shows currently running Claude Code and Codex sessions in the menu bar, including model, effort, context usage, cost, CPU and memory, as well as the account's 5-hour and weekly limits.
  7. Team features (Sprag Pro and Enterprise): the whole team shares one set of delegation rules, and once approved in one place all machines follow them; provides dashboards for cost, savings, seats, and budget, prompt monitoring, and a virtual office.

How to use: Run npm i -g sprag-cli to install; hooks, the status bar, and starter rules are configured for all projects, with no per-project setup needed. After installation, open Claude Code and it works. If your package manager skips install scripts (pnpm, bun), run sprag install once after installing. For Codex, select it with --agent codex, or run sprag install --agent codex; Codex requires reviewing and trusting the new hooks in the /hooks menu.

Use cases: Forindividual developers or teams who want to reduce the cost of using Claude Code and Codex and have different tasks in the same session automatically matched to more economical models and effort levels.

Limitations and notes:

  • Session analysis runs entirely locally and requires no additional model calls or API keys; the analysis only reads local logs.
  • The optional Codex gateway budget and price queries use existing credentials to contact the configured LiteLLM endpoint.
  • The CLI requires Node.js 20+ and one TOML parser dependency.
  • The free CLI does not send personally identifiable information and requires no account.
  • Sprag Bar is not distributed as a binary; it compiles Swift source on the Mac at session start and requires the Xcode command line tools.
  • In hosts that run Claude Code through the Agent SDK (such as T3 Code), status bar commands are not executed; use sprag panel instead.
  • Codex dollar figures come from Claude Code sessions, not from Codex benchmarks.
  • Pricing and specific prices for some features (Pro, Enterprise) are not provided.