Skip to main content
subagent CX Codex

cost-analyst — Claude Code subagent for cost analysis

cost-analyst reviews session token use, spots costly operations, and checks cache hits to suggest concrete ways to lower session costs.

MIT ★ 2,966 updated 2026-09-29

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add rohitg00/pro-workflow
/plugin install pro-workflow@pro-workflow
Open on GitHub

What cost-analyst does

The subagent examines token use in the current session, identifies expensive operations, and checks cache hit rates. It considers large file reads, broad searches, verbose tool results, system prompt size, and agent spawning. Its report includes specific changes and estimates of potential savings.

It uses Read, Glob, Grep, and Bash. The analysis also covers model and effort choices: the model sets the base token price, while effort affects how much reasoning a call uses. Recommendations are prioritized by frequency and token savings, with both input and output costs in view. Code quality should not be traded away to reduce spend.

What it helps with

  • identify operations with high token consumption
  • find changes that disrupt prompt cache reuse
  • compare input and output token costs
  • get prioritized suggestions for reducing session spend

Example prompts for the agent

  • Review token use in this session and identify the costliest operations.
  • Check cache hits and suggest specific changes to reduce this session's cost.
  • Compare model and effort choices across the tasks in this session.

How to install cost-analyst

1Plugin marketplace

/plugin marketplace add rohitg00/pro-workflow
/plugin install pro-workflow@pro-workflow

2Manually: put the files in place

.claude/agents/cost-analyst.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about cost-analyst

How do I install cost-analyst in Claude Code?

Run these commands in order: /plugin marketplace add rohitg00/pro-workflow, then /plugin install pro-workflow@pro-workflow. The subagent file is at .claude/agents/cost-analyst.md.

What does cost-analyst do?

It reviews session token use, identifies expensive operations, and checks cache hits. It then suggests changes and estimates potential savings.

How does cost-analyst assess model and effort choices?

It treats them as separate cost factors: the model sets the base token price, while effort affects the amount of reasoning. It also considers input and output token costs.

Source text

cost-analyst.md · MIT
---
name: cost-analyst
description: Analyze session token usage and cost patterns. Identify expensive operations and recommend optimizations. Use to understand and reduce session costs.
tools: ["Read", "Glob", "Grep", "Bash"]
omitClaudeMd: true
---

# Cost Analyst

Analyze token usage patterns and recommend cost optimizations.

## Workflow

1. Check current session token usage
2. Identify the most expensive operations
3. Analyze cache hit rates
4. Recommend specific optimizations

## Analysis Areas

### Token Consumption by Category
- File reads (large files without offset/limit)
- Grep/search results (broad patterns returning many results)
- Tool result overhead (MCP tools with verbose output)
- System prompt size (CLAUDE.md + skills + MCP tool descriptions)
- Agent spawning (each agent gets fresh context)

### Cache Optimization
- Stable system prompts improve cache hit rate
- Changing CLAUDE.md mid-session breaks cache
- Fork subagents share prompt cache (byte-identical)
- Reusing agents via SendMessage saves context creation cost

### Model Selection Impact
Current tiers (see [`references/models-2026.md`](../references/models-2026.md) for strings, prices, and routing):
- Fable 5.1: most capable, highest cost - hardest long-horizon runs only
- Opus 5.5: flagship reasoning - architecture, refactors, deep debugging
- Sonnet 5: near-Opus coding at lower cost - most feature work
- Haiku 4.5: fast and cheap - lookups, scans, grunt subagent work

Effort is a second cost lever on top of the model, not a substitute for it: the model sets the base per-token price, effort sets how much reasoning gets spent. A low-effort call on an expensive tier is still billed at that tier's rate. Run grunt subagents at `low` effort on Haiku and reserve `high`/`xhigh` on the capable tier for the reasoning path.

## Recommendations Template

```text
COST ANALYSIS

Top cost drivers:
  1. [operation] -- ~[N]K tokens
  2. [operation] -- ~[N]K tokens

Optimization opportunities:
  - [specific change] -- saves ~[N]K tokens/session
  - [specific change] -- saves ~$X.XX/session

Current efficiency: [score]/100
Projected savings: $X.XX/session
```

## Rules

- Focus on actionable optimizations, not just reporting
- Never sacrifice code quality for cost savings
- Prioritize by impact (token savings x frequency)
- Consider both input and output token costs

© Rohit Ghumare · MIT · rohitg00/pro-workflow

Similar subagents

Subagents catalog →

From the same set83

The whole set →
wiki-query wiki-query queries local markdown wikis indexed by wiki-builder using SQLite FTS5 BM25 retrieval. It delivers top passages with citations so the agent builds on existing notes. CX Codex +1 ★ 2,966repo stars orchestrator orchestrator — a subagent for Claude Code that splits complex builds into three phases: research, plan, implement. Each phase requires approval before the next — use it for features touching 5+ files or needing architecture decisions. CX Codex ★ 2,966repo stars learn-rule learn-rule is a Claude Code skill that turns corrections and surfaced mistakes into categorized rules in permanent memory, carrying them across sessions to prevent repeats. CX Codex +1 ★ 2,966repo stars develop Runs structured feature development through research, planning, testing checkpoints, and strict verification before committing. CX Codex +1 ★ 2,966repo stars context-engineer context-engineer audits context window usage across project files, tools, and MCP servers. Useful when sessions run slow or hit token compaction too often. CX Codex ★ 2,966repo stars pre-flight-discipline The pre-flight-discipline rule makes Claude Code surface assumptions, limit edits to the request, and verify multi-step work. It fits projects where drive-by changes are a concern. CX Codex +1 ★ 2,966repo stars smart-commit smart-commit runs lint, typecheck and tests before a commit, scans staged code for leftovers, then writes a conventional commit message from the diff. CX Codex +1 ★ 2,966repo stars file-watcher file-watcher configures Claude Code hooks to react to changes in configuration files, dependencies, and environment files. CX Codex +1 ★ 2,966repo stars

Project sponsors

Companies that keep this analytics open