claude-usage-cliQuery Claude API usage and cost reports from the command line. Secure macOS Keychain storage for Admin API key. Table/JSON output.
Install via ClawdBot CLI:
clawdbot install cyberash-dev/claude-usage-cliInstall claude-usage-cli via npm:
Install claude-usage-cli via npmRequires:
ā ļø DEPRECATED ā This skill is no longer maintained. Please use claude-cost-cli instead, which provides the same functionality with active support.
A CLI for querying Anthropic Admin API usage and cost data. Requires an Admin API key (sk-ant-admin...) from Claude Console ā Settings ā Admin Keys. Credentials are stored in macOS Keychain.
Requires Node.js >= 18 and macOS. The package is open source: https://github.com/cyberash-dev/claude-usage-cli
npm install -g claude-usage-cli
Install from source (if you prefer to audit the code before running):
git clone https://github.com/cyberash-dev/claude-usage-cli.git
cd claude-usage-cli
npm install && npm run build && npm link
After installation the claude-usage command is available globally.
claude-usage config set-key # Interactive prompt: enter Admin API key (masked)
claude-usage usage # Token usage for the last 7 days
claude-usage cost # Cost breakdown for the last 7 days
claude-usage cost --sum # Total spend for the last 7 days
Store API key (interactive masked prompt, validates sk-ant-admin prefix):
claude-usage config set-key
Show stored key (masked):
claude-usage config show
Remove key from Keychain:
claude-usage config remove-key
claude-usage usage # Last 7 days, daily, grouped by model
claude-usage usage --period 30d # Last 30 days
claude-usage usage --from 2026-01-01 --to 2026-01-31 # Custom date range
claude-usage usage --model claude-sonnet-4 # Filter by model
claude-usage usage --api-keys apikey_01Rj,apikey_02Xz # Filter by API key IDs
claude-usage usage --group-by model,api_key_id # Group by multiple dimensions
claude-usage usage --bucket 1h # Hourly granularity (1d, 1h, 1m)
JSON output (for scripting):
claude-usage usage --json
claude-usage usage --period 30d --json
Output columns: Date, Model, Input Tokens, Cached Tokens, Output Tokens, Web Searches.
claude-usage cost # Last 7 days, grouped by description
claude-usage cost --period 30d # Last 30 days
claude-usage cost --from 2026-01-01 --to 2026-01-31 # Custom date range
claude-usage cost --group-by workspace_id,description # Group by workspace and description
claude-usage cost --sum # Total cost only
JSON output (for scripting):
claude-usage cost --json
claude-usage cost --sum --json
Output columns: Date, Description, Model, Amount (USD), Token Type, Tier.
usage| Flag | Description | Default |
|------|-------------|---------|
| --from | Start date (YYYY-MM-DD or ISO) | 7 days ago |
| --to | End date (YYYY-MM-DD or ISO) | now |
| --period | Shorthand period (7d, 30d, 90d) | 7d |
| --model | Filter by model(s), comma-separated | all |
| --api-keys | Filter by API key ID(s), comma-separated | all |
| --group-by | Group by model, api_key_id, workspace_id, service_tier | model |
| --bucket | Bucket width: 1d, 1h, 1m | 1d |
| --json | Output as JSON | false |
cost| Flag | Description | Default |
|------|-------------|---------|
| --from | Start date (YYYY-MM-DD or ISO) | 7 days ago |
| --to | End date (YYYY-MM-DD or ISO) | now |
| --period | Shorthand period (7d, 30d, 90d) | 7d |
| --group-by | Group by workspace_id, description | description |
| --sum | Output total cost only | false |
| --json | Output as JSON | false |
claude-usage-cli). Never written to disk in plaintext.api.anthropic.com over HTTPS. No other outbound connections are made.This CLI wraps the Anthropic Admin API:
GET /v1/organizations/usage_report/messagesGET /v1/organizations/cost_reportDocumentation: https://platform.claude.com/docs/en/build-with-claude/usage-cost-api
Generated Feb 23, 2026
A freelance developer uses this CLI to monitor API usage and costs across multiple client projects, ensuring they stay within budget and can invoice accurately. They filter by API key IDs to separate client expenses and generate JSON reports for documentation.
A startup building a SaaS product with Claude integration uses this tool to track daily token consumption and cost trends, optimizing model selection and usage patterns to control operational expenses. They group by model and workspace to analyze performance across different features.
An enterprise IT team employs this CLI to audit Claude API usage across departments, verifying compliance with internal policies and identifying cost-saving opportunities. They use custom date ranges and group-by options to generate detailed reports for management review.
Researchers at a university use this tool to monitor API costs for a large-scale AI research project, ensuring grant funds are allocated efficiently. They rely on the secure Keychain storage to protect the Admin API key while generating usage reports for funding reports.
A consulting firm offers AI cost optimization services, using this CLI to analyze client usage data and provide recommendations for reducing API expenses. They charge a monthly retainer or project-based fee for delivering actionable insights and reports.
A managed service provider integrates this tool into their platform to monitor and report on Claude API usage for clients, offering proactive cost management and alerting. Revenue is generated through subscription plans based on the number of monitored accounts or usage volume.
A training company develops workshops on AI cost management, using this CLI as a hands-on tool to teach participants how to track and optimize API expenses. Revenue comes from course fees, corporate training contracts, and selling supplementary materials.
š¬ Integration Tip
Integrate this CLI into automated scripts using the --json flag for programmatic cost tracking, and ensure the Admin API key is securely stored in macOS Keychain to maintain compliance with data security standards.
Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
Command-line tool to manage Google Workspace services including Gmail, Calendar, Drive, Sheets, Docs, Slides, Contacts, Tasks, People, Groups, and Keep.
Runs shell commands inside a dedicated tmux session named claw, captures, and returns the output, with safety checks for destructive commands.
A modern text-based browser. Renders web pages in the terminal using headless Firefox.
Write robust, portable shell scripts. Use when parsing arguments, handling errors properly, writing POSIX-compatible scripts, managing temp files, running commands in parallel, managing background processes, or adding --help to scripts.
NotebookLM CLI wrapper via `node {baseDir}/scripts/notebooklm.mjs`. Use for auth, notebooks, chat, sources, notes, sharing, research, and artifact generation/download.