ultracost

Enforces per-stage model routing and pre-flight cost estimation for Claude Code dynamic workflows.

3.4k|487|Updated Jul 25, 2025
One-click install
npx skills add https://github.com/davepoon/buildwithclaude --skill ultracost
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ultracost
Source: https://github.com/davepoon/buildwithclaude/tree/main/plugins/ultracost/skills/ultracost
Command: npx skills add https://github.com/davepoon/buildwithclaude --skill ultracost

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dynamic workflows and subagent stages in Claude Code often inherit the session model by default, leading to overspending on expensive models for mechanical tasks or underpowering stages that need deep reasoning. This Skill enforces explicit model and effort pinning on every stage and adds a cost gate before any workflow launches.

Core Features & Use Cases

  • Per-Stage Model Routing: Applies a two-tier policy (opus at xhigh for coding and reasoning, sonnet at high for mechanical and support work) to every agent() stage, with haiku banned outright.
  • Effort Calibration: Sets per-stage effort levels (low through xhigh) bounded by the chosen model, so trivial scans never burn high-effort tokens.
  • Pre-Flight Cost Gate: Estimates agent count, model mix, and cost versus an all-opus baseline, then asks the user to Approve, Cancel, or Modify before launching.
  • Script Verification: The /ultracost:check command flags stages missing a model pin, pins that mismatch the described work, and effort exceeding the model cap.
  • Use Case: Before launching a 12-stage ultracode workflow, draft the script, run the estimate, see it costs 60% less than an all-opus baseline, and get explicit user approval before execution.

Quick Start

Ask Claude to draft a dynamic-workflow script with per-stage model and effort pins, then run /ultracost:check on the file to verify the pins and review the cost estimate before approving the launch.

Frequently Asked Questions about ultracost

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I control which model each subagent uses in Claude Code?

Pin the model per stage using the per-invocation model parameter, such as agent(task, { model: 'sonnet' }). The ultracost policy requires explicit pins on every stage and forbids letting stages inherit the session model by default.

How do I estimate the cost of a dynamic workflow before running it?

Write the draft script to a temp file and run ultracost estimate <file>, or node "$CLAUDE_PLUGIN_ROOT/bin/cli.js" estimate <file> under the plugin. It reports agent count, model mix, and cost versus an all-opus baseline before you approve the launch.

When should I use opus versus sonnet for workflow stages?

Use opus at xhigh effort for stages that decide how to write or change code, including debugging, design, review, and synthesis. Use sonnet at high effort for pre-planned mechanical work like search, extraction, reformatting, and running tests.

Can I use haiku for cheap workflow stages?

No. The ultracost routing policy bans haiku entirely as a hard rule. The cheapest permitted option is sonnet at low effort for trivial deterministic work like listing files or simple field extraction.

What does the /ultracost:check command verify?

It flags stages missing a model pin, pins that mismatch the work the prompt describes, and effort levels exceeding the model's cap. Run it as the plugin command /ultracost:check or as ultracost check <script> on the CLI.

What happens if I skip the manual cost estimate step?

The PreToolUse cost gate in the full plugin still stops the workflow launch automatically and presents the same cost numbers. The manual estimate step is a convenience, not the only enforcement point.