Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
ruvnet avatar

Cost Track

  • 590 installs
  • 67k repo stars
  • Updated August 4, 2026
  • ruvnet/ruflo

cost-track is a Ruflo Claude Code skill that reads session jsonl usage, computes USD costs per model, and persists records for developers tracking LLM spend.

About

cost-track is a ruflo-cost-tracker plugin skill in ruvnet/ruflo that auto-captures per-session token usage from the active Claude Code session jsonl at ~/.claude/projects/<encoded-cwd>/<session>.jsonl. It tallies assistant-message usage fields per model—including prompt cache hits—computes USD cost using REFERENCE.md pricing tiers, and writes structured records to the cost-tracking AgentDB namespace via mcp__claude-flow__memory_store. The skill is the producer side for companion skills cost-report, cost-optimize, and cost-budget-check. Install with npx -y skills add ruvnet/ruflo --skill cost-track --agent claude-code and invoke via /cost-track after meaningful work chunks or at session end. Allowed tools include Bash and memory_store. Developers reach for cost-track when Claude Code sessions need measured token totals instead of guessing API bills.

  • cost-track

Cost Track by the numbers

  • 590 all-time installs (skills.sh)
  • +10 installs in the week ending Jul 26, 2026 (Skillselion tracking)
  • Ranked #667 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/ruvnet/ruflo --skill cost-track

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs590
repo stars67k
Last updatedAugust 4, 2026
Repositoryruvnet/ruflo

How do you track Claude Code session token costs?

Use cost-track for development tasks

Who is it for?

Developers running extended Claude Code sessions who need persisted token and USD metrics for reporting and budget checks.

Skip if: Projects without Claude Code session jsonl logs or teams not using the Ruflo cost-tracking namespace ecosystem.

When should I use this skill?

A Claude Code session completes a meaningful work chunk and token spend should be captured for cost-report or budget alerts.

What you get

Structured cost-tracking namespace records with per-model token totals and USD spend breakdown

  • cost-tracking namespace records
  • Per-model USD cost breakdown

By the numbers

  • Persists to the cost-tracking AgentDB namespace consumed by cost-report and cost-optimize
  • Allowed tools: Bash and mcp__claude-flow__memory_store

Files

SKILL.mdMarkdownGitHub ↗

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

1. Run the tracker from the project root:

   node plugins/ruflo-cost-tracker/scripts/track.mjs

The 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.

2. Inspect the markdown summary — total cost, per-model and per-tier breakdowns, and the persisted memory key.

3. Verify persistencemcp__claude-flow__memory_search --query "session-" --namespace cost-tracking should list the new record. cost-report step 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

EnvDefaultPurpose
TRACK_CWDprocess.cwd()Override which project's sessions to scan
TRACK_SESSIONmost-recent jsonlPin a specific session file
TRACK_OUTunsetAlso write the JSON summary to this path
TRACK_DRY_RUN=1unsetSkip the memory store call
TRACK_QUIET=1unsetSuppress markdown output
TRACK_NAMESPACEcost-trackingOverride 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

Related skills

How it compares

Pick cost-track when you need automatic jsonl ingestion into Ruflo's cost-tracking store rather than manual spreadsheet token math.

FAQ

Where does cost-track read session data?

cost-track reads the active Claude Code session jsonl at ~/.claude/projects/<encoded-cwd>/<session>.jsonl, tallying assistant-message usage blocks per model from that file.

What namespace stores cost-track output?

cost-track writes structured usage records to the cost-tracking AgentDB namespace via mcp__claude-flow__memory_store, which cost-report and cost-budget-check skills later query.

When should you run cost-track?

cost-track runs after a meaningful chunk of Claude Code work or at session end to capture spend before cost-report generates USD breakdowns by tier, model, and agent.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.