cost-tracking

cost-tracking is a skill for Claude Code, Codex from gongyijie85/dsh-ecc. It costs 54 tokens per session (1,163 once invoked), scanned B, a copy of cost-tracking, MIT.

A reporting tool for Claude Code usage based on its local cost log. It tracks tokens, estimated spending, budgets, models, sessions, and dates.

In plain words
What is it for?
Use it to answer questions about total spending, the cost of a session, token usage, budget overruns, or costs by model and date.
Why use it?
It removes the need to manually calculate usage and avoids counting repeated session snapshots more than once.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: reads .claude/ paths; mentions Claude Code.

Good fit Use it to answer questions about total spending, the cost of a session, token usage, budget overruns, or costs by model and date.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/gongyijie85/dsh-ecc/cost-tracking
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add gongyijie85/dsh-ecc --skill cost-tracking
Clone the repo
git clone --depth 1 https://github.com/gongyijie85/dsh-ecc

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cost-tracking

README.md
[![agentmods](https://agentmods.dev/badge/skills/gongyijie85/dsh-ecc/cost-tracking/github.svg)](https://agentmods.dev/skills/gongyijie85/dsh-ecc/cost-tracking)
Your own site
<a href="https://agentmods.dev/skills/gongyijie85/dsh-ecc/cost-tracking"><img src="https://agentmods.dev/badge/skills/gongyijie85/dsh-ecc/cost-tracking/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cost-tracking

Your own site · 80×15
<a href="https://agentmods.dev/skills/gongyijie85/dsh-ecc/cost-tracking"><img src="https://agentmods.dev/badge/skills/gongyijie85/dsh-ecc/cost-tracking.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,163 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 91% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00054 $0.01163
Opus 5 $0.00027 $0.00581
Sonnet 5 $0.00011 $0.00233
Haiku 4.5 $0.00005 $0.00116

Measured 10d ago against content hash 486b8289ec3f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade B, and why

cost-tracking scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Unrestricted tool accessmediumExcessive agency

A wildcard tool grant or "run any command" leaves no least-privilege boundary at all.

- Do not recommend installing unreviewed hooks or plugins that execute arbitrary code.
Origin

This is a copy

91% identical to cost-tracking — 26 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/cost-tracking/SKILL.md · 98 lines

How it starts

The opening of the file, as written. The whole thing — 98 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cost Tracking

Use this skill to analyze Claude Code cost and usage history from the metrics log that ECC's stop:cost-tracker hook writes.

Where the data lives

The tracker appends one JSON object per session-stop to ~/.claude/metrics/costs.jsonl. Each row is a cumulative snapshot for that session, so to total spend you take the latest row per session_id and sum across sessions — summing every row multiply-counts.

Row schema:

Field Meaning
timestamp ISO timestamp of the snapshot
session_id Claude Code session identifier
transcript_path Path to the session transcript
model Model used
input_tokens / output_tokens Token counts
cache_write_tokens / cache_read_tokens Prompt-cache token counts
estimated_cost_usd Precomputed cumulative cost in USD for the session

Prefer estimated_cost_usd over hand-calculating pricing — model and cache prices change, and the tracker is the source of truth.

When to Use

  • The user asks "how much have I spent?", "what did this session cost?", or "what is my token usage?"
  • The user mentions budgets, spending limits, overruns, or cost controls.
  • The user wants a cost breakdown by model, session, or date, or a CSV export.

How It Works

First verify the log exists (use node, not sqlite3 — the tracker writes JSONL, and node is cross-platform):

node -e 'const fs=require("fs"),os=require("os"),p=require("path");const f=p.join(os.homedir(),".claude","metrics","costs.jsonl");console.log(fs.existsSync(f)?"cost log found":"cost log not found: "+f)'

If the log is missing, do not fabricate usage data. Tell the user that cost tracking populates after the first session ends with the stop:cost-tracker hook enabled.

Example — summary, by model, last 7 days

node -e '
const fs=require("fs"),os=require("os"),path=require("path");
const f=path.join(os.homedir(),".claude","metrics","costs.jsonl");
if(!fs.existsSync(f)){console.log("cost log not found: "+f);process.exit(0);}
const rows=fs.readFileSync(f,"utf8").split(/\r?\n/).filter(Boolean).map(l=>{try{return JSON.parse(l)}catch{return null}}).filter(Boolean);
const bySession=new Map();
for(const r of rows){const k=r.session_id||r.transcript_path||r.timestamp;const p=bySession.get(k);if(!p||String(r.timestamp)>String(p.timestamp))bySession.set(k,r);}
const latest=[...bySession.values()];
const cost=r=>Number(r.estimated_cost_usd)||0, day=r=>String(r.timestamp||"").slice(0,10), sum=a=>a.reduce((s,r)=>s+cost(r),0), f4=n=>"$"+n.toFixed(4);
const today=new Date().toISOString().slice(0,10), yest=new Date(Date.now()-864e5).toISOString().slice(0,10);
console.log("today: "+f4(sum(latest.filter(r=>day(r)===today)))+" | yesterday: "+f4(sum(latest.filter(r=>day(r)===yest)))+" | total: "+f4(sum(latest))+" ("+latest.length+" sessions)");
const m=new Map();for(const r of latest){const k=r.model||"(unknown)";m.set(k,(m.get(k)||0)+cost(r));}
console.log("by model:");[...m.entries()].sort((a,b)=>b[1]-a[1]).forEach(([k,v])=>console.log("  "+f4(v)+"  "+k));
'

Read the full file on GitHub · 98 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 98 lines · 54 tokens per session scan B 486b8289ec3f

Subscribe to this mod's changes

cost-tracking is a skill published in the GitHub repository gongyijie85/dsh-ecc (7 stars, last pushed 2d ago), licensed MIT. It adds 54 tokens to every session and 1,163 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it B with 1 finding (unrestricted tool access). It is 91% identical to cost-tracking, differing in 26 lines, and is treated as a copy.

Related

Other skills, from other repositories

manage-taskboard

Manage work in the native DeepSeek Harness Taskboard with exact task ids and optimistic versions. Use when an Agent must inspect project work, claim an eligible todo, record progress or blockers, verify an implementation, submit it for human review, or release its own claim; also use when a human asks how to accept…

shengsheng90/DSH-taskboard · 88 tokens

dsh-web-pet-developer

Create a pet for the dsh-pet plugin and integrate it into the dsh web GUI — author a v2 pet.json manifest plus an 8-column x 9-row atlas per the Codex/hatch-pet contract (live2d pets, voice packs and status decorations included), drop it into the pet-center user directory or contribute it as a built-in asset under…

zhu1090093659/dsh-web · 162 tokens

dsh-plugin-guide

Use when developing, reviewing, packaging, debugging, or answering questions about DeepSeek Harness (DSH) plugins — the plugin-based agent harness on vendored Cordis. Applies the official plugin-development constraints (plugin contract, cordis.yml layers, services/events/effects, tool DSL, bundles/profiles) backed by…

PerryLink/dsh-plugin-guide · 76 tokens

douyin-works-crawler

A tool that retrieves basic information and recent videos from a Douyin account, using its name or Douyin ID. It can return up to 50 videos with engagement data and links.

redfox-data/redfox-community-dsh · 102 tokens

playlet-douyin-feed

A tool that tracks popular short dramas on Douyin, a Chinese short-video platform, and creates a daily HTML report with covers, engagement data, links, topic groups, and writing observations.

redfox-data/redfox-community-dsh · 264 tokens

playlet-xhs-feed

A daily tracker for popular short-drama posts on Xiaohongshu, a Chinese social-media platform. It groups posts by story themes and creates an HTML report with covers, interaction data, links, and writing insights.

redfox-data/redfox-community-dsh · 184 tokens