ai-cost-optimizer

ai-cost-optimizer is an agent for Claude Code from VandanaAjayDubey111/great-pm. It costs 47 tokens per session (2,323 once invoked), scanned A, original, MIT.

An AI product planning agent that examines the cost of running AI actions and proposes ways to control it, such as choosing between cheaper and more expensive models, combining requests, reusing results, or running work on a device.

In plain words
What is it for?
Use it to create cost plans for model selection, request batching, caching, prompt shortening, and deciding between cloud and on-device processing.
Why use it?
It helps prevent AI usage costs from quietly reducing product margins while keeping quality and cost trade-offs visible.

Agent for Claude Code

Written for Claude Code: effort in frontmatter. Also seen: model in frontmatter; mentions subagents.

Part of the great-pm plugin — 10 commands, 48 agents shipped together

Good fit Use it to create cost plans for model selection, request batching, caching, prompt shortening, and deciding between cloud and on-device processing.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/vandanaajaydubey111/great-pm/ai-cost-optimizer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/VandanaAjayDubey111/great-pm

Made for: Claude Code.

Or install great-pm, the plugin that ships this one along with the rest of its 10 commands, 48 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ai-cost-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/vandanaajaydubey111/great-pm/ai-cost-optimizer/github.svg)](https://agentmods.dev/agents/vandanaajaydubey111/great-pm/ai-cost-optimizer)
Your own site
<a href="https://agentmods.dev/agents/vandanaajaydubey111/great-pm/ai-cost-optimizer"><img src="https://agentmods.dev/badge/agents/vandanaajaydubey111/great-pm/ai-cost-optimizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ai-cost-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/agents/vandanaajaydubey111/great-pm/ai-cost-optimizer"><img src="https://agentmods.dev/badge/agents/vandanaajaydubey111/great-pm/ai-cost-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 47 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,323 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00047 $0.02323
Opus 5 $0.00023 $0.01162
Sonnet 5 $0.00009 $0.00465
Haiku 4.5 $0.00005 $0.00232

Measured 12d ago against content hash c8f0094370b9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

ai-cost-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/ai-cost-optimizer.md · 216 lines

How it starts

The opening of the file, as written. The whole thing — 216 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are ai-cost-optimizer — great-pm's economist for AI products. LLM-powered products bleed margin in three ways the team rarely sees until it's too late: unbatched inference, no routing tier, no caching. You author the cost plan that prevents this.

Governance (MANDATORY — overrides everything below)

You DRAFT and PROPOSE. You never change model routing in production; you author the plan and the trigger conditions. The human approves cost-vs-quality tradeoffs.

Phase task tracking

source .great-pm/env.sh 2>/dev/null || export PATH="/opt/homebrew/bin:$HOME/.local/bin:/usr/local/bin:$PATH"
mkdir -p .great-pm/drafts
SLUG="<initiative-slug>"
TASK_ID=$(bd create "ai-cost: $SLUG — ai-cost-optimizer" \
  --type task --priority 1 --label "stage-strategize,ai-cost" --json 2>/dev/null \
  | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null)
bd update "$TASK_ID" --claim 2>/dev/null

Environment setup

source .great-pm/env.sh 2>/dev/null || export PATH="/opt/homebrew/bin:$HOME/.local/bin:/usr/local/bin:$PATH"

Read past lessons FIRST

[ -f ~/.great-pm/decisions.md ] && grep -iE "cost|token|batch|cache|rout" ~/.great-pm/decisions.md | tail -20
[ -f .great-pm/lessons.md ] && grep -iE "cost|token|batch|cache|rout" .great-pm/lessons.md | tail -20
[ -f .great-pm/brain.md ] && tail -40 .great-pm/brain.md

Mission

For an AI initiative, model the per-action cost, design the cost-optimization plan (routing / batching / caching / on-device), and set the budget envelope that triggers re-architecture if breached. The output goes into the AI launch plan and informs pricing.

The five cost levers (in order of leverage)

# Lever Typical savings When to apply
1 Routing (cheap-first) 30–80% When most queries are simple enough for a small model
2 Caching (semantic + exact) 20–60% When queries repeat — common in support, FAQ, classification
3 Batching 10–40% When latency tolerates batching (background jobs, async flows)
4 Prompt compression 10–30% When prompts are bloated; aggressive few-shot
5 On-device vs cloud varies When latency or privacy demands local; cost depends on hardware

Read the full file on GitHub · 216 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 216 lines · 47 tokens per session scan A c8f0094370b9

Subscribe to this mod's changes

ai-cost-optimizer is an agent published in the GitHub repository VandanaAjayDubey111/great-pm (3 stars, last pushed 1mo ago), licensed MIT. It adds 47 tokens to every session and 2,323 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

accounting-reviewer

Bookkeeping / general-ledger / financial-close specialist pre-implementation reviewer for fintech and enterprise-saas archetypes. Outputs threat model TM-accounting-{slug}.md and signs off Critical/High mitigations before senior-dev claims tasks.

avelikiy/great_cto · 52 tokens

regulated-reviewer

Regulated-industry specialist pre-implementation reviewer for fintech / regulated archetypes. Outputs threat model TM-{slug}.md and signs off Critical/High mitigations before senior-dev claims tasks.

avelikiy/great_cto · 42 tokens

tax-reviewer

Tax preparation / filing specialist pre-implementation reviewer for the fintech archetype. Outputs threat model TM-tax-{slug}.md and signs off Critical/High mitigations before senior-dev claims tasks.

avelikiy/great_cto · 42 tokens

performance-engineer

Performance specialist. Owns SLO/SLA budget design, load test execution (k6/Locust/Gatling), latency regression analysis, flame graph interpretation, and capacity planning. Runs after senior-dev, before QA. Writes docs/performance/PERF-{slug}.md. Activated when performance-sla is set in PROJECT.md, or archetype is…

avelikiy/great_cto · 83 tokens

procurement-reviewer

Purchasing / source-to-pay specialist pre-implementation reviewer for enterprise-saas and enterprise archetypes. Outputs threat model TM-procurement-{slug}.md and signs off Critical/High mitigations before senior-dev claims tasks.

avelikiy/great_cto · 50 tokens

quant-researcher

Quantitative research agent for systematic-trading projects. Forms hypotheses, builds and runs backtests, and reports results with the validity conditions that make a backtest evidence rather than decoration — purged cross-validation with an embargo, stationarity, sample uniqueness under overlapping labels…

avelikiy/great_cto · 114 tokens