cost-tracker

$npx mdskill add rohitg00/pro-workflow/cost-tracker

Track session costs, set budget alerts, and optimize token spend.

  • Check current session costs and set spending limits.
  • Depends on Claude Code's built-in cost tracking and /cost command.
  • Recommends budget alerts based on task type and complexity.
  • Displays cost summaries and optimization tips in the status bar.

SKILL.md

.github/skills/cost-trackerView on GitHub ↗
---
name: cost-tracker
description: Track session costs, set budget alerts, and optimize token spend. Use to check costs mid-session or set spending limits.
user-invocable: true
---

# Cost Tracker

Monitor and optimize Claude Code session costs.

## Trigger

Use when:
- Checking session costs
- Setting budget alerts
- Optimizing token spend
- Planning multi-session work

## Cost Awareness

### Check Current Costs
```bash
# Session cost is shown at the end of each session
# Mid-session: check the status bar or run /cost
```

### Cost Drivers

| Operation | Relative Cost | Optimization |
|-----------|--------------|-------------|
| Large file reads | High | Use offset/limit params |
| Broad grep searches | Medium | Scope to specific dirs |
| Subagent spawning | High (new context) | Reuse agents via SendMessage |
| Repeated tool calls | Cumulative | Batch operations |
| MCP tool calls | Variable | Minimize round-trips |
| Model selection | 3-10x difference | Use haiku for simple tasks |

### Token Budget by Task Type

| Task | Typical Cost | Budget Alert |
|------|-------------|-------------|
| Bug fix | $0.10-0.50 | $1.00 |
| Feature (small) | $0.50-2.00 | $3.00 |
| Feature (large) | $2.00-8.00 | $10.00 |
| Refactor | $1.00-5.00 | $7.00 |
| Code review | $0.20-1.00 | $2.00 |

### Tool-Call Budgets

Set explicit budgets by task complexity:

| Task Type | Tool-Call Budget | Wrap-Up At |
|-----------|-----------------|------------|
| Quick fix / lookup | 20 calls | 15 |
| Bug fix | 30 calls | 25 |
| Feature (small) | 50 calls | 40 |
| Feature (large) | 80 calls | 65 |
| Refactor | 50 calls | 40 |

At the wrap-up threshold: commit progress, assess remaining work, decide whether to continue or start fresh.

### Optimization Strategies

1. **Scope prompts tightly** — "Fix the auth bug in src/auth/login.ts" vs "Fix the auth bug"
2. **Use the right model** — Haiku for simple lookups, Sonnet for features, Opus for architecture
3. **Delegate to subagents** — Search/explore operations in subagents keep main context lean
4. **Compact proactively** — Don't wait for auto-compact; compact at task boundaries
5. **Read selectively** — Use `offset` and `limit` params for large files
6. **Batch operations** — Multiple independent tool calls in one message
7. **One-pass discipline** — Write complete solution, test once, stop if green
8. **No re-reads** — Don't re-read unchanged files; trust cached knowledge
9. **Read before write** — Never write a file without reading it first
10. **Kill output bloat** — No sycophantic openers, no closing fluff, no prompt restatement

## Budget Alerts

Set mental checkpoints:
- **50% budget** — Are you on track? Should you compact?
- **80% budget** — Wrap up current task, avoid new exploration
- **100% budget** — Commit what you have, start fresh session

## Output

```text
COST TRACKER
  Session cost: $X.XX
  Token usage: [input]K in / [output]K out
  Cache hit rate: ~XX%

  Top cost drivers:
    1. [operation] — $X.XX
    2. [operation] — $X.XX

  Optimization tips:
    - [specific suggestion]
```

## Rules

- Track costs as awareness, not hard limits
- Never sacrifice code quality to save tokens
- Compact at task boundaries, not mid-task
- Use subagents for exploration-heavy work

More from rohitg00/pro-workflow

SkillDescription
agent-teamsCoordinate multiple Claude Code sessions as a team — lead + teammates with shared task lists, mailbox messaging, and file-lock claiming. Patterns for team sizing, task decomposition, and when to use teams vs sub-agents vs worktrees.
auto-setupAuto-configure quality gates, hooks, and settings for a new project. Detects project type and sets up appropriate tooling. Use when onboarding a new codebase.
batch-orchestrationDecompose large-scale changes into independent units and spawn parallel agents in isolated worktrees. Use for migrations, refactors, codemods, and any change touching 10+ files with the same pattern.
bug-captureCapture a user-reported defect as a durable GitHub issue written in the project's own domain language. Explores the codebase in parallel for context but never leaks file paths or line numbers into the issue. Use when the user reports a bug conversationally, runs a QA pass, or says "file an issue", "log this as a bug", "capture this".
compact-guardSmart context compaction with state preservation. Saves critical files, task progress, and working state before compaction, restores after. Use before manual compact or when auto-compact triggers.
context-optimizerOptimize token usage and context management. Use when sessions feel slow, context is degraded, or you're running out of budget.
design-engineeringApply interface craft when building or reviewing UI - motion, easing, timing, springs, component feel, and visual foundations. Use when building a component, animation, transition, hover or press state, modal, drawer, toast, or when polishing an interface so it feels right. Says "make this feel better", "add an animation", "polish the UI", "review this component".
deslopRemove AI-generated code slop, unnecessary comments, and over-engineering from the current branch diff. Cleans up boilerplate, simplifies abstractions, strips defensive code, and in skill-file mode lints SKILL.md files for quality. Use when cleaning up code, simplifying, removing boilerplate, before committing, or when reviewing a skill before promoting it.
domain-modelingBuild the project's shared language and bounded contexts before writing code, so names stay consistent and the agent stops paraphrasing domain concepts. Produces a CONTEXT.md glossary and decision records. Use at the start of a project or feature, or when the codebase and the people describing it speak different languages.
file-watcherConfigure file watching hooks to auto-react to config changes, env file updates, and dependency modifications. Use to set up reactive workflows.