Install any skill in seconds. Free to start, no credit card required.
Get Started Free →This skill should be used when the user asks to "estimate LLM costs", "count tokens in prompts", "optimize prompt token usage", "compare model pricing", or "reduce LLM API costs".
.claude/skills/borghei-llm-cost-optimizer/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -39% | 0% |
| case-05 | ✗→✓ | ▲ Improved | -46% | 0% |
| case-06 | ✗→✓ | ▲ Improved | -11% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -46% | 0% |
| case-10 | ✗→✓ | ▲ Improved | -8% | 0% |
> Category: Engineering > Domain: AI Cost Management
The LLM Cost Optimizer skill provides tools for counting tokens, estimating costs across different LLM providers, and optimizing prompts to reduce token usage without sacrificing quality. Essential for teams managing LLM API budgets at scale.
Before estimating or optimizing, confirm these inputs. If any is unknown or vague, ASK — do not assume:
--file/--text/--stdin)--models and the pricing comparison)token_counter.py vs prompt_optimizer.py and sets --target-reduction)Stop rule: ask only the 2-3 that most change the output. If the user says "just draft it," proceed and list your assumptions at the top of the artifact.
bash# Count tokens in a prompt file and estimate costs python scripts/token_counter.py --file prompt.txt --models gpt-4o claude-sonnet # Count tokens from stdin echo "Hello world" | python scripts/token_counter.py --stdin --models all # Analyze a prompt for optimization opportunities python scripts/prompt_optimizer.py --file system_prompt.txt # Optimize with target reduction python scripts/prompt_optimizer.py --file prompt.txt --target-reduction 30
| Tool | Purpose | Key Flags | |------|---------|-----------| | token_counter.py | Count tokens and estimate costs across models | --file, --text, --stdin, --models | | prompt_optimizer.py | Analyze prompts for token reduction opportunities | --file, --target-reduction, --format | | cache_savings_calculator.py | Model prompt-cache economics: naive vs cached cost, break-even reuse, % savings | --requests, --cached-tokens, --cache-write-multiplier, --cache-read-multiplier, --base-input-price, --json |
token_counter.py with target modelsprompt_optimizer.py on eachcache_savings_calculator.py| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 18,578 | 7,766 | -58% | 1 | 1 | 0% | 3,656 | 2,234 | -39% | 0 | 0 | — |
case-02 | pass→pass | 9,883 | 7,396 | -25% | 1 | 1 | 0% | 1,477 | 2,180 | +48% | 0 | 0 | — |
case-03 | fail→fail | 20,922 | 21,230 | +1% | 1 | 1 | 0% | 4,069 | 5,029 | +24% | 0 | 0 | — |
case-04 | pass→pass | 12,988 | 7,721 | -41% | 1 | 1 | 0% | 2,572 | 2,358 | -8% | 0 | 0 | — |
case-05 | fail→pass | 13,314 | 2,316 | -83% | 1 | 1 | 0% | 2,304 | 1,250 | -46% | 0 | 0 | — |
case-06 | fail→pass | 9,322 | 2,597 | -72% | 1 | 1 | 0% | 1,506 | 1,341 | -11% | 0 | 0 | — |
case-07 | fail→pass | 13,786 | 2,376 | -83% | 1 | 1 | 0% | 2,375 | 1,281 | -46% | 0 | 0 | — |
case-08 | pass→pass | 7,085 | 2,383 | -66% | 1 | 1 | 0% | 1,126 | 1,258 | +12% | 0 | 0 | — |
case-09 | pass→pass | 12,648 | 5,814 | -54% | 1 | 1 | 0% | 2,012 | 1,753 | -13% | 0 | 0 | — |
case-10 | fail→pass | 18,760 | 12,136 | -35% | 1 | 1 | 0% | 3,012 | 2,768 | -8% | 0 | 0 | — |
case-11 | fail→pass | 31,710 | 11,908 | -62% | 1 | 1 | 0% | 1,527 | 2,764 | +81% | 0 | 0 | — |
case-12 | pass→pass | 12,920 | 11,253 | -13% | 1 | 1 | 0% | 1,912 | 2,736 | +43% | 0 | 0 | — |
case-13 | pass→pass | 14,422 | 11,400 | -21% | 1 | 1 | 0% | 1,963 | 2,723 | +39% | 0 | 0 | — |
case-14 | pass→pass | 9,018 | 6,345 | -30% | 1 | 1 | 0% | 1,370 | 1,905 | +39% | 0 | 0 | — |
case-15 | pass→pass | 17,078 | 17,297 | +1% | 1 | 1 | 0% | 2,641 | 3,694 | +40% | 0 | 0 | — |
case-16 | pass→pass | 16,999 | 14,274 | -16% | 1 | 1 | 0% | 2,651 | 3,259 | +23% | 0 | 0 | — |
case-17 | fail→pass | 17,606 | 2,693 | -85% | 1 | 1 | 0% | 2,910 | 1,338 | -54% | 0 | 0 | — |
case-18 | fail→pass | 4,429 | 2,129 | -52% | 1 | 1 | 0% | 576 | 1,197 | +108% | 0 | 0 | — |
case-19 | pass→pass | 13,324 | 11,047 | -17% | 1 | 1 | 0% | 1,902 | 2,461 | +29% | 0 | 0 | — |
case-20 | fail→pass | 6,346 | 2,588 | -59% | 1 | 1 | 0% | 896 | 1,263 | +41% | 0 | 0 | — |
case-21 | pass→pass | 19,489 | 18,733 | -4% | 1 | 1 | 0% | 3,983 | 4,700 | +18% | 0 | 0 | — |
case-22 | pass→pass | 14,562 | 11,148 | -23% | 1 | 1 | 0% | 2,612 | 2,981 | +14% | 0 | 0 | — |
case-23 | pass→pass | 16,761 | 13,872 | -17% | 1 | 1 | 0% | 3,215 | 3,348 | +4% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 22 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +39 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.