cost-accrual-tracker
Track real-time API cost accrual during LLM execution. Activate on 'cost tracking', 'token usage', 'API costs', 'budget monitoring', 'usage metrics'. NOT for cost estimation, pricing tiers, or billing systems.
npx skills add majiayu000/claude-skill-registry --skill cost-accrual-tracker-curiositech-some-claude-skills --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Cost Accrual Tracker Real-time tracking of API costs during LLM execution with support for partial costs on abort. ## When to Use ✅ **Use for**: - Implementing real-time cost tracking during execution - Capturing partial costs when executions are aborted - Building cost display widgets for execution UIs - Integrating token counting into execution pipelines - Adding budget thresholds with auto-stop ❌ **NOT for**: - Cost estimation before execution (use pricing calculators) - Billing system design (use billing-system skill) - Price tier management or discounts - Historical cost analytics dashboards ## Core Patterns ### 1. Token-Based Cost Calculation ```typescript interface TokenUsage { inputTokens: number; outputTokens: number; cacheReadTokens?: number; // Prompt caching hits cacheWriteTokens?: number; // Prompt caching misses } interface CostCalculation { inputCostUsd: number; outputCostUsd: number; cacheSavingsUsd?: number; totalCostUsd: number; } function calculateCost(usage: TokenUsage, model: string): CostCalculation { const pricing = MODEL_PRICING[model]; const inputCostUsd = (usage.inputTokens / 1_000_000) * pricing.inputPerMTok; const outputCostUsd = (usage.outputTokens /
- When to Use
- Core Patterns
- 1. Token-Based Cost Calculation
- 2. Incremental Accrual Pattern
- 3. Abort-Aware Cost Capture
- 4. Budget Threshold Pattern
- Anti-Patterns
- Lost Costs on Abort
- Polling Without Debounce
- Ignoring Prompt Caching
- Per-Request Cost Objects
- State Flow
- UI Display Pattern
- Integration Points
What does the cost-accrual-tracker skill do?
Track real-time API cost accrual during LLM execution. Activate on 'cost tracking', 'token usage', 'API costs', 'budget monitoring', 'usage metrics'. NOT for cost estimation, pricing tiers, or billing systems.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill cost-accrual-tracker-curiositech-some-claude-skills --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
