llm-cost-optimization

llm-cost-optimization is a skill for Claude Code from nimadorostkar/Claude-Skills-collection. It costs 101 tokens per session (1,405 once invoked), scanned A, original, MIT.

Guidance for reducing the cost of a language-model feature by measuring and controlling the text sent to and returned by the model. It covers caching, smaller context, model selection, batching, and output limits.

In plain words
What is it for?
Use it when model usage is too expensive, before scaling traffic, or when a growing bill needs explanation and per-feature tracking.
Why use it?
It helps identify which parts of requests are driving the bill before making changes. The goal is to lower spending while keeping the required answer quality.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the ai plugin — 12 skills shipped together

Good fit Use it when model usage is too expensive, before scaling traffic, or when a growing bill needs explanation and per-feature tracking.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nimadorostkar/claude-skills-collection/llm-cost-optimization
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add nimadorostkar/Claude-Skills-collection --skill llm-cost-optimization
Clone the repo
git clone --depth 1 https://github.com/nimadorostkar/Claude-Skills-collection

Made for: Claude Code.

Or install ai, the plugin that ships this one along with the rest of its 12 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for llm-cost-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/llm-cost-optimization/github.svg)](https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/llm-cost-optimization)
Your own site
<a href="https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/llm-cost-optimization"><img src="https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/llm-cost-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for llm-cost-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/llm-cost-optimization"><img src="https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/llm-cost-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,405 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00101 $0.01405
Opus 5.5 $0.00040 $0.00562
Sonnet 5.5 $0.00020 $0.00281
Haiku 4.5 $0.00010 $0.00140

Measured 1mo ago against content hash 8c390c3994d6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

llm-cost-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/ai/llm-cost-optimization/SKILL.md · 124 lines

How it starts

The opening of the file, as written. The whole thing — 124 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LLM Cost Optimization

Purpose

Reduce the cost of an LLM feature without losing the quality that justified it. Most LLM bills are dominated by one or two things that nobody has measured, and the fix is usually structural rather than a matter of shaving tokens.

When to Use

  • An LLM feature that is too expensive at current or projected volume.
  • Before scaling a feature from pilot to production traffic.
  • A bill that grew and nobody can explain why.

Capabilities

  • Token accounting: where the spend actually is.
  • Prompt caching.
  • Context reduction and retrieval narrowing.
  • Model routing and downgrading.
  • Batch processing for non-interactive work.
  • Output-length control.

Inputs

  • Token counts per call, broken down: system, context, history, output.
  • Call volume, by feature and by tenant.
  • The quality bar that must be maintained.

Outputs

  • A ranked list of cost drivers.
  • Changes with measured cost reduction and no quality regression.
  • Per-feature cost tracking so the next increase is visible.

Workflow

  1. Measure where the tokens go — Input versus output, and within input: system prompt, tools, retrieved context, conversation history. The answer is frequently not what anyone expected.
  2. Cache the stable prefix — If the system prompt and tools are identical across calls, prompt caching reduces their cost by roughly 90%. This is usually the single largest and cheapest win.
  3. Cut the context, not the quality — Retrieving twenty chunks when five suffice costs four times as much and often produces a worse answer. Measure the quality at each k.
  4. Route to a smaller model — Most tasks do not need the largest model. Measure the small one before assuming it cannot.
  5. Batch what is not interactive — Batch APIs are typically half the price for work that can wait. Overnight classification does not need a synchronous call.
  6. Cap the output — Output tokens cost several times more than input tokens. A max_tokens that is generous "just in case" is a standing cost.

Read the full file on GitHub · 124 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · +62 tokens per session 8c390c3994d6
  2. 3mo ago First seen · 124 lines · 39 tokens per session scan A f5bbecdd938e

Subscribe to this mod's changes

llm-cost-optimization is a skill published in the GitHub repository nimadorostkar/Claude-Skills-collection (41 stars, last pushed yesterday), licensed MIT. It adds 101 tokens to every session and 1,405 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

llm-cost-optimization compared with skills from other repositories

llm-cost-optimization next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
llm-cost-optimizationnimadorostkar/Claude-Skills-collectionSkill41yesterdayMITA101Claude Code
ai-ethics-reviewmohitagw15856/pm-claude-skillsSkill1.6ktodayMITA88Claude Code
ai-product-canvasmohitagw15856/pm-claude-skillsSkill1.6ktodayMITA73Claude Code
model-migration-planmohitagw15856/pm-claude-skillsSkill1.6ktodayMITA99Claude Code
prompt-regression-suitemohitagw15856/pm-claude-skillsSkill1.6ktodayMITA102Claude Code
ai-context-primermohitagw15856/pm-claude-skillsSkill1.6ktodayMITA149Claude Code
ai-output-verifiermohitagw15856/pm-claude-skillsSkill1.6ktodayMITA142Claude Code