본문으로 건너뛰기
cccskills
무료GitHub에 공개

claude-usage

Report ground-truth Claude token consumption and estimated cost by parsing JSONL session files directly. Use when checking API spend, auditing token usage by project/session/model, generating daily/weekly/monthly cost reports, or diagnosing ccusage undercounting. Includes subagent files that ccusage ignores.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Playwright
설치 방법 보기

포함된 파일(4)

  • SKILL.md7.1 KB
  • README.md10.7 KB
  • scripts/claude_usage_report.py28.6 KB
  • scripts/claude_usage.py36.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Claude Usage

Ground-truth token usage and cost reporting for Claude Code sessions. Parses JSONL files directly—parent sessions and subagent sidechains—to produce accurate numbers.

Why This Exists

ccusage (v18+, the standard community tool with 10.6k stars) undercounts output tokens by 77-94% for heavy users:

SourceOutput TokensNotes
Raw JSONL (all files)1,076,691Ground truth
Raw JSONL (date-filtered)412,987Properly filtered
ccusage --timezone UTC93,96077% undercount
ccusage default62,37594% undercount

Three compounding bugs:

  1. Ignores subagent files at {session-uuid}/subagents/{agent-id}.jsonl—132 files missed on a typical day with Agent Teams
  2. Timezone confusion between UTC entry timestamps and local time filtering
  3. Drops entries in parent files—even at UTC, reports only 23% of actual tokens

This script reads every JSONL file to produce correct totals.


Usage

# Today's usage (default)
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py

# Last 7 days, broken down by day
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --since 7d

# Weekly breakdown for the past month
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --by week --since 30d

# Per-model breakdown
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --by model --since 7d

# Per-session with human-readable summaries
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --by session --since 1d

# Per-project breakdown
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --by project --since 7d

# Filter to one project
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --project Thera --since 30d

# Custom date range
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --since 2026-02-01 --until 2026-02-28

# JSON output (pipe to jq)
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --since 7d --json | jq '.grand_total'

# CSV output
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --since 7d --csv

# Compare against ccusage (shows delta)
python3 ~/.claude/skills/claude-usage/scripts/claude_usage.py --compare

# PDF report (dark editorial, CTO-ready)
python3 ~/.claude/skills/claude-usage/scripts/claude_usage_report.py --since 30d

# PDF with custom output path
python3 ~/.claude/skills/claude-usage/scripts/claude_usage_report.py --since 30d -o ~/Desktop/feb-usage.pdf

# HTML only (no Playwright needed)
python3 ~/.claude/skills/claude-usage/scripts/claude_usage_report.py --since 7d --html

Output Columns

ColumnDescription
InputPrompt tokens (charged at input rate)
OutputResponse tokens (most expensive category)
CacheWCache write tokens (cache_creation_input_tokens)
CacheRCache read tokens (significantly cheaper than input)
TotalSum of all four token types
CostEstimated USD from the hardcoded pricing table

Aggregation Modes (--by)

ModeGroups byExample key
day (default)Calendar date in local timezone2026-02-20
weekISO week number2026-W08
monthMonth2026-02
sessionSession UUID (resolved to summary from sessions-index.json)8a6c801a Working on Claudicle...
modelModel nameclaude-opus-4-6
projectProject directory (decoded to path)~/Desktop/Programming

Pricing Table

Prices are hardcoded in the PRICING dict at the top of claude_usage.py. Update when Anthropic changes rates. Keys are model name substrings matched most-specific-first.

Current defaults (USD per million tokens, verified 2026-02-21):

ModelInputOutputCache Write (1h)Cache Read
Opus 4.5 / 4.6$5.00$25.00$10.00$0.50
Opus 4.0 / 4.1$15.00$75.00$30.00$1.50
Sonnet 4.x$3.00$15.00$6.00$0.30
Haiku 4.5$1.00$5.00$2.00$0.10
Sonnet 3.7 / 3.5$3.00$15.00$6.00$0.30
Haiku 3.5$0.80$4.00$1.60$0.08
Opus 3$15.00$75.00$30.00$1.50
Haiku 3$0.25$1.25$0.50$0.03

Cache write column shows the 1-hour rate (2x base input). Claude Code uses 1-hour prompt caching exclusively. The 5-minute rate (1.25x base input) is also supported when the JSONL cache_creation sub-object provides a TTL split.


Timezone Handling

JSONL timestamps are UTC. The script converts to the system's local timezone (or --tz America/New_York) before applying --since/--until filters. This prevents the midnight-boundary confusion that causes ccusage to drop entries when the UTC date differs from the local date.


Data Sources

JSONL files at ~/.claude/projects/{encoded-path}/:

  • Parent sessions: {session-uuid}.jsonl
  • Subagent sidechains: {session-uuid}/subagents/{agent-id}.jsonl
  • Session metadata: sessions-index.json (summaries for --by session)

The script uses streaming line-by-line reads (O(1) memory) to handle files exceeding 300MB.


PDF Reports

claude_usage_report.py generates a dark editorial PDF with Crimson Pro + JetBrains Mono typography, gold Minoan accents, bar charts, model distribution with color-coded stacked bars, token composition breakdown, and detailed tables. Designed for executive sharing.

Requires Playwright (uv pip install --system playwright && playwright install chromium). Uses Chromium for pixel-perfect CSS rendering—same engine as the Aldea Slide Deck skill. Falls back to HTML output with --html flag.


Caveats

  • Estimated accuracy: ~95%. The remaining gap comes from data residency multipliers (1.1x for US-only inference, not tracked) and potential edge cases in streaming chunk boundaries.
  • Streaming chunks are deduplicated by message ID using last-wins strategy—output_tokens monotonically increases across chunks, so only the final chunk per message ID has the correct value. Without dedup, costs were overcounted by 2-5x.
  • Cost is estimated from the pricing table. Anthropic billing may differ due to batch discounts or promotional pricing.
  • Cache write pricing uses the 1-hour rate by default (Claude Code's caching mode). When JSONL provides cache_creation.ephemeral_5m_input_tokens / ephemeral_1h_input_tokens, rates are split accordingly.
  • Synthetic entries (model: "<synthetic>") and billing error entries (all-zero token counts) are automatically filtered.
  • Malformed JSON lines and duplicate streaming chunks are counted and reported in the output footer.
  • Requires Python 3.9+ for zoneinfo module.
  • PDF reports require Playwright with Chromium (playwright install chromium). Includes a Pricing Methodology section with full rate table, formula, and confidence badge.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Search academic papers, build literature reviews, and synthesize research findings — combines Exa search (publication category, domain and date filters) with arxiv-mcp-server for paper discovery, download, and deep analysis. Triggers on academic paper, literature review, research synthesis, arxiv, find papers, scholarly search.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

tdimino/claude-code-minoan412026년 10월 20일 업데이트

Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

tdimino/claude-code-minoan412026년 10월 20일 업데이트

This skill should be used when creating, auditing, or maintaining AGENTS.md files and Codex CLI configuration for any project—including initializing AGENTS.md for cross-agent compatibility (Codex, Cursor, Copilot, Devin, Jules, Amp, Gemini CLI), generating config.toml or .rules files, scaffolding .agents/skills/, converting CLAUDE.md to AGENTS.md, or auditing existing agent configs for bloat and staleness. Complementary to codex-orchestrator (which executes subagents; this skill creates the config files they consume).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

tdimino/claude-code-minoan412026년 10월 20일 업데이트

Academic research skill for Biblical Hebrew, Semitic linguistics, cuneiform studies, and comparative Ancient Near Eastern research. Provides Sefaria API for Hebrew Bible, CDLI/ORACC for cuneiform databases, and web discovery via Omnisearch, Exa, Firecrawl, and Obscura for finding scholarly sources across JSTOR, Perseus, Persée, Google Scholar, and academia.edu. Triggers on Hebrew quotes, cuneiform, Sefaria, ANE research, Minoan, search for scholarship, find papers, literature review, scholarly search, academic search, Genesis/Tehom, Ugaritic, Talmudic sources, extract from PDF, OCR academic.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

tdimino/claude-code-minoan412026년 10월 20일 업데이트

Build comprehensive ARCHITECTURE.md files following matklad's canonical guidelines — bird's-eye views, ASCII/Mermaid diagrams, codemaps, invariants, and layer boundaries. Triggers on document the architecture, create ARCHITECTURE.md, map this codebase, architectural overview.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

tdimino/claude-code-minoan412026년 10월 20일 업데이트

Generate physically-based atmospheric scattering shaders — sky domes, planetary atmospheres, LUT-optimized pipelines, depth-aware post-processing. Four modes — sky-dome, atmosphere-post, planet, lut. Triggers on atmospheric scattering, sky shader, sunset rendering, planet atmosphere, Rayleigh scattering, Mie scattering, volumetric sky, sky dome, atmosphere post-processing, aerial perspective, transmittance LUT, sky rendering, realistic sky, planetary rendering.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

tdimino/claude-code-minoan412026년 10월 20일 업데이트

tdimino의 스킬 모두 보기

이 스킬의 문제 신고