From hatch3r
Tracks token usage and estimates costs for AI agent sessions. Use for monitoring spend, budget limits, or generating reports.
npx claudepluginhub hatch3r/hatch3rThis skill uses the workspace's default tool permissions.
```
Tracks Claude Code session costs, sets budget alerts, and optimizes token spend with task budgets, cost drivers, and strategies. Useful for mid-session checks and multi-session planning.
Tracks token usage per cycle in agentic systems, audits context growth, enforces budget caps, prunes low-value content, and integrates progressive disclosure. For long-lived loops, cost spikes, and workflow guardrails.
Share bugs, ideas, or general feedback.
Task Progress:
- [ ] Step 1: Review cost tracking configuration
- [ ] Step 2: Estimate current session token usage
- [ ] Step 3: Identify cost optimization opportunities
- [ ] Step 4: Generate cost report
hatch.json for a costTracking section.sessionBudget, issueBudget, epicBudget.hardStop is enabled.Estimate tokens for the current session using these rules:
| Content Type | Rule | Accuracy |
|---|---|---|
| Messages | ~4 characters per token | High -- stable ratio for English text |
| Tool calls | JSON length / 4 (input), response length / 4 (output) | Medium -- JSON has more overhead characters |
| File reads | Character count / 4 | High -- but large files may be truncated by the tool |
| Web searches | ~500 tokens per search | Low -- varies widely by result length |
| Subagent spawns | Estimate full context re-sent per spawn (~2000-5000 tokens base) | Medium -- depends on included rules/context |
Subagent cost multiplier. Each subagent spawn carries a base cost for the agent protocol, included rules, and context. A pipeline with 8 subagents (researcher + implementer + reviewer + fixer + 4 Phase 4 specialists) has significant overhead from context re-transmission. Factor this into budget estimates.
Calculate estimated cost using the model tier rates from the hatch3r-cost-tracking command reference.
Review usage patterns for savings:
Produce a cost report using the output format from the hatch3r-cost-tracking command. Include:
hatch3r-cost-tracking — full cost tracking protocol with guardrails and budget enforcementhatch3r-context-health — context health monitoring complements cost tracking for session management