claude-usage-cli

Query Claude API usage and cost reports from the command line. Secure macOS Keychain storage for Admin API key. Table/JSON output.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "claude-usage-cli" with this command: npx skills add cyberash-dev/claude-usage-cli

claude-usage-cli

⚠️ 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.

Installation

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.

Quick Start

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

API Key Management

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

Usage Reports

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.

Cost Reports

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.

Flag Reference

usage

FlagDescriptionDefault
--from <date>Start date (YYYY-MM-DD or ISO)7 days ago
--to <date>End date (YYYY-MM-DD or ISO)now
--period <days>Shorthand period (7d, 30d, 90d)7d
--model <models>Filter by model(s), comma-separatedall
--api-keys <ids>Filter by API key ID(s), comma-separatedall
--group-by <fields>Group by model, api_key_id, workspace_id, service_tiermodel
--bucket <width>Bucket width: 1d, 1h, 1m1d
--jsonOutput as JSONfalse

cost

FlagDescriptionDefault
--from <date>Start date (YYYY-MM-DD or ISO)7 days ago
--to <date>End date (YYYY-MM-DD or ISO)now
--period <days>Shorthand period (7d, 30d, 90d)7d
--group-by <fields>Group by workspace_id, descriptiondescription
--sumOutput total cost onlyfalse
--jsonOutput as JSONfalse

Security and Data Storage

  • Admin API key: stored exclusively in macOS Keychain (service: claude-usage-cli). Never written to disk in plaintext.
  • No config files: all settings are passed via CLI flags. Nothing is stored on disk besides the Keychain entry.
  • Network: the API key is only sent to api.anthropic.com over HTTPS. No other outbound connections are made.
  • Scope: the Admin API key grants read-only access to organization usage and cost data. It cannot modify billing, create API keys, or access conversation content.
  • No caching: query results are not cached or persisted to disk.

API Reference

This CLI wraps the Anthropic Admin API:

  • Usage: GET /v1/organizations/usage_report/messages
  • Cost: GET /v1/organizations/cost_report

Documentation: https://platform.claude.com/docs/en/build-with-claude/usage-cost-api

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Web3

founder-playbook-web3

Decision validation and thinking frameworks for startup founders. Use when you need to pressure-test a decision, validate your next steps, think through stra...

Registry SourceRecently Updated
1160Profile unavailable
Web3

SignaAI — Agent-to-Agent Payments

Send payments, messages, escrow, and verifiable outputs between AI agents on the Signum blockchain. Use when asked about agent-to-agent payments, on-chain me...

Registry SourceRecently Updated
330Profile unavailable
Web3

Freelance Autobot

Autonomous freelance hunter — finds gigs on FreeLanceDAO and CryptoGigs, scores them for fit, and auto-submits proposals. Also builds your CryptoGig profile...

Registry SourceRecently Updated
460Profile unavailable
Web3

erc-8004-development

Build with ERC-8004 Trustless Agents - on-chain agent identity, reputation, validation, and discovery on EVM chains. Use when registering AI agents on-chain,...

Registry SourceRecently Updated
1170Profile unavailable