bundles/dev-workflow/skills/ai-agent-cost-optimizer/SKILL.md
Audit and reduce AI agent token and inference spend through context discipline, prompt caching, model routing, batching, and workflow capture. Use when discussing AI coding bills, token waste, model selection, prompt caching, or agent cost optimization.
npx skillsauth add shipshitdev/library ai-agent-cost-optimizerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reduce AI agent spend without reducing shipped quality. Optimize for cost per correct completed task, not raw token count.
Price the model and context to the cost of failure.
Use more capable models when a wrong answer could create expensive rework, security risk, data loss, or architectural drag. Use cheaper models and smaller context when the task is bounded, reversible, test-covered, or mechanical.
Do not save tokens in ways that increase retries, hide important evidence, or lower code quality.
Identify what is actually driving cost before recommending changes:
If usage data is unavailable, mark it unknown and inspect local configs, logs, scripts, or provider dashboards only when accessible.
Pricing, model availability, cache behavior, and benchmark rankings are date-sensitive. Verify current provider documentation before citing specific prices or recommending a model as the default.
Treat social posts, benchmark screenshots, and vendor marketing as hypotheses. Convert them into local tests before changing default routing.
Look for these common waste patterns:
Fix context shape first:
Design stable prefixes:
Do not generalize that streaming breaks caching. Cache misses usually come from unstable prefixes, unsupported providers or models, thresholds, TTL expiry, or changed tool/message structure.
Use this rubric as the starting point:
| Task | Default Tier | Promote When | |------|--------------|--------------| | Architecture, security-critical review, irreversible operations, high-blast-radius refactors | Premium | Already premium; add review or tests | | Feature implementation, debugging, test writing, routine refactors | Workhorse | Failing repeatedly, weak tests, or hidden architecture risk | | Lint, format, rename, simple extraction, boilerplate, classification | Utility or local | Output needs nuanced judgment or affects production behavior | | Long agentic loops | Workhorse with strict context budgets | Loop reaches unclear design decisions or persistent failures | | Exploration across unknown codebases | Workhorse or premium for initial map, then cheaper tier for bounded follow-up | Architecture is unclear or stakes are high |
Use local evaluation over broad leaderboard claims. A cheaper model that doubles retries may be more expensive than the premium model.
Batch related small questions into one call when they share context. Partition broad tasks into independent subtasks when each subtask can run with isolated context and return a compact result.
Avoid spawning extra agents just to parallelize trivial work. Multi-agent systems can increase token spend unless context isolation or wall-clock savings justify the overhead.
When a workflow is repeated and stable, capture it so agents stop rediscovering it:
Capture the final working workflow, not the exploratory path that found it.
Compare before and after using task-level metrics:
Report savings as measured ranges. Avoid unsupported claims like "80% reduction" unless the baseline and after-state are both known.
When auditing a workflow, return:
Related skills:
context-fundamentals - Understand what consumes contextcontext-optimization - Apply compaction, masking, caching, and partitioningmulti-agent-patterns - Evaluate when sub-agent context isolation is worth the overheadtool-design - Reduce tool ambiguity and response bloatskill-capture - Persist repeated workflows as reusable skillsdevelopment
TypeScript refactoring and modernization guidelines from a principal specialist perspective. This skill should be used when refactoring, reviewing, or modernizing TypeScript code to ensure type safety, compiler performance, and idiomatic patterns. Triggers on tasks involving TypeScript type architecture, narrowing, generics, error handling, or migration to modern TypeScript features.
tools
Resolves TypeScript and JavaScript problems across type-level programming, performance, monorepo management, migration, and modern tooling. Invoke when diagnosing "type instantiation excessively deep" errors, migrating JS to TS, configuring strict tsconfig, debugging module resolution, or choosing between Biome/ESLint/Turborepo/Nx.
tools
Turborepo monorepo build system guidance. Triggers on: `turbo.json`, task pipelines, `dependsOn`, caching, remote cache, the `turbo` CLI, `--filter`, `--affected`, CI optimization, environment variables, internal packages, monorepo structure, and package boundaries. Use when the user configures tasks or workflows, creates packages, sets up a monorepo, shares code between apps, runs changed packages, debugs cache behavior, or works in an `apps/` plus `packages/` workspace.
tools
Provides Tailwind CSS v4 performance optimization and best practices guidelines. Triggers when writing, reviewing, or refactoring Tailwind CSS v4 code; when working with Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.