ccusage-cli-cost-tracking
Skill0 starsChanged 5 months agoMITView on GitHub
非公式 ccusage CLI で Claude MAX クォータ消費を daily/weekly/blocks で集計・statusline 連携する設計。発火: token 5h block の残量確認 / 週次の出力 token 集計 / cost-guard hook 設計時 / Opus burn rate 警告
- Installs packages
In this repository99 other files it gives its agents.
- agents-tools-quoted-jsonSkill
- asc-api-app-store-submitSkill
- asd-ste100Skill
- automation-bool-selector-pitfallsSkill
- automation-stale-cooldown-flagSkill
- autonomous-build-verifySkill
- book-to-skillSkill
- chrome-ext-mv3-programmatic-injectSkill
- chrome-ext-store-assetsSkill
- claude-headless-p-invocationSkill
- claude-plugin-context-auditSkill
- claude-session-log-to-kbSkill
- cloudflare-workers-do-deploySkill
- codebase-to-courseSkill
- codesign-keychain-prompt-fixSkill
- codex-cli-setupSkill
- codex-delegation-handoffSkill
- content-factory-grounding-dedupSkill
- conversation-log-append-patternSkill
- cron-to-launchd-macosSkill
- cross-automation-shared-resource-killSkill
- design-token-migration-rnSkill
- discord-bot-image-to-claudeSkill
- discord-gateway-resume-dedupSkill
- excel-filtered-url-http-auditSkill
- execution-budget-vs-capsSkill
- expo-free-local-ios-testflightSkill
- ga4-connect-projectsSkill
- gcal-oauth-desktop-setupSkill
- git-commit-helperSkill
- git-prepush-secret-remote-checkSkill
- gsc-cli-automationSkill
- hatena-blogsync-autopostSkill
- hook-latency-wrapSkill
- hook-log-append-patternSkill
- html-to-pdf-slide-deckSkill
- humanizerSkill
- human-review-gate-shellSkill
- implementation-model-routingSkill
- insights-to-claude-mdSkill
- ios-permission-key-security-matrixSkill
- ios-sim-store-screenshotsSkill
- launchd-exit78-exconfig-debugSkill
- llm-content-pipeline-quality-gateSkill
- local-ai-video-pipelineSkill
- local-flux-mflux-image-genSkill
- local-llm-slow-diagnosisSkill
- local-music-generationSkill
- lottie-skottie-authoring-pitfallsSkill
- machine-wide-api-ratelimit-latchSkill
- macos-hook-path-timeoutSkill
- md-to-docx-reportSkill
- memory-md-inject-bloat-auditSkill
- message-display-secrets-maskSkill
- metric-source-attributionSkill
- migrate-icloud-desktop-assetsSkill
- nextauth-local-e2e-sessionSkill
- nextjs-rsc-payload-slimSkill
- nothing-designSkill
- openclaw-ollama-setupSkill
- The first 60 shown.
The file
Files
Procedure
- インストール:
npm install -g ccusage(Node 20+) - 基本コマンド:
ccusage daily— 当日の input/output/costccusage weekly --json— 週次 JSONccusage blocks --active --json— 現在の 5h block 状態
- statusline 連携 (~/.claude/scripts/statusline.sh):
BLOCK_JSON=$(ccusage blocks --active --json)tokenCounts.outputTokens / projection.remainingMinutes / costUSDを抽出
- キャッシュ戦略: blocks 30s / weekly 5min で statusline 高速化
- cost-guard hook 連携: UserPromptSubmit で閾値超え警告 (500k/800k tokens / $80/hr burn)
Pitfalls
- ccusage は非公式 → MAX plan の cost は API 換算値で実費ではない
- session_id × transcript の重複加算で stop_cost_log と乖離 → ccusage の per-block 値を優先
- node version 不一致で動かない →
command -v ccusageで nvm fallback - weekly 集計は ISO week (月曜起点) なので、Anthropic billing と日付差あり
- block 切り替わり時に projection.remainingMinutes が NaN → null check 必須
Verification
ccusage blocks --active --json | jq '.blocks[0].tokenCounts'で生値確認- statusline で
5h:Nk(cost)表示成功 - cost-guard hook が 800k 超で WARN を stderr に出すこと
See Also
- — transcript JSONL直集計によるセッション後コスト集計(ccusageが使えない環境のフォールバック/事後精算はこちら)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

