agent-cost-optimizer
Real-time cost tracking, budget enforcement, and ROI measurement for AI agent operations. Track token usage, predict costs, enforce budget caps ($50-70/month typical), optimize model selection, cache results, measure cost-to-value. Use when tracking AI costs, preventing budget overruns, optimizing spend, measuring ROI, or ensuring cost-effective AI operations.
npx skills add majiayu000/claude-skill-registry --skill agent-cost-optimizer-adaptationio-skrillz-2 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
agent-cost-optimizer provides comprehensive cost tracking, budget enforcement, and ROI measurement for AI agent operations.
How it works
- Tracks token usage per skill invocation and maintains a running cost log, including model used and per-invocation totals.
- Calculates costs by comparing usage (prompt_tokens, completion_tokens) against model-specific pricing and outputs input_cost, output_cost, and total_cost in USD.
- Enforces monthly budget caps with a per-skill budget view, warning when 80% of budget is used, and blocks operations if the estimated cost would exceed the remaining budget; offers cheaper model options or budget increases as alternatives.
- Selects cost-effective models per task using a decision matrix and an auto-optimization function based on task_type, criticality, and budget_remaining.
- Enables cost-effective caching by generating a cache key from operation inputs, checking for a cache hit, and saving results with a TTL to reduce re-computation costs.
- Measures ROI by comparing time and cost savings with and without AI, providing a monthly ROI report with detailed breakdowns.
- Predicts costs before operations using historical cost data, providing estimated_cost, confidence, and a suggested budget impact with recommended cost-saving alternatives.
When to use it
Use agent-cost-optimizer when tracking AI costs, preventing budget overruns, optimizing spend, measuring ROI, or ensuring cost-effective AI operations.
What it can touch
- Reads and writes cost-tracking logs and cache data
- May interface with cost data and historical usage for predictions
- Uses model pricing data to calculate costs
Caveats
- Pricing tables and model identifiers are provided in the skill data and are used for cost calculations; actual prices may vary over time.
- Budget enforcement logic assumes monthly budgeting and may require integration with external budget workflows.
# Agent Cost Optimizer ## Overview agent-cost-optimizer provides comprehensive cost tracking, budget enforcement, and ROI measurement for AI agent operations. **Purpose**: Control and optimize AI spending while maximizing value delivered **Pattern**: Task-based (7 operations for cost management) **Key Innovation**: Real-time cost tracking with automatic budget enforcement and cost-effective fallbacks **Industry Context** (2025): - Average AI spending: **$85,521/month** (36% YoY increase) - Only **50% of organizations can measure AI ROI** - IT teams struggle with hidden costs **Solution**: Comprehensive cost management from tracking to optimization --- ## When to Use Use agent-cost-optimizer when: - Tracking AI costs across skills - Preventing budget overruns - Measuring ROI (cost vs. value delivered) - Optimizing model selection (Opus vs. Sonnet vs. Haiku) - Planning AI budgets - Cost-effective development - Enterprise cost accountability --- ## Prerequisites ### Required - AI API access (Anthropic, OpenAI, Google) - Cost tracking capability (API usage data) ### Optional - Paid.ai or AgentOps integration (advanced cost tracking) - Prometheus/Grafana (cost visualization) - Budget ap
- Overview
- When to Use
- Prerequisites
- Required
- Optional
- Cost Operations
- Operation 1: Track Token Usage
- Operation 2: Calculate Costs
- Operation 3: Enforce Budget Caps
- Operation 4: Optimize Model Selection
- Operation 5: Cost-Effective Caching
- Operation 6: Measure ROI
- Operation 7: Predict Costs
- Cost Optimization Strategies
cat tracking.json >> .cost-tracking/$(date +%Y-%m-%d).json Check today's spending cat .cost-tracking/$(date +%Y-%m-%d).json | jq '[.[] | .cost.amount_usd] | add' Check month-to-date cat .cost-tracking/2025-01-*.json | jq '[.[] | .cost.amount_usd] | add'
What does the agent-cost-optimizer skill do?
Real-time cost tracking, budget enforcement, and ROI measurement for AI agent operations. Track token usage, predict costs, enforce budget caps ($50-70/month typical), optimize model selection, cache results, measure cost-to-value. Use when tracking AI costs, preventing budget overruns, optimizing spend, measuring ROI, or ensuring cost-effective AI operations.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill agent-cost-optimizer-adaptationio-skrillz-2 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
