cost-aware-routing
Skill4 starsChanged 3 months agoMITView on GitHub
Model routing by task complexity with cost tracking. Haiku/Sonnet/Opus decision framework.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- kienbui1995/magic-powerstheir own version, first seen Apr 10, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- kienbui1995/magic-powers★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository103 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- harness-installSkill
- ab-test-setupSkill
- accessibility-complianceSkill
- accessibilitySkill
- agent-architecture-auditSkill
- agent-evalSkill
- agent-harness-constructionSkill
- agentic-engineeringSkill
- agent-introspection-debuggingSkill
- ai-regression-testingSkill
- ai-seoSkill
- anthropic-coursesSkill
- anthropic-sdk-phpSkill
- anthropic-sdk-pythonSkill
- api-connector-builderSkill
- architecture-decision-recordsSkill
- architecture-patternsSkill
- article-writingSkill
- async-python-patternsSkill
- auth-implementation-patternsSkill
- backend-patternsSkill
- bash-defensive-patternsSkill
- bats-testing-patternsSkill
- block-no-verify-hookSkill
- blueprintSkill
- brainstormingSkill
- browser-testing-with-devtoolsSkill
- churn-preventionSkill
- ci-cd-and-automationSkill
- citation-engineSkill
- ckSkill
- claude-code-security-reviewSkill
- claude-cookbooksSkill
- click-path-auditSkill
- codebase-onboardingSkill
- coding-standardsSkill
- competitor-alternativesSkill
- connections-optimizerSkill
- content-engineSkill
- content-hash-cache-patternSkill
- context-budgetSkill
- context-driven-developmentSkill
- context-engineeringSkill
- continuous-agent-loopSkill
- cost-aware-llm-pipelineSkill
- cost-trackingSkill
- councilSkill
- cqrs-implementationSkill
- crosspostSkill
- customer-billing-opsSkill
- dashboard-builderSkill
- data-scraper-agentSkill
- data-storytellingSkill
- data-throughput-acceleratorSkill
- deployment-patternsSkill
- docker-patternsSkill
- documentation-and-adrsSkill
- e2e-testingSkill
- error-handlingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
No complexity signal keywords present
- Distinctive: line 24
No files need to be read or modified
- Very specific: line 133
Does NOT override explicit model selections (e.g., model=opus in Agent calls)
- Distinctive: line 135
When spawning subagents, record the model tier used for cost tracking
- Distinctive: line 139
Always leverage Anthropic's prompt caching for repeated context:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cost-Aware Routing
Decision framework for routing tasks to the optimal model tier (Haiku/Sonnet/Opus) based on complexity signals. Tracks estimated session cost.
Trigger
/cost status-- show current session cost estimate/cost summary-- detailed breakdown by model tier and task type- Keywords: "cost status", "cost summary", "cost routing"
Routing Rules
Tier 1: Haiku (1x cost)
Use when ALL of these are true:
- Query is under 30 words
- No complexity signal keywords present
- Task is a lookup, status check, or simple transform
- No files need to be read or modified
- Not client-facing output
Examples: "what branch am I on?", "list files in src/", greeting responses, yes/no confirmations
Tier 2: Sonnet (4x cost)
Use when ANY of these are true:
- Standard coding task (read, edit, write files)
- Content generation (non-client-facing)
- Agent spawning for research or exploration
- Multi-step task requiring tool use
- Query over 50 words without Opus signals
Examples: Bug fixes, feature implementation, test writing, code refactoring, documentation, research tasks
Tier 3: Opus (19x cost)
Use when ANY of these are true:
- Architecture or system design decisions
- Security review or vulnerability analysis
- Complex debugging requiring deep reasoning
- Client-facing copy (ad copy, emails, landing pages, proposals)
- Multi-agent orchestration planning
- Cross-system integration design
- Conflict resolution between competing approaches
Examples: Campaign strategy, landing page copy, security audits, system architecture, proposal writing
Complexity Signals
These keywords/patterns in a query bump routing one tier up:
analyze, debug, investigate, architect, design, strategy,
plan, optimize, refactor, migrate, deploy, security,
review, audit, integrate, client, proposal, campaignCost Tracking
Pricing Ratios (relative)
| Model | Input/1M tokens | Output/1M tokens | Ratio |
| Haiku 4.5 | $0.80 | $4.00 | 1x |
| Sonnet 4.6 | $3.00 | $15.00 | ~4x |
| Opus 4.6 | $15.00 | $75.00 | ~19x |
Session Log
Estimated costs are logged to ~/.claude/state/cost-log.json (the state dir is created on first write):
{
"session_id": "e1e7c72a...",
"started": "2026-04-07T12:00:00Z",
"entries": [
{
"timestamp": "2026-04-07T12:01:00Z",
"task": "VPS recon",
"model": "sonnet",
"estimated_tokens": {"input": 5000, "output": 2000},
"estimated_cost_usd": 0.045
}
],
"totals": {
"haiku": {"tasks": 3, "cost": 0.012},
"sonnet": {"tasks": 8, "cost": 0.36},
"opus": {"tasks": 2, "cost": 1.14},
"total_usd": 1.512
}
}Output Formats
/cost status
SESSION COST ESTIMATE
=====================
Session: e1e7c72a (started 2h ago)
Tasks: 13 total
Haiku: 3 tasks ~$0.01
Sonnet: 8 tasks ~$0.36
Opus: 2 tasks ~$1.14
----------------------
Total: ~$1.51
Current task routing: Sonnet (standard complexity)/cost summary
COST BREAKDOWN BY TASK TYPE
============================
Research/Exploration: 5 tasks Sonnet ~$0.23
Code Implementation: 3 tasks Sonnet ~$0.13
Security Review: 1 task Opus ~$0.57
Client Copy: 1 task Opus ~$0.57
Status Checks: 3 tasks Haiku ~$0.01
------
~$1.51
OPTIMIZATION TIPS:
- 2 Sonnet tasks could have been routed to Haiku (simple lookups)
- Estimated savings: $0.08Integration
- Complements the MSP (Model Scoring Protocol) routing rules in
~/.claude/rules/architecture.rules.md - Does NOT override explicit model selections (e.g.,
model=opusin Agent calls) - Cost log persists across compactions but resets each session
- When spawning subagents, record the model tier used for cost tracking
Prompt Caching
Always leverage Anthropic's prompt caching for repeated context:
- System prompts with
cache_control: {"type": "ephemeral"}reduce input costs by ~90% on cache hits - CLAUDE.md content is automatically cached by the harness
- For agent spawns, front-load shared context to maximize cache reuse
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

