Agent skill

Claude Cost Optimization

by majiayu000 in majiayu000/claude-skill-registry

Comprehensive cost tracking and optimization for production Claude deployments.

MITAuto-check passedAI & LLM Engineering

Install Claude Cost Optimization

skills CLI
$ npx skills add majiayu000/claude-skill-registry --skill claude-cost-optimization -a claude-code

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

GitHub CLI
$ gh skill install majiayu000/claude-skill-registry claude-cost-optimization --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/majiayu000/claude-skill-registry.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/ai-llm/claude-cost-optimization .claude/skills/claude-cost-optimization && 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
claude-cost-optimization
GitHub stars
666
Used in
1 other repo
Token cost
~3.1k tokens
SKILL.md length
819 words
Files
2
Skills in repo
971
Repo updated
First seen
Licence
MIT

At a glance

Comprehensive cost tracking and optimization for production Claude deployments.

  • Works in 5 steps: Measure Baseline Usage → Analyze Cost Drivers → Apply Optimizations → …
  • Optimizing token usage
  • SKILL.md covers Overview, When to Use This Skill, 5-Step Optimization Workflow and Quick Start - Usage Tracking, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Claude Cost Optimization is an agent skill from majiayu000/claude-skill-registry. Comprehensive cost tracking and optimization for production Claude deployments. Covers Admin API usage tracking, efficiency measurement, ROI calculation, optimization patterns (caching, batching, model selection, context editing, effort parameter), and cost prediction. Use when tracking costs, optimizing token usage, measuring efficiency, calculating ROI, reducing production expenses, or implementing cost-effective Claude integrations.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `metadata.json`).

It sits in AI & LLM Engineering, covering LLM cost and token optimization, Deployment and Caching. The repository describes itself as: Searchable Claude Code skills catalog with source-linked guides and generated registry artifacts. The licence is MIT.

When your agent uses it

  • Optimizing token usage
  • Measuring efficiency
  • Calculating ROI
  • Reducing production expenses

Example prompts

  • “/claude-cost-optimization”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Measure Baseline Usage
  2. Analyze Cost Drivers
  3. Apply Optimizations
  4. Track Improvements
  5. Report ROI

What it can do on your machine

Read from SKILL.md and the folder at commit 000116a. 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

    No scripts in the folder and no shell commands in SKILL.md (its code samples are 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

Claude Cost Optimization loads about 3.1k tokens when it runs. Until then it costs about 116 tokens; SKILL.md has 819 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~116
When it runs · the whole SKILL.md, loaded when a task matches
~3.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); files beside SKILL.md are not scanned.

SKILL.md

The full file from majiayu000/claude-skill-registry at commit 000116a, republished under its MIT licence (© majiayu000). 819 words, ~3,140 tokens.

Download SKILL.mdSave it as .claude/skills/claude-cost-optimization/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
claude-cost-optimization
description
Comprehensive cost tracking and optimization for production Claude deployments. Covers Admin API usage tracking, efficiency measurement, ROI calculation, optimization patterns (caching, batching, model selection, context editing, effort parameter), and cost prediction. Use when tracking costs, optimizing token usage, measuring efficiency, calculating ROI, reducing production expenses, or implementing cost-effective Claude integrations.

Claude Cost Optimization

Overview

Cost optimization is critical for production Claude deployments. A single inefficiently-designed agent can cost hundreds or thousands of dollars monthly, while optimized implementations cost 10-90% less for identical functionality. This skill provides a comprehensive workflow for measuring, analyzing, and optimizing token costs.

Why This Matters:

  • Token costs are your largest Claude expense
  • Small improvements compound over millions of API calls
  • Context optimization alone saves 60-90% on long conversations
  • Model + effort selection can reduce costs 5-10x for specific tasks

Key Savings Available:

  • Effort parameter: 20-70% token reduction (same model, different reasoning depth)
  • Context editing: 60-90% reduction on long conversations
  • Tool optimization: 37-85% reduction with advanced tool patterns
  • Prompt caching: 90% reduction on repeated content
  • Model selection: 2-5x cost difference between models

When to Use This Skill

Use claude-cost-optimization when you need to:

  • Track Token Costs: Understand exactly what your Claude implementation costs
  • Identify Expensive Patterns: Find which operations consume the most tokens
  • Measure ROI: Calculate the business value of your Claude integration
  • Optimize for Production: Reduce costs before deploying expensive agents
  • Analyze Cost Drivers: Break down costs by model, feature, endpoint, or time period
  • Plan Budget: Forecast future costs based on growth projections
  • Implement Optimizations: Apply proven techniques (caching, batching, context editing)
  • Set Alerts: Monitor costs and get notified of anomalies or budget overruns

5-Step Optimization Workflow

Step 1: Measure Baseline Usage

Establish your current cost baseline before optimization.

What to Measure:

- Total monthly tokens (input + output)
- Cost breakdown by model
- Top 10 most expensive operations
- Average tokens per request
- Peak usage times and patterns

How to Measure (using Admin API):

python
from anthropic import Anthropic

client = Anthropic()

# Get monthly usage
response = client.beta.admin.usage_metrics.list(
    limit=30,
    sort_by="date",
)

total_input_tokens = sum(m.input_tokens for m in response.data)
total_output_tokens = sum(m.output_tokens for m in response.data)
total_cost = (total_input_tokens * 0.000005) + (total_output_tokens * 0.000025)
print(f"Monthly cost: ${total_cost:.2f}")

Where to Start: See references/usage-tracking.md for detailed Admin API integration

Step 2: Analyze Cost Drivers

Understand where your costs actually come from.

Identify Expensive Patterns:

  1. Which operations use the most tokens?
  2. Which models cost the most?
  3. Are you using caching effectively?
  4. Are context windows growing unnecessarily?
  5. Are you making redundant API calls?

Create Cost Breakdown (example):

Agent reasoning loops: 45% of costs
File analysis: 25% of costs
Web search: 15% of costs
Classification tasks: 10% of costs
Other: 5% of costs

Key Metrics to Calculate:

  • Cost per transaction
  • Tokens per transaction
  • Cost per business outcome
  • Cost trend (week-over-week)
Step 3: Apply Optimizations

Apply targeted optimizations to your biggest cost drivers.

Effort Parameter (if using Opus 4.5):

  • Complex reasoning: high effort (default)
  • Balanced tasks: medium effort (20-40% savings)
  • Simple classification: low effort (50-70% savings)

Context Editing (for long conversations):

  • Automatic tool result clearing (saves 60-90%)
  • Client-side compaction (saves automatic summarization)
  • Memory tool integration (enables infinite conversations)

Tool Optimization (for large tool sets):

  • Tool search with deferred loading (supports 10K+ tools)
  • Programmatic calling (37% token reduction on data processing)
  • Tool examples (improve accuracy 72% → 90%)

Prompt Caching (for repeated content):

  • Cache system prompts (90% cost reduction on cached portion)
  • Cache repeated files/documents
  • Cache tool definitions

Model Selection:

  • Opus 4.5: $5/M input, $25/M output (complex tasks)
  • Sonnet 4.5: (see references for pricing)
  • Haiku 4.5: (see references for pricing)
Step 4: Track Improvements

Monitor cost reductions and efficiency gains after optimizations.

Metrics to Track:

  • Cost per transaction (before vs after)
  • Total token reduction percentage
  • Quality impact (did results improve or worsen?)
  • Implementation difficulty and time

Measurement Period: Track for 1-2 weeks per optimization to see impact

Example Impact:

Optimization: Client-side compaction on long research tasks
Before: 450K tokens/request, $11.25 cost
After:  180K tokens/request, $4.50 cost
Savings: 60% cost reduction
Show full SKILL.md (324 more words)Show less
Step 5: Report ROI

Calculate business value of your optimizations.

ROI Calculation:

Monthly Savings = (Daily Cost × 30) - (Optimized Cost × 30)
Implementation Hours = Time to implement optimizations
Cost per Hour = $100-300 (your eng cost)
Payback Period = (Implementation Hours × Cost per Hour) / Monthly Savings

ROI Example:

Monthly savings: $500/month
Implementation: 8 hours
Cost per hour: $150
Implementation cost: $1,200
Payback period: 2.4 months
First year ROI: 400%

Quick Start - Usage Tracking

Get started with Admin API cost tracking in 5 minutes:

python
import anthropic
from datetime import datetime, timedelta

client = anthropic.Anthropic()

def get_monthly_costs():
    """Get current month's token costs"""

    # Get usage for last 30 days
    now = datetime.now()
    thirty_days_ago = now - timedelta(days=30)

    response = client.beta.admin.usage_metrics.list(
        limit=30,
        sort_by="date",
    )

    total_input = sum(m.input_tokens for m in response.data)
    total_output = sum(m.output_tokens for m in response.data)

    # Opus 4.5 pricing: $5/M input, $25/M output
    input_cost = total_input * 0.000005
    output_cost = total_output * 0.000025
    total_cost = input_cost + output_cost

    print(f"Last 30 days:")
    print(f"  Input tokens: {total_input:,}")
    print(f"  Output tokens: {total_output:,}")
    print(f"  Input cost: ${input_cost:.2f}")
    print(f"  Output cost: ${output_cost:.2f}")
    print(f"  Total cost: ${total_cost:.2f}")

    return {
        "input_tokens": total_input,
        "output_tokens": total_output,
        "input_cost": input_cost,
        "output_cost": output_cost,
        "total_cost": total_cost
    }

# Run the function
costs = get_monthly_costs()

Quick Start - ROI Calculation

Calculate the business value of your Claude implementation:

python
def calculate_roi(
    monthly_cost: float,
    monthly_transactions: int,
    cost_before_claude: float = None,
    quality_improvement: float = 1.0
) -> dict:
    """Calculate ROI metrics for Claude implementation"""

    cost_per_transaction = monthly_cost / monthly_transactions

    metrics = {
        "monthly_cost": monthly_cost,
        "monthly_transactions": monthly_transactions,
        "cost_per_transaction": cost_per_transaction,
    }

    # If you had costs before Claude (manual process, previous tool, etc)
    if cost_before_claude:
        savings = cost_before_claude - monthly_cost
        roi_percentage = (savings / cost_before_claude) * 100
        metrics["previous_cost"] = cost_before_claude
        metrics["monthly_savings"] = savings
        metrics["roi_percentage"] = roi_percentage

    # Account for quality improvements
    effective_cost = monthly_cost / quality_improvement
    metrics["quality_adjusted_cost"] = effective_cost

    return metrics

# Example: Research agent replacing manual research
result = calculate_roi(
    monthly_cost=500,          # Claude costs
    monthly_transactions=1000,  # Requests processed
    cost_before_claude=3000,   # Manual research was $3k/month
    quality_improvement=1.5    # Claude results are 50% better
)

print(f"Cost per transaction: ${result['cost_per_transaction']:.4f}")
print(f"Monthly savings: ${result['monthly_savings']:.2f}")
print(f"ROI: {result['roi_percentage']:.0f}%")

Pricing Overview

Current Claude Model Pricing (as of November 2025):

ModelInputOutputBest For
Opus 4.5$5/M$25/MComplex reasoning, agents, coding
Sonnet 4.5$3/M$15/MBalanced performance/cost
Haiku 4.5$0.80/M$4/MSimple tasks, high volume

Cost Impact of Optimization Techniques:

TechniqueSavingsImplementation Difficulty
Effort parameter (medium)20-40%Easy (add 2 lines)
Effort parameter (low)50-70%Easy (add 2 lines)
Context editing60-90%Medium (requires setup)
Tool optimization37-85%Medium (architecture change)
Prompt caching90%Hard (infrastructure)
Model selection50-75%Hard (architecture change)

Example Cost Comparison (1M transactions/month):

Scenario: Classification task

Opus 4.5, high effort:
- Input: 50M tokens @ $5/M = $250
- Output: 10M tokens @ $25/M = $250
- Total: $500/month

Opus 4.5, low effort:
- Input: 50M tokens @ $5/M = $250
- Output: 5M tokens @ $25/M = $125
- Total: $375/month (25% savings)

Haiku 4.5, high effort:
- Input: 50M tokens @ $0.80/M = $40
- Output: 10M tokens @ $4/M = $40
- Total: $80/month (84% savings)

Optimization Decision Tree

START: Have high costs?
  ↓
  Q1: Do you know what's causing the costs?
    NO → Go to Step 2: Analyze Cost Drivers
    YES → Q2: Have you tried effort parameter (Opus 4.5)?
            NO → Apply effort parameter (medium/low)
                 Expect 20-70% savings, 2-4 hours implementation
            YES → Q3: Do you have long conversations (>50K tokens)?
                    NO → Q4: Do you have 10+ tools in your agents?
                            NO → Q5: Can you cache repeated content?
                                    YES → Implement prompt caching
                                          Expect 90% savings on cached
                                    NO → Consider model selection
                                         Expect 2-5x cost reduction
                            YES → Implement tool search + deferred loading
                                  Expect 85% context savings
                    YES → Implement context editing
                          Expect 60-90% savings on long tasks

Common Optimization Scenarios

Scenario 1: Reducing Agent Costs 50%

Before:

  • Opus 4.5 with high effort
  • Long reasoning loops
  • All 20+ tools always loaded
  • Monthly cost: $2,000

Optimizations (in order of impact):

  1. Effort Parameter: Switch to medium effort → 30% savings ($600)
  2. Tool Optimization: Use tool search + deferred loading → 20% savings ($400)
  3. Context Editing: Clear old tool results → 10% savings ($200)
  4. Total: 60% cost reduction to $800/month

Timeline: 20-30 hours implementation

Scenario 2: Reducing Classification Costs 80%

Before:

  • Opus 4.5 high effort (overkill for classification)
  • Simple yes/no decisions
  • Monthly cost: $1,000

Optimizations:

  1. Model Selection: Switch to Haiku 4.5 → 80% savings ($800)
  2. Effort Parameter: Use low effort → Additional 20% on Haiku
  3. Prompt Caching: Cache classification rules → 90% savings on cache
  4. Total: 85% cost reduction to $150/month

Timeline: 5-10 hours implementation

For deeper dives into specific optimization areas, see:

  • claude-opus-4-5-guide: Effort parameter trade-offs and Opus 4.5 capabilities
  • claude-context-management: Context editing strategies (60-90% savings on long conversations)
  • claude-advanced-tool-use: Tool optimization patterns (37-85% efficiency gains)
  • anthropic-expert: Admin API reference and prompt caching basics

For complete optimization strategies, cost prediction models, and ROI measurement frameworks, see references/ directory.

© majiayu000, 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 1 other file in skills/ai-llm/claude-cost-optimization of majiayu000/claude-skill-registry.

  • SKILL.md
  • metadata.json

Open the folder on GitHubat commit 000116a

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in majiayu000/claude-skill-registry, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Claude Cost Optimization 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.

Claude Cost Optimization compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Claude Cost Optimization this skillmajiayu000/claude-skill-registry6661 repos~3.1kAutomated safety check: PassMIT
Dt Obs GenaiDynatrace/dynatrace-for-ai161—~4.5kAutomated safety check: PassApache-2.0
Continue Enable DefaultsOnlyTerp/prompt-cache-skills114—~977Automated safety check: PassCustom licence
Commandkit Cacheneplexlabs/commandkit165—~506Automated safety check: PassMIT
LLM Cost Optimizationsickn33/agentic-awesome-skills47k1 repos~2.5kAutomated safety check: PassMIT
LLM Gatewaysickn33/agentic-awesome-skills47k1 repos~2.1kAutomated safety check: PassMIT

Similar skills

  • Dt Obs Genai

    Dynatrace/dynatrace-for-ai

    Analyze & debug GenAI/LLM apps: token cost & caching by prompt, model & provider; latency/errors; agent & tool loops/failures; conversations; guardrails; evaluations; OpenTelemetry/dt-evals setup.

    161 GitHub stars~4.5k tokensUpdated 6 days ago
    AI & LLM EngineeringAuto-check passed
  • Continue Enable Defaults

    OnlyTerp/prompt-cache-skills

    Continue's prompt caching is opt-in via config and off by default.

    114 GitHub stars~977 tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check passed
  • Commandkit Cache

    neplexlabs/commandkit

    Implement deterministic caching with @commandkit/cache. An agent skill from neplexlabs/commandkit.

    165 GitHub stars~506 tokensUpdated 10 days ago
    DatabasesAuto-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
  • LLM Gateway

    sickn33/agentic-awesome-skills

    Deploy an API gateway for LLM traffic with load balancing, rate limiting, key management, semantic caching, fallback routing, and cost tracking.

    47k GitHub starsUsed in 1 repo~2.1k tokens
    Backend & APIsAuto-check passed
  • Deploying Scalable Agents

    microsoft/ai-agents-for-beginners

    Official

    Take a working agent prototype to a scalable, observable production deployment on Microsoft Foundry.

    77k GitHub stars~1.5k tokensUpdated 18 days ago
    DevOps & CloudAuto-check passed

More from majiayu000/claude-skill-registry

All 971 skills in this repo
  • Deep Research

    majiayu000/claude-skill-registry

    Multi-source deep research using firecrawl and exa MCPs. An agent skill from majiayu000/claude-skill-registry.

    666 GitHub starsUsed in 6 repos~1.1k tokens
    Auto-check passed
  • Exa Search

    majiayu000/claude-skill-registry

    Neural search via Exa MCP for web, code, and company research.

    666 GitHub starsUsed in 5 repos~856 tokens
    Auto-check passed
  • Fal AI Media

    majiayu000/claude-skill-registry

    Unified media generation via fal.ai MCP — image, video, and audio.

    666 GitHub starsUsed in 5 repos~1.7k tokens
    Auto-check passed
  • Bgpt Paper Search

    majiayu000/claude-skill-registry

    Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server.

    666 GitHub starsUsed in 4 repos~619 tokens
    Auto-check: notes
  • Bio Alignment Pairwise

    majiayu000/claude-skill-registry

    Perform pairwise sequence alignment using Biopython Bio.Align.PairwiseAligner.

    666 GitHub starsUsed in 4 repos~1.7k tokens
    Auto-check passed
  • Open Notebook

    majiayu000/claude-skill-registry

    Self-hosted, open-source alternative to Google NotebookLM for AI-powered research and document analysis.

    666 GitHub starsUsed in 4 repos~2.4k tokens
    Auto-check passed

Questions about Claude Cost Optimization

What does Claude Cost Optimization do?

Comprehensive cost tracking and optimization for production Claude deployments. Claude Cost Optimization is an agent skill from majiayu000/claude-skill-registry. Comprehensive cost tracking and optimization for production Claude deployments.

When should I use Claude Cost Optimization?

Claude Cost Optimization fits situations like: optimizing token usage; measuring efficiency; calculating ROI; reducing production expenses.

How do I install Claude Cost Optimization in Claude Code?

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

How do I install Claude Cost Optimization in Codex?

Run `npx skills add majiayu000/claude-skill-registry --skill claude-cost-optimization -a codex`. Or copy the skill folder (skills/ai-llm/claude-cost-optimization in majiayu000/claude-skill-registry) into .agents/skills/claude-cost-optimization in your project. Codex loads it when a task matches its description.

Can I use Claude Cost Optimization 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 majiayu000/claude-skill-registry --skill claude-cost-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/claude-cost-optimization, .gemini/skills/claude-cost-optimization, .github/skills/claude-cost-optimization and .opencode/skills/claude-cost-optimization in your project.

What does Claude Cost Optimization need to run?

SKILL.md names no scripts, command-line tools or credentials: Claude Cost Optimization is instructions for the agent only. Our summary lists: Python 3.

Does Claude Cost Optimization 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 Claude Cost Optimization 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. Review the folder before installing.

What licence does Claude Cost Optimization use?

Claude Cost Optimization is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Claude Cost Optimization use?

About 3.1k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Claude Cost Optimization?

Skills that share tags, products or a category with Claude Cost Optimization: Dt Obs Genai (Dynatrace/dynatrace-for-ai, 161 stars), Continue Enable Defaults (OnlyTerp/prompt-cache-skills, 114 stars), Commandkit Cache (neplexlabs/commandkit, 165 stars) and LLM Cost Optimization (sickn33/agentic-awesome-skills, 47k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Claude Cost Optimization?

majiayu000 (a GitHub user) maintains it in majiayu000/claude-skill-registry, which has 666 GitHub stars. The repository holds 971 skills in this directory. The repository was last updated on October 7, 2026.

Source: majiayu000/claude-skill-registry on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.