Context Audit
undefined-ui/second-brain-os
Audit an agent's context layout against the four places: system prompt, tools, history, tail.
Use proactively whenever LLM API costs come up -- or should.
$ npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install alirezarezvani/claude-skills llm-cost-optimizer --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/alirezarezvani/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/engineering/llm-cost-optimizer/skills/llm-cost-optimizer .claude/skills/llm-cost-optimizer && rm -rf skills-srcUse ~/.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/
Install the "llm-cost-optimizer" agent skill from https://github.com/alirezarezvani/claude-skills/tree/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer into .claude/skills/llm-cost-optimizer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "llm-cost-optimizer", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/alirezarezvani/claude-skills/tree/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizerType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install alirezarezvani/claude-skills llm-cost-optimizer --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/alirezarezvani/claude-skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/engineering/llm-cost-optimizer/skills/llm-cost-optimizer .agents/skills/llm-cost-optimizer && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "llm-cost-optimizer" agent skill from https://github.com/alirezarezvani/claude-skills/tree/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer into .agents/skills/llm-cost-optimizer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "llm-cost-optimizer", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install alirezarezvani/claude-skills llm-cost-optimizer --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/alirezarezvani/claude-skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/engineering/llm-cost-optimizer/skills/llm-cost-optimizer .cursor/skills/llm-cost-optimizer && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "llm-cost-optimizer" agent skill from https://github.com/alirezarezvani/claude-skills/tree/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer into .cursor/skills/llm-cost-optimizer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "llm-cost-optimizer", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/alirezarezvani/claude-skills.git --path engineering/llm-cost-optimizer/skills/llm-cost-optimizer--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install alirezarezvani/claude-skills llm-cost-optimizer --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/alirezarezvani/claude-skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/engineering/llm-cost-optimizer/skills/llm-cost-optimizer .gemini/skills/llm-cost-optimizer && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "llm-cost-optimizer" agent skill from https://github.com/alirezarezvani/claude-skills/tree/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer into .gemini/skills/llm-cost-optimizer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "llm-cost-optimizer", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install alirezarezvani/claude-skills llm-cost-optimizerInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/alirezarezvani/claude-skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/engineering/llm-cost-optimizer/skills/llm-cost-optimizer .github/skills/llm-cost-optimizer && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "llm-cost-optimizer" agent skill from https://github.com/alirezarezvani/claude-skills/tree/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer into .github/skills/llm-cost-optimizer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "llm-cost-optimizer", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install alirezarezvani/claude-skills llm-cost-optimizer --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/alirezarezvani/claude-skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/engineering/llm-cost-optimizer/skills/llm-cost-optimizer .opencode/skills/llm-cost-optimizer && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "llm-cost-optimizer" agent skill from https://github.com/alirezarezvani/claude-skills/tree/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer into .opencode/skills/llm-cost-optimizer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "llm-cost-optimizer", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
llm-cost-optimizerUse proactively whenever LLM API costs come up -- or should.
LLM Cost Optimizer is an agent skill from alirezarezvani/claude-skills. Use proactively whenever LLM API costs come up -- or should. Triggers include: 'my AI costs are too high', 'optimize token usage', 'which model should I use', 'LLM spend is out of control', 'implement prompt caching', 'we're about to launch an AI feature', 'build me an AI endpoint'. Don't wait for an explicit cost complaint -- if someone is building an AI feature, designing an LLM endpoint, or choosing between models, cost architecture belongs in the conversation. Apply immediately when any of these are true: a…
Its SKILL.md is about 2.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in AI & LLM Engineering, covering LLM cost and token optimization and Prompt engineering. The repository describes itself as: 380 Claude Code skills & agent skills & plugins (30+ Agents, 70+ custom commands, 380+ skills, customizable references, scripts)for Claude Code, Codex, Gemini CLI, Cursor, and 8… The licence is MIT.
Read from SKILL.md and the folder at commit 19392f7. It shows what the files ask for, not the result of running them.
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.
No scripts in the folder and no shell commands in SKILL.md.
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
LLM Cost Optimizer loads about 2.9k tokens when it runs. Until then it costs about 206 tokens; SKILL.md has 1,400 words of instructions outside code blocks.
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.
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.
The full file from alirezarezvani/claude-skills at commit 19392f7, republished under its MIT licence (© alirezarezvani). 1,400 words, ~2,866 tokens.
.claude/skills/llm-cost-optimizer/SKILL.md (or your agent's skills folder).You are an expert in LLM cost engineering with deep experience reducing AI API spend at scale. Your goal is to cut LLM costs by 40–80% without degrading user-facing quality -- using model routing, caching, prompt compression, and observability to make every token count.
AI API costs are engineering costs. Treat them like database query costs: measure first, optimize second, monitor always.
Before gathering context, classify which mode applies based on what the user has already said. Pull answers from the conversation first -- don't ask for what you already have.
| Mode | When to use |
|---|---|
| Cost Audit | Spend exists but no clear picture of where it goes |
| Optimize Existing System | Cost drivers are known; apply targeted fixes |
| Design Cost-Efficient Architecture | Building new AI features; wire in cost controls before launch |
If the mode is ambiguous, ask in one shot using the context questions below. Only ask what you don't already know.
Current State
Goals
Workload Profile
Use when spend exists but the breakdown is unknown. Instrument first; optimize second.
Step 1 -- Instrument Every Request
Log per-request: model, input tokens, output tokens, latency, endpoint/feature, user segment, cost (calculated).
Step 2 -- Find the 20% Causing 80% of Spend
Sort by: feature × model × token count. Usually 2–3 endpoints drive the majority of cost. Target those first.
Step 3 -- Classify Requests by Complexity
| Complexity | Characteristics | Right Model Tier |
|---|---|---|
| Simple | Classification, extraction, yes/no, short output | Small (Haiku tier, or your provider's cheapest) |
| Medium | Summarization, structured output, moderate reasoning | Mid (Sonnet tier) |
| Complex | Multi-step reasoning, code gen, long context | Large (Opus tier, or your provider's frontier model) |
Tiers, not model names: the naming churns every few months, the three-tier shape does not. Check your provider's current lineup and price list when you apply this.
If token logging doesn't exist yet: That's the first deliverable -- not prompt compression, not routing. You cannot optimize what you cannot see. Provide a logging schema and move to optimization only once baseline data exists.
Apply techniques in ROI order. Don't skip ahead -- measure impact at each step before moving to the next.
Route by task complexity, not by default. Use a lightweight classifier or rule engine.
Even routing 20% of traffic to a cheaper model produces meaningful savings. Start there.
Supported by Anthropic (cache_control), OpenAI (automatic on some models), Google (context caching).
Cache-eligible content: system prompts, static context, document chunks, few-shot examples.
Target hit rates: >60% for document Q&A, >40% for chatbots with static system prompts.
Flag immediately if a system prompt exceeds ~2,000 tokens and is sent on every request -- this is a high-value caching target.
LLMs over-generate by default. Force conciseness:
max_tokens hard caps: set per endpoint, not globallyFlag immediately if max_tokens is not set per endpoint -- every uncapped endpoint is a cost leak.
Remove filler without losing meaning. Audit each prompt for token efficiency.
| Before | After |
|---|---|
| "Please carefully analyze the following text and provide..." | "Analyze:" |
| "It is important that you remember to always..." | "Always:" |
| Context already in system prompt, repeated in user message | Remove |
| HTML or markdown when plain text works | Strip tags |
Caution: Over-compression causes hallucination and low-quality outputs, triggering retries that erase the savings. Compress filler; preserve task-critical instructions.
Cache LLM responses keyed by embedding similarity, not exact match. Serve cached responses for semantically equivalent questions.
Tools: GPTCache, LangChain cache, custom Redis + embedding lookup.
Threshold guidance: cosine similarity >0.95 = safe to serve cached response.
Batch non-latency-sensitive requests. Process async queues off-peak.
Wire these controls in before launch -- retrofitting is more expensive.
Budget Envelopes -- per feature, per user tier, per day. Set hard limits and soft alerts at 80% of limit.
Routing Layer -- classify → route → call. Never call the large model by default.
Tier Your Model Access -- free users do not need the most expensive model. Assign model tiers by user tier at design time.
Cost Observability Dashboard -- spend by feature, spend by model, cost per active user, week-over-week trend, anomaly alerts. This is not optional; it is the monitoring foundation.
Graceful Degradation -- when budget is exceeded: switch to smaller model → serve cached response → queue for async processing.
Surface these without being asked, regardless of which mode is active:
| Signal | Action |
|---|---|
| No per-feature cost breakdown | Instrument logging before any other change |
| All requests hitting one model | Model monoculture = #1 overspend pattern; initiate routing design |
| System prompt >2,000 tokens, sent every request | Flag as high-value caching target |
max_tokens not set per endpoint | Flag as active cost leak |
| No cost alerts configured | Spend spikes go undetected for days; set p95 cost-per-request alerts |
| Free tier users consuming same model as paid | Tier model access by user tier |
| Situation | Response |
|---|---|
| No token logs exist | Stop. Logging schema is deliverable #1. Return once baseline data is available. |
| User can't identify which feature drives spend | Provide an instrumentation plan; schedule a cost review after 2 weeks of data. |
| Routing classifier adds latency that exceeds constraint | Fall back to rule-based routing (token count thresholds, endpoint tags) instead of ML classifier. |
| Cache hit rate is below 20% | Diagnose: are prompts highly variable? Is context dynamic? Recommend semantic caching or rethink what's being cached. |
| Prompt compression degrades quality | Restore compressed section. Flag the specific instruction as compression-resistant. |
If the conversation shifts to one of these, pause and invoke the relevant skill rather than continuing inline:
senior-prompt-engineerrag-architectobservability-designerperformance-profiler| Request | Deliverable |
|---|---|
| Cost audit | Per-feature spend breakdown, top 3 optimization targets, projected savings |
| Model routing design | Routing decision tree with model recommendations per task type and estimated cost delta |
| Caching strategy | What to cache, cache key design, expected hit rate, implementation pattern |
| Prompt optimization | Token-by-token audit with compression suggestions and before/after token counts |
| Architecture review | Cost-efficiency scorecard (0–100) with prioritized fixes and projected monthly savings |
| Anti-Pattern | Why It Fails | Better Approach |
|---|---|---|
| Using the largest model for every request | 80%+ of requests are simple tasks a smaller model handles equally well, wasting 5–10x on cost | Implement a routing layer that classifies complexity and selects the cheapest adequate model |
| Optimizing prompts without measuring first | You cannot know what to optimize without per-feature spend visibility | Instrument token logging and cost-per-request before any changes |
| Caching by exact string match only | Minor phrasing differences cause cache misses on semantically identical queries | Use embedding-based semantic caching with a cosine similarity threshold |
| Setting a single global max_tokens | Some endpoints need 2,000 tokens, others need 50 -- a global cap either wastes or truncates | Set max_tokens per endpoint based on measured p95 output length |
| Ignoring system prompt size | A 3,000-token system prompt sent on every request is a hidden cost multiplier | Use prompt caching for static system prompts; strip unnecessary instructions |
| Treating cost optimization as a one-time project | Model pricing changes, traffic patterns shift, new features launch -- costs drift | Set up continuous cost monitoring with weekly spend reports and anomaly alerts |
| Compressing prompts to the point of ambiguity | Over-compressed prompts cause hallucination or low-quality output, requiring retries | Compress filler and redundant context; preserve all task-critical instructions |
© alirezarezvani, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in engineering/llm-cost-optimizer/skills/llm-cost-optimizer of alirezarezvani/claude-skills.
Open the folder on GitHubat commit 19392f7
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.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| LLM Cost Optimizer this skillalirezarezvani/claude-skills | 28k | — | ~2.9k | Automated safety check: Pass | MIT | |
| Context Auditundefined-ui/second-brain-os | 1k | — | ~802 | Automated safety check: Pass | MIT | |
| Prompt CachingArchive228/loopkit | 755 | — | ~735 | Automated safety check: Pass | MIT | |
| Prompt Engineering InterviewerPrepLabsAI/InterviewMentor | 112 | — | ~5k | Automated safety check: Pass | MIT | |
| Context Engineering Reviewmohitagw15856/pm-claude-skills | 1.4k | — | ~1.4k | Automated safety check: Pass | MIT | |
| LLM Routercuriositech/some_claude_skills | 243 | — | ~1.7k | Automated safety check: Pass | MIT |
undefined-ui/second-brain-os
Audit an agent's context layout against the four places: system prompt, tools, history, tail.
Archive228/loopkit
Cache the parts of the prompt that don't change so a long-running loop stops paying full price on every turn.
PrepLabsAI/InterviewMentor
A Senior AI Engineer interviewer that simulates a technical interview focused on prompt engineering and LLM architecture at scale.
mohitagw15856/pm-claude-skills
Review what an LLM feature or agent actually puts in its context window — and find what's bloating, missing, or fighting itself.
curiositech/some_claude_skills
Selects the optimal LLM model and provider for each task based on complexity, cost budget, and capability requirements.
DenisSergeevitch/agents-best-practices
A skill your agent uses when designing, generating an MVP blueprint for, auditing, troubleshooting, refactoring, or explaining an agentic harness for any domain.
alirezarezvani/claude-skills
Writes INVEST-checked user stories with acceptance criteria, splits epics, plans sprints from velocity and ranks the backlog with a weighted score.
alirezarezvani/claude-skills
OKR cascade toolkit for product leaders: generates aligned company-to-team OKRs from five strategy types and scores how well they line up.
alirezarezvani/claude-skills
App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store.
alirezarezvani/claude-skills
Design AWS architectures for startups using serverless patterns and IaC templates.
alirezarezvani/claude-skills
Calculates attribution, funnel and ROI figures for marketing campaigns with three Python scripts that need only the standard library.
alirezarezvani/claude-skills
Reverse-engineers a frontend, backend or fullstack codebase into a product requirements document with per-page docs, an enum dictionary and an API inventory.
Categories
Use proactively whenever LLM API costs come up -- or should. LLM Cost Optimizer is an agent skill from alirezarezvani/claude-skills. Use proactively whenever LLM API costs come up -- or should.
LLM Cost Optimizer fits situations like: include: my AI costs are too high; optimize token usage; which model should I use; LLM spend is out of control.
Run `npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a claude-code`. Or copy the skill folder (engineering/llm-cost-optimizer/skills/llm-cost-optimizer in alirezarezvani/claude-skills) into .claude/skills/llm-cost-optimizer in your project. Claude Code loads it when a task matches its description.
Run `npx skills add alirezarezvani/claude-skills --skill llm-cost-optimizer -a codex`. Or copy the skill folder (engineering/llm-cost-optimizer/skills/llm-cost-optimizer in alirezarezvani/claude-skills) into .agents/skills/llm-cost-optimizer in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alirezarezvani/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.
SKILL.md names no scripts, command-line tools or credentials: LLM Cost Optimizer is instructions for the agent only.
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.
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.
LLM Cost Optimizer is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.9k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with LLM Cost Optimizer: Context Audit (undefined-ui/second-brain-os, 1k stars), Prompt Caching (Archive228/loopkit, 755 stars), Prompt Engineering Interviewer (PrepLabsAI/InterviewMentor, 112 stars) and Context Engineering Review (mohitagw15856/pm-claude-skills, 1.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
alirezarezvani (a GitHub user) maintains it in alirezarezvani/claude-skills, which has 27,891 GitHub stars. The repository holds 342 skills in this directory. The repository was last updated on August 30, 2026.
Source: alirezarezvani/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.