
cost-track
Auto-capture per-session token usage from the Claude Code session jsonl and persist to the cost-tracking namespace
- Installs
- 684
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/ruvnet/ruflo --skill cost-track- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads cost-track automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Cost Track
Reads the active Claude Code session jsonl (~/.claude/projects/<encoded-cwd>/<session>.jsonl), tallies assistant-message usage per model, computes USD cost using REFERENCE.md pricing, and writes a structured record to the cost-tracking AgentDB namespace. This is the producer that gives cost-report and cost-optimize real data to consume.
When to use
- After a meaningful chunk of work, to capture spend for the report.
- At session-end to persist the final tally.
- Periodically during long sessions (cron-friendly — see
/loop 30m).
Steps
-
Run the tracker from the project root:
node plugins/ruflo-cost-tracker/scripts/track.mjsThe script auto-discovers the session jsonl from the current working directory. To pin a specific session:
TRACK_SESSION=/path/to/session.jsonl. To dry-run (no memory write):TRACK_DRY_RUN=1. -
Inspect the markdown summary — total cost, per-model and per-tier breakdowns, and the persisted memory key.
-
Verify persistence —
mcp__plugin_ruflo-core_ruflo__memory_search --query "session-" --namespace cost-trackingshould list the new record.cost-reportstep 1 reads from this namespace.
Record shape (in cost-tracking namespace)
Key: session-<sessionId>. Value (JSON):
{
"sessionId": "1dba3b8c-...",
"cwd": "/Users/cohen/Projects/ruflo",
"startedAt": "2026-05-04T...",
"endedAt": "2026-05-05T...",
"messageCount": 234,
"byModel": {
"claude-opus-4-7": {
"tier": "opus",
"input_tokens": 12345,
"output_tokens": 6789,
"cache_creation_input_tokens": 800000,
"cache_read_input_tokens": 2000000,
"messages": 50,
"cost_usd": 1.23
}
},
"byTier": { "haiku": 0.0, "sonnet": 0.45, "opus": 1.23, "unknown": 0 },
"total_cost_usd": 1.68,
"capturedAt": "2026-05-05T..."
}
Pricing source of truth
The script's PRICING constant mirrors REFERENCE.md "Model pricing (USD per 1M tokens)". Update both together when prices change. Cache-write tokens are billed at cache_write rate; cache-read tokens at cache_read (per Anthropic billing docs).
Env overrides
| Env | Default | Purpose |
|---|---|---|
TRACK_CWD | process.cwd() | Override which project's sessions to scan |
TRACK_SESSION | most-recent jsonl | Pin a specific session file |
TRACK_OUT | unset | Also write the JSON summary to this path |
TRACK_DRY_RUN=1 | unset | Skip the memory store call |
TRACK_QUIET=1 | unset | Suppress markdown output |
TRACK_NAMESPACE | cost-tracking | Override target namespace |
Cross-references
cost-report(consumer) — reads records produced by this skill- REFERENCE.md "Cost attribution formula" — the math the script implements
cost-budget-check(consumer; landing in P2) — reads totals to evaluate alerts
FAQ
What does the cost-track skill do?
Auto-capture per-session token usage from the Claude Code session jsonl and persist to the cost-tracking namespace
How do I install cost-track?
Run npx skills add https://github.com/ruvnet/ruflo --skill cost-track in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/cost-track/ (personal) or .claude/skills/cost-track/ (project).
Which AI agents can use cost-track?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is cost-track safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains cost-track?
It is published by ruvnet in ruvnet/ruflo. It has 684 recorded installs.
More from ruvnet/ruflo
swarm-orchestration
ruvnet/ruflo
Multi-agent swarm coordination for complex tasks. Uses hierarchical topology with specialized agents to break down and execute complex work across multiple files and modules. Use when: 3+ files need changes, new feature implementation, cross-module refactoring, API changes with tests, security-related changes, performance optimization across codebase, database schema changes. Skip when: single file edits, simple bug fixes (1-2 lines), documentation updates, configuration changes, quick exploration.
agent-arch-system-design
ruvnet/ruflo
Agent skill for arch-system-design - invoke with $agent-arch-system-design
agent-workflow
ruvnet/ruflo
Agent skill for workflow - invoke with $agent-workflow
security-audit
ruvnet/ruflo
Comprehensive security scanning and vulnerability detection. Includes input validation, path traversal prevention, CVE detection, and secure coding pattern enforcement. Use when: authentication implementation, authorization logic, payment processing, user data handling, API endpoint creation, file upload handling, database queries, external API integration. Skip when: read-only operations on public data, internal development tooling, static documentation, styling changes.
github-project-management
ruvnet/ruflo
Comprehensive GitHub project management with swarm-coordinated issue tracking, project board automation, and sprint planning
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.