ai-cost-optimizer
LLM cost reduction: prompt caching, model routing, token optimization, and batching.
Skill by UltronCore
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ultroncore-ai-cost-optimizer
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, ml, finance, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/ai-cost-optimizer
What's inside
- Skill name
ai-cost-optimizer- Description
- LLM cost reduction: prompt caching, model routing, token optimization, and batching. Triggers on: prompt caching, cache_control, token budget, cost optimization, batch API, model routing, input tokens.
- License
- MIT
- Instructions
- 432 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- body: contains an absolute path from the author's machine
Files (2)
- SKILL.md
- metadata.json
SKILL.md (first lines)
# AI Cost Optimizer
## When to Use
- Adding prompt caching to reduce repeated system prompt costs
- Choosing the right model tier for a task (Haiku vs Sonnet vs Opus)
- Using the Batch API for offline/async workloads
- Counting tokens before sending a request
- Truncating conversation history to fit a budget
- Estimating API costs before running a pipeline
## Core Rules
1. Always cache system prompts and static context — they're re-sent every turn and caching cuts that cost by ~90%.
2. `cache_control: {type: "ephemeral"}` requires a minimum of 1024 tokens to actually cache.
3. Cached tokens cost ~10% of normal input price; first-fill costs ~25% more but is amortized quickly.
4. Use `claude-haiku-4-5` for classification, routing, extraction, and simple Q&A — it's 10-30x cheaper than Opus.
5. Use the Batch API for any workload that can wait up to 24 hours — it's 50% cheaper than the sync API.
6. Count tokens with `client.messages.count_tokens()` before running expensive pipelines.
7. Truncate conversation history from the middle, not the end — preserve system context and recent messages.
8. Set `max_tokens` to the actual expected output length — you pay for capacity, not unused tokens.
9. For RAG, retrieve only the top-K most relevant chunks; don't stuff the full document into context.
10. Cache the large/static part of the prompt at the top; dynamic content goes at the bottom (cache reads are positional from the top).
## Pricing Reference (approximate, check anthropic.com for latest)
| Model | Input (per 1M) | Output (per 1M) | Cache Write | Cache Read |
|-------|---------------|-----------------|-------------|------------|
| claude-haiku-4-5 | $0.80 | $4.00 | $1.00 | $0.08 |
| claude-sonnet-4-5 | $3.00 | $15.00 | $3.75 | $0.30 |
| claude-opus-4-5 | $15.00 | $75.00 | $18.75 | $1.50 |
## Prompt Caching (Python)
```python
import anthropic
client = anthropic.Anthropic()
LARGE_DOCUMENT = "..." * 500 # 1000+ tokens of static content
response = client.messages.create(
model="claude-opus-4-5",
max_tokens=1024,
system=[
{
"type": "text",
"text": "You are an expert document analyst. Answer questions precisely.",
},
{
"type": "text",
"text": LARGE_DOCUMENT,
"cache_control": {"type": "ephemeral"}, # Cache this block
},
],
messages=[{"role": "user", "content": "What are the main themes?"}],
)
# Check cache performance
usage = response.usage
print(f"Input tokens: {usage.input_tokens}")
print(f"Cache creation: {getattr(usage, 'cache_creation_input_tokens', 0)}")
print(f"Cache read: {getattr(usage, 'cache_read_input_tokens', 0)}")
# Second request — cache_read_input_tokens will be high
response2 = client.messages.create(
model="claude-opus-4-5",
max_tokens=1024,
system=[
{"type": "text", "text": "You are an expert document analyst."},
{
"type": "text",
"text": LARGE_DOCUMENT,
"cache_control": {"type": "ephemeral"}, # Same block = cache hit
},
],
messages=[{"role": "user", "content": "Who are the key stakeholders?"}],
)
```
## Prompt Caching (TypeScript)
```typescript
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const STATIC_CONTEXT = "...".repeat(300); // Must be 1024+ tokens
async function askWithCache(question: string) {
const response = await client.messages.create({
model: "claude-opus-4-5",
max_tokens: 1024,
system: [
{
type: "text",
text: "You are a helpful assistant. Answer concisely.",
},
{
type: "text",
text: STATIC_CONTEXT,
// @ts-ignore — cache_control is a beta field
cache_control: { type: "ephemeral" },
},
] as Anthropic.TextBlockParam[],
messages: [{ role: "user", content: question }],
});
const usage = response.usage as Anthropic.Usage & {
cache_creation_input_tokens?: number;
cache_read_input_tokens?: number;
};
console.log(`Cache hit: ${usage.cache_read_input_tokens ?? 0} tokens`);
return (response.content[0] as Anthropic.TextBlock).text;
}
```
## Caching Conversation History
```pythonFrom UltronCore/claude-skill-vault, MIT.
More from UltronCore/claude-skill-vault
- 0.494score
ai-agent-memory
UltronCore
Design and implement memory systems for AI agents — short-term working context, episodic memory in vector stores, entity extraction into knowledge graphs…
SkillCFreshness: C★ 1Claude Code +9 - 0.493score
claude-tool-use
UltronCore
Advanced Claude tool/function calling patterns: tool definitions, parallel tool use, tool result chaining, and agentic loops.
SkillCFreshness: C★ 1Claude Code +9 - 0.493score
embeddings-expert
UltronCore
Text embeddings for semantic search, clustering, RAG retrieval, and similarity.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
autogen
UltronCore
Microsoft's multi-agent conversation framework for building collaborative AI workflows
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
guidance
UltronCore
Microsoft's structured generation library for constrained LLM outputs using Handlebars-style templates
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
haystack
UltronCore
Production-ready LLM pipeline framework with component-based architecture for RAG and QA
SkillCFreshness: C★ 1Claude Code +9 - 0.485score
diffusion-models
UltronCore
Build and deploy diffusion model pipelines for image generation, inpainting, and fine-tuning using Hugging Face Diffusers.
SkillCFreshness: C★ 1Claude Code +9 - 0.485score
embedding-pipeline
UltronCore
Build production embedding pipelines for semantic search, RAG, and recommendation systems.
SkillCFreshness: C★ 1Claude Code +9 - 0.484score
computer-vision
UltronCore
Computer vision tasks: image classification, object detection, OCR, and manga/comic image processing.
SkillCFreshness: C★ 1Claude Code +9 - 0.483score
skill-name
UltronCore
One-line description of what this skill does and when to use it.
SkillCFreshness: C★ 1Claude Code +9 - 0.264score
ab-testing-statistics-ai-ml-stub
UltronCore
No description from the publisher yet.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 24, 2026 (5 months ago)
- Last release
- May 24, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/UltronCore/claude-skill-vault
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from UltronCore
- 0.494score
ai-agent-memory
UltronCore
Design and implement memory systems for AI agents — short-term working context, episodic memory in vector stores, entity extraction into knowledge graphs…
SkillCFreshness: C★ 1Claude Code +9 - 0.493score
claude-tool-use
UltronCore
Advanced Claude tool/function calling patterns: tool definitions, parallel tool use, tool result chaining, and agentic loops.
SkillCFreshness: C★ 1Claude Code +9 - 0.493score
embeddings-expert
UltronCore
Text embeddings for semantic search, clustering, RAG retrieval, and similarity.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
guidance
UltronCore
Microsoft's structured generation library for constrained LLM outputs using Handlebars-style templates
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
haystack
UltronCore
Production-ready LLM pipeline framework with component-based architecture for RAG and QA
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
autogen
UltronCore
Microsoft's multi-agent conversation framework for building collaborative AI workflows
SkillCFreshness: C★ 1Claude Code +9
Cite this page
ai-cost-optimizer skill. Agent Mart. https://agentmart.dev/skills/ultroncore-ai-cost-optimizer (last updated 2026-10-24)