Agent skill

LLM Cost Optimizer

by borghei in borghei/Claude-Skills

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".

MITAuto-check passedAI & LLM Engineering

Install LLM Cost Optimizer

skills CLI
$ npx skills add borghei/Claude-Skills --skill llm-cost-optimizer -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install borghei/Claude-Skills llm-cost-optimizer --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/engineering/llm-cost-optimizer .claude/skills/llm-cost-optimizer && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
llm-cost-optimizer
GitHub stars
881
Token cost
~1.1k tokens
SKILL.md length
398 words
Files
6 (incl. scripts, references)
Skills in repo
349
Repo updated
First seen
Licence
MIT

At a glance

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".

  • Works in 4 steps: Collect sample prompts (system prompt +… → Run token_counter.py with target models → Multiply per-request cost by expected… → …
  • Asks to estimate LLM costs
  • SKILL.md covers Overview, Clarify First, Quick Start and Tools Overview, plus 3 more sections
  • Runs Python scripts from its folder; calls python

What it does

LLM Cost Optimizer is an agent skill from borghei/Claude-Skills. 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".

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts and reference files (for example `references/caching-and-batch-economics.md`, `references/llm-pricing-guide.md` and `scripts/cache_savings_calculator.py`).

It sits in AI & LLM Engineering, covering LLM cost and token optimization and LLM API integration. The repository describes itself as: 385 AI skills, 77 expert agents, and 900 stdlib Python tools for every team: engineering, PM, marketing, C-level, compliance, business ops, research, and a LinkedIn toolkit… The licence is MIT.

When your agent uses it

  • Asks to estimate LLM costs
  • Count tokens in prompts
  • Optimize prompt token usage
  • Compare model pricing

Example prompts

  • “estimate LLM costs”
  • “count tokens in prompts”
  • “optimize prompt token usage”
  • “/llm-cost-optimizer”

Requirements

  • Python 3

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Collect sample prompts (system prompt + user messages)
  2. Run token_counter.py with target models
  3. Multiply per-request cost by expected daily volume
  4. Compare models on cost-quality tradeoff

What it can do on your machine

Read from SKILL.md and the folder at commit 4a698e8. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 3 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

LLM Cost Optimizer loads about 1.1k tokens when it runs, and up to ~4.1k if it reads all its reference files. Until then it costs about 50 tokens; SKILL.md has 398 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~50
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from borghei/Claude-Skills at commit 4a698e8, republished under its MIT licence (© borghei). 398 words, ~1,074 tokens.

Download SKILL.mdSave it as .claude/skills/llm-cost-optimizer/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
llm-cost-optimizer
description
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".
license
MIT + Commons Clause
metadata.version
1.1.0
metadata.author
borghei
metadata.category
engineering
metadata.domain
ai-cost-management
metadata.updated
2026-06-29
metadata.tags
llm, tokens, cost-optimization, prompt-engineering, pricing

LLM Cost Optimizer

Category: Engineering Domain: AI Cost Management

Overview

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.

Clarify First

Before estimating or optimizing, confirm these inputs. If any is unknown or vague, ASK — do not assume:

  • Input prompt/text — the prompt file or text to count or optimize (the input via --file/--text/--stdin)
  • Target models — which models to estimate cost for (sets --models and the pricing comparison)
  • Goal — cost estimation vs prompt optimization, and any target reduction (selects 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.

Quick Start

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

Tools Overview

ToolPurposeKey Flags
token_counter.pyCount tokens and estimate costs across models--file, --text, --stdin, --models
prompt_optimizer.pyAnalyze prompts for token reduction opportunities--file, --target-reduction, --format
cache_savings_calculator.pyModel prompt-cache economics: naive vs cached cost, break-even reuse, % savings--requests, --cached-tokens, --cache-write-multiplier, --cache-read-multiplier, --base-input-price, --json

Workflows

Cost Estimation for New Project
  1. Collect sample prompts (system prompt + user messages)
  2. Run token_counter.py with target models
  3. Multiply per-request cost by expected daily volume
  4. Compare models on cost-quality tradeoff
Prompt Optimization Sprint
  1. Identify highest-cost prompts from usage logs
  2. Run prompt_optimizer.py on each
  3. Apply suggested optimizations
  4. Re-count tokens to verify reduction
  5. A/B test optimized vs. original for quality
Show full SKILL.md (145 more words)Show less

Reference Documentation

  • LLM Pricing Guide - Current pricing for major LLM providers, token estimation methods
  • Caching & Batch Economics - Prompt/context caching break-even math, batch-API cost tradeoff, reasoning-effort cost impact, structured-output token overhead (model-agnostic, user-supplied rates)

Common Patterns

Token Reduction Techniques
  • Remove redundant instructions and examples
  • Use shorter variable names in few-shot examples
  • Compress verbose system prompts
  • Replace repeated context with references
  • Use structured output formats (JSON) to reduce response tokens
  • Batch multiple requests into single prompts where possible
Cost-Effective Model Selection
  • Use smaller models for classification/extraction tasks
  • Reserve large models for complex reasoning
  • Implement model routing based on query complexity
  • Cache responses for identical or similar queries
  • Cache the stable system-prompt/context/schema prefix (most-stable first, volatile last) and check the reuse break-even with cache_savings_calculator.py
  • Route bulk, non-interactive work to the batch API (~half cost for added latency); right-size reasoning effort per route — high only where accuracy demands it

© borghei, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (scripts, references) in engineering/llm-cost-optimizer of borghei/Claude-Skills.

  • SKILL.md
  • references/caching-and-batch-economics.md
  • references/llm-pricing-guide.md
  • scripts/cache_savings_calculator.py
  • scripts/prompt_optimizer.py
  • scripts/token_counter.py

Open the folder on GitHubat commit 4a698e8

Compare with similar skills

LLM Cost Optimizer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

LLM Cost Optimizer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
LLM Cost Optimizer this skillborghei/Claude-Skills881—~1.1kAutomated safety check: PassMIT
AIbutterbase-ai/butterbase-skills534—~1.1kAutomated safety check: PassMIT
LLM Cost Optimizationsickn33/agentic-awesome-skills47k1 repos~2.5kAutomated safety check: PassMIT
Cost Aware LLM Pipelinemajiayu000/claude-skill-registry6666 repos~1.4kAutomated safety check: PassMIT
Claude APIkid-sid/claude-spellbook189—~2.7kAutomated safety check: PassMIT
Cost Aware LLM Pipelinexu-xiang/everything-claude-code-zh2k—~1.1kAutomated safety check: PassMIT

Similar skills

  • AI

    butterbase-ai/butterbase-skills

    A skill your agent uses when calling the app's AI gateway from agent tools — chat completions, embeddings, listing models, configuring defaults or BYOK, reading token/cost usage

    534 GitHub stars~1.1k tokensUpdated 3 days ago
    AI & LLM EngineeringAuto-check passed
  • LLM Cost Optimization

    sickn33/agentic-awesome-skills

    Reduce LLM API and infrastructure costs through model selection, prompt caching, batching, caching, quantization, and self-hosting strategies.

    47k GitHub starsUsed in 1 repo~2.5k tokens
    AI & LLM EngineeringAuto-check passed
  • Cost Aware LLM Pipeline

    majiayu000/claude-skill-registry

    Cost optimization patterns for LLM API usage — model routing by task complexity, budget tracking, retry logic, and prompt caching.

    666 GitHub starsUsed in 6 repos~1.4k tokens
    AI & LLM EngineeringAuto-check passed
  • Claude API

    kid-sid/claude-spellbook

    A skill your agent uses when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop…

    189 GitHub stars~2.7k tokensUpdated 2 mo ago
    AI & LLM EngineeringAuto-check passed
  • Cost Aware LLM Pipeline

    xu-xiang/everything-claude-code-zh

    LLM API 使用成本优化模式——基于任务复杂度的模型路由、预算跟踪、重试逻辑和提示词缓存. An agent skill from xu-xiang/everything-claude-code-zh.

    2k GitHub stars~1.1k tokensUpdated 7 mo ago
    AI & LLM EngineeringAuto-check passed
  • Anth Cost Tuning

    jeremylongshore/tons-of-skills-marketplace

    Optimize Anthropic Claude API costs with model routing, prompt caching, batching, and spend monitoring.

    2.8k GitHub stars~2.1k tokensUpdated today
    AI & LLM EngineeringAuto-check passed

More from borghei/Claude-Skills

All 349 skills in this repo
  • Agents In The Team

    borghei/Claude-Skills

    Run delivery when AI coding and ops agents take tickets. An agent skill from borghei/Claude-Skills.

    881 GitHub stars~4.2k tokensUpdated yesterday
    Auto-check passed
  • AI Content Disclosure

    borghei/Claude-Skills

    Check AI-generated marketing content and reviews for required disclosures under the EU AI Act, FTC rules and platform AI-label policies.

    881 GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed
  • AI Prototyping

    borghei/Claude-Skills

    Idea to AI-generated prototype to customer validation to engineering handoff.

    881 GitHub stars~3.6k tokensUpdated yesterday
    Auto-check passed
  • Analytics Engineer

    borghei/Claude-Skills

    Analytics engineering across data modeling, dbt, transformation, and semantic layers.

    881 GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed
  • Ansoff Matrix

    borghei/Claude-Skills

    Ansoff Matrix — 4-quadrant framework for growth options: market penetration, market/product development, and diversification.

    881 GitHub stars~2.2k tokensUpdated yesterday
    Auto-check passed
  • Brainstorm Okrs

    borghei/Claude-Skills

    OKR brainstorming and validation using the Radical Focus framework — outcome objectives, measurable key results, counter-metrics.

    881 GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed

Questions about LLM Cost Optimizer

What does LLM Cost Optimizer do?

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". LLM Cost Optimizer is an agent skill from borghei/Claude-Skills. 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".

When should I use LLM Cost Optimizer?

LLM Cost Optimizer fits situations like: asks to estimate LLM costs; count tokens in prompts; optimize prompt token usage; compare model pricing.

How do I install LLM Cost Optimizer in Claude Code?

Run `npx skills add borghei/Claude-Skills --skill llm-cost-optimizer -a claude-code`. Or copy the skill folder (engineering/llm-cost-optimizer in borghei/Claude-Skills) into .claude/skills/llm-cost-optimizer in your project. Claude Code loads it when a task matches its description.

How do I install LLM Cost Optimizer in Codex?

Run `npx skills add borghei/Claude-Skills --skill llm-cost-optimizer -a codex`. Or copy the skill folder (engineering/llm-cost-optimizer in borghei/Claude-Skills) into .agents/skills/llm-cost-optimizer in your project. Codex loads it when a task matches its description.

Can I use LLM Cost Optimizer in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add borghei/Claude-Skills --skill llm-cost-optimizer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/llm-cost-optimizer, .gemini/skills/llm-cost-optimizer, .github/skills/llm-cost-optimizer and .opencode/skills/llm-cost-optimizer in your project.

What does LLM Cost Optimizer need to run?

Going by SKILL.md and its folder, LLM Cost Optimizer needs Python for the scripts in its folder and the command-line tools its instructions call (python). Our summary lists: Python 3.

Does LLM Cost Optimizer access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is LLM Cost Optimizer safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does LLM Cost Optimizer use?

LLM Cost Optimizer is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does LLM Cost Optimizer use?

About 1.1k tokens (SKILL.md is roughly 4.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3k tokens, read only when the agent opens those files.

What are the alternatives to LLM Cost Optimizer?

Skills that share tags, products or a category with LLM Cost Optimizer: AI (butterbase-ai/butterbase-skills, 534 stars), LLM Cost Optimization (sickn33/agentic-awesome-skills, 47k stars), Cost Aware LLM Pipeline (majiayu000/claude-skill-registry, 666 stars) and Claude API (kid-sid/claude-spellbook, 189 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains LLM Cost Optimizer?

borghei (a GitHub user) maintains it in borghei/Claude-Skills, which has 881 GitHub stars. The repository holds 349 skills in this directory. The repository was last updated on October 7, 2026.

Source: borghei/Claude-Skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.