stats

stats is a command for coding agents from AR6420/Hail_Hydra. It costs 29 tokens per session (2,171 once invoked), scanned A, original, MIT.

A command that reads Claude Code session logs and reports actual token use, delegation, and savings. Tokens are the text units used to measure AI input and output, and JSONL is a log format with one JSON record per line.

In plain words
What is it for?
It helps inspect token usage, compare model costs, and track how much work was delegated during a Claude Code session.
Why use it?
It removes guesswork from measuring how much a Hydra session used and saved. The figures come from the session log rather than estimates.

Command

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.

agentmods
npx agentmods add commands/ar6420/hail_hydra/stats
Clone the repo
git clone --depth 1 https://github.com/AR6420/Hail_Hydra

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 stats

README.md
[![agentmods](https://agentmods.dev/badge/commands/ar6420/hail_hydra/stats.svg)](https://agentmods.dev/commands/ar6420/hail_hydra/stats)
Your own site
<a href="https://agentmods.dev/commands/ar6420/hail_hydra/stats"><img src="https://agentmods.dev/badge/commands/ar6420/hail_hydra/stats.svg" alt="Measured on agentmods" height="20"></a>
Per session 29 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,171 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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 $0.00029 $0.02171
Opus 5 $0.00015 $0.01086
Sonnet 5 $0.00006 $0.00434
Haiku 4.5 $0.00003 $0.00217

Measured 4d ago against content hash 88ec1e4ba33e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

stats scanned grade A with 0 findings 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 4d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

content/commands/stats.md · 169 lines

How it starts

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

Hydra Stats — Real Token Tracking

Read the active Claude Code session log and compute actual token usage and savings. NO AI estimation — pure JSONL parsing.

Math + JSONL parsing live in the shared helper at ~/.claude/hooks/hydra-token-math.js. Statusline and /hydra:stats both call it so numbers stay consistent.

Pricing (per 1M tokens, verified 2026-08 for Claude 4.x / 5.x)

Tier Input Output Cache read
Haiku $1 $5 10% of input
Sonnet $3 $15 10% of input
Opus $5 $25 10% of input
Fable $10 $50 10% of input

Prices are keyed by tier, not by model ID — Opus 4.6 through Opus 5 all bill at $5/$25, so point releases need no change. Edit the PRICING map in hydra-token-math.js only if Anthropic publishes new prices or ships a new tier.

Fable sits above the Opus baseline, so Fable turns are not counted as delegations and they reduce (never increase) reported savings.

Run

# Strikethrough capability detection — env-heuristic only.
USE_STRIKETHROUGH=0
[ "$TERM_PROGRAM" = "Apple_Terminal" ] && USE_STRIKETHROUGH=1
[ "$TERM_PROGRAM" = "iTerm.app" ]      && USE_STRIKETHROUGH=1
[ "$TERM_PROGRAM" = "vscode" ]         && USE_STRIKETHROUGH=1
[ -n "$KITTY_WINDOW_ID" ]              && USE_STRIKETHROUGH=1
[ "$TERM" = "alacritty" ]              && USE_STRIKETHROUGH=1
[ -n "$WEZTERM_PANE" ]                 && USE_STRIKETHROUGH=1
[ -n "$WT_SESSION" ]                   && USE_STRIKETHROUGH=1
# Known-incompatible terminals (force fallback, overrides green-list)
[ -n "$MSYSTEM" ]                      && USE_STRIKETHROUGH=0
[ -n "$CYGWIN" ]                       && USE_STRIKETHROUGH=0
echo "$TERM" | grep -q "cygwin"        && USE_STRIKETHROUGH=0
# User override
[ "$HYDRA_STRIKETHROUGH" = "0" ] && USE_STRIKETHROUGH=0
[ "$HYDRA_STRIKETHROUGH" = "1" ] && USE_STRIKETHROUGH=1

HYDRA_USE_STRIKETHROUGH="$USE_STRIKETHROUGH" node -e "
const path = require('path');
const os = require('os');
const helperPath = path.join(os.homedir(), '.claude', 'hooks', 'hydra-token-math.js');
let tokenMath;
try {
  tokenMath = require(helperPath);
} catch (e) {
  console.log('hydra-token-math.js not installed at ' + helperPath);
  console.log('Run: hail-hydra-cc  to (re)install Hydra hooks.');
  process.exit(0);
}

const summary = tokenMath.computeSummary();
if (!summary.available) {
  console.log('No session data for this project yet.');
  process.exit(0);
}

const useStrike = process.env.HYDRA_USE_STRIKETHROUGH === '1';
const STRIKE     = useStrike ? '\x1b[9m'  : '';
const STRIKE_OFF = useStrike ? '\x1b[29m' : '';
const GREEN = '\x1b[32m';
const BOLD  = '\x1b[1m';
const DIM   = '\x1b[2m';
const RESET = '\x1b[0m';

function fmt(n) {
  if (n >= 1_000_000) return (n / 1_000_000).toFixed(2) + 'M';
  if (n >= 1_000)     return (n / 1_000).toFixed(1) + 'k';
  return n.toString();
}

const { stats, totalTurns, haikuCost, sonnetCost, opusCost, fableCost,
        actualCost, hypotheticalCost, savedUSD, savedPct,
        delegatedTurns, delegationRate, sessionFile, unknownModels } = summary;

const bar = '━'.repeat(40);

// No-delegation guidance branch — when no Hydra subagents dispatched OR savings below indicator threshold
if (delegatedTurns === 0 || savedUSD < 0.01) {
  console.log('');
  console.log('🐉 Hydra Stats');
  console.log(bar);
  console.log('Session: ' + path.basename(sessionFile));
  console.log('Turns:   ' + totalTurns);
  console.log(bar);
  console.log('');
  console.log('🟣 Opus  (' + stats.opus.turns + ' turns):  ' + fmt(stats.opus.input + stats.opus.cache_create) + ' in / ' + fmt(stats.opus.output) + ' out  → \$' + opusCost.toFixed(3));
  if (stats.fable.turns > 0) {
    console.log('🔴 Fable (' + stats.fable.turns + ' turns):  ' + fmt(stats.fable.input + stats.fable.cache_create) + ' in / ' + fmt(stats.fable.output) + ' out  → \$' + fableCost.toFixed(3));
  }
  console.log(bar);
  console.log('');
  console.log('No Hydra subagent dispatches recorded in this session.');
  console.log('');
  console.log('Hydra works best when invoked explicitly. Try:');
  console.log('  /hydra:guard       — security scan on Haiku');
  console.log('  /hydra:preflight   — environment validation');
  console.log('  /hydra:map         — codebase dependency map');
  console.log('');
  console.log('Or include \"use hydra\" in prompts that involve multi-file');
  console.log('exploration, codebase analysis, or routine verification.');
  console.log(bar);
  if (unknownModels && unknownModels.size > 0) {
    console.log('');
    console.log('⚠️  Unknown models (not counted): ' + Array.from(unknownModels).join(', '));
  }
  process.exit(0);
}

console.log('');
console.log('🐉 Hydra Stats');
console.log(bar);
console.log('Session: ' + path.basename(sessionFile));
console.log('Turns:   ' + totalTurns);
console.log(bar);
console.log('');
console.log('🟢 Haiku  (' + stats.haiku.turns  + ' turns):  ' + fmt(stats.haiku.input  + stats.haiku.cache_create)  + ' in / ' + fmt(stats.haiku.output)  + ' out  → \$' + haikuCost.toFixed(3));
console.log('🔵 Sonnet (' + stats.sonnet.turns + ' turns):  ' + fmt(stats.sonnet.input + stats.sonnet.cache_create) + ' in / ' + fmt(stats.sonnet.output) + ' out  → \$' + sonnetCost.toFixed(3));
console.log('🟣 Opus   (' + stats.opus.turns   + ' turns):  ' + fmt(stats.opus.input   + stats.opus.cache_create)   + ' in / ' + fmt(stats.opus.output)   + ' out  → \$' + opusCost.toFixed(3));
if (stats.fable.turns > 0) {
  console.log('🔴 Fable  (' + stats.fable.turns + ' turns):  ' + fmt(stats.fable.input + stats.fable.cache_create) + ' in / ' + fmt(stats.fable.output) + ' out  → \$' + fableCost.toFixed(3));
}
console.log(bar);
console.log('');
console.log('Delegation rate:    ' + delegationRate.toFixed(1) + '% (' + delegatedTurns + '/' + totalTurns + ' turns)');

if (useStrike) {
  console.log('Was:                ' + DIM + STRIKE + '\$' + hypotheticalCost.toFixed(3) + STRIKE_OFF + RESET);
  console.log('Now:                ' + BOLD + GREEN + '\$' + actualCost.toFixed(3) + RESET);
} else {
  console.log('Actual cost:        \$' + actualCost.toFixed(3));
  console.log('All-Opus baseline:  \$' + hypotheticalCost.toFixed(3));
}
console.log(bar);
console.log('💰 ' + GREEN + 'Saved:           \$' + savedUSD.toFixed(3) + ' (' + savedPct.toFixed(1) + '%)' + RESET);
console.log(bar);
console.log('');
console.log('Reads Claude Code session JSONL directly. No AI estimation.');
if (unknownModels && unknownModels.size > 0) {
  console.log('');
  console.log('⚠️  Unknown models (not counted): ' + Array.from(unknownModels).join(', '));
  console.log('    Update PRICING map in ~/.claude/hooks/hydra-token-math.js');
}
"

Read the full file on GitHub · 169 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. 4d ago First seen · 169 lines · 29 tokens per session scan A 88ec1e4ba33e

Subscribe to this mod's changes

stats is a command published in the GitHub repository AR6420/Hail_Hydra (48 stars, last pushed 23d ago), licensed MIT. It adds 29 tokens to every session and 2,171 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.