cost-track
What it does
This skill reads the log of your current AI coding session and saves a record of its token use and cost. It is for people who want their AI spending tracked over time.
When to use it
- ✓When you finish a big chunk of work and want to record what it cost.
- ✓When you want to save the final total at the end of a session.
- ✓When you want to check spending on a regular schedule during a long session.
Skill link
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-track/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Record how much this session cost so I can see it in my report later.”
5 new skills a week. 1 minute to read.
How it works
The skill finds the active session log, adds up the token use for each model, works out the cost from a price list and saves the totals. You can also run it as a dry run that saves nothing.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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-tracking" })should 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
Where is the session log found?
It looks in your Claude Code folder for the project you are working in, unless you point it to a file.
Can I test it without saving?
Yes. A dry-run setting prints the results without writing anything to memory.
Which report uses this data?
The cost report and cost optimization skills read the records this skill saves.
Details
Original description by the author
Auto-capture per-session token usage from the Claude Code session jsonl and persist to the cost-tracking namespace
repo: ruvnet/ruflo
Popularity
- GitHub stars
- 81k
- Ranking position
- #1611
- License
- MIT
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
agent-adaptive-coordinator
81kHelps your agent split and rebalance a group of AI agents as the workload changes, choosing a layout that fits the task.
agent-agent
81kTeaches your agent to turn a big goal into an ordered plan of actions, and to replan when conditions change.
agent-agentic-payments
81kHelps your agent manage spending mandates for AI shopping, with spend caps, time windows, merchant rules and signed approvals.
agent-analyze-code-quality
81kHelps your agent review code for quality, finding code smells, technical debt and refactoring ideas without changing the files.
Similar skills
blucli
394kHelps your agent find, play, pause, group, and adjust the volume of Bluesound and NAD speakers through the blu command.
camsnap
394kHelps your agent grab snapshots, short clips, or motion events from network cameras and local webcams that you have set up.
eightctl
394kHelps your agent check and control an Eight Sleep pod, including its temperature, alarms, and sleep schedules.