← 返回 Skills 市场
cyberash-dev

claude-usage-cli

作者 cyberash-dev · GitHub ↗ · v0.2.0
macos ⚠ suspicious
1216
总下载
0
收藏
3
当前安装
2
版本数
在 OpenClaw 中安装
/install 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.
使用说明 (SKILL.md)

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

Flag Description Default
--from \x3Cdate> Start date (YYYY-MM-DD or ISO) 7 days ago
--to \x3Cdate> End date (YYYY-MM-DD or ISO) now
--period \x3Cdays> Shorthand period (7d, 30d, 90d) 7d
--model \x3Cmodels> Filter by model(s), comma-separated all
--api-keys \x3Cids> Filter by API key ID(s), comma-separated all
--group-by \x3Cfields> Group by model, api_key_id, workspace_id, service_tier model
--bucket \x3Cwidth> Bucket width: 1d, 1h, 1m 1d
--json Output as JSON false

cost

Flag Description Default
--from \x3Cdate> Start date (YYYY-MM-DD or ISO) 7 days ago
--to \x3Cdate> End date (YYYY-MM-DD or ISO) now
--period \x3Cdays> Shorthand period (7d, 30d, 90d) 7d
--group-by \x3Cfields> Group by workspace_id, description description
--sum Output total cost only false
--json Output as JSON false

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

安全使用建议
Before installing: 1) Confirm the npm package and GitHub repository are legitimate (owner, recent commits, stars, issues) and inspect the CLI source — SKILL.md's claims about Keychain and network scope can only be validated by reading code. 2) Do not paste a high-privilege Admin key unless necessary — prefer a least-privilege/read-only token or an account that limits blast radius. 3) Verify the npm package tarball (npm view / integrity) or build from source (git clone) if you want to audit before executing. 4) Check that the CLI actually only connects to api.anthropic.com (monitor network activity on first run). 5) If you have low tolerance for risk, prefer alternatives with published source and active maintenance (SKILL.md even marks this skill DEPRECATED).
功能分析
Type: OpenClaw Skill Name: claude-usage-cli Version: 0.2.0 The skill instructs the agent to install an external Node.js package (`claude-usage-cli`) via `npm install -g`. While the `SKILL.md` provides a public GitHub link for the source code and makes strong claims about security (macOS Keychain storage, no plaintext storage, only connects to `api.anthropic.com`, read-only API key scope), the act of installing an external package from npm introduces a supply chain risk. The installed package, which handles sensitive Anthropic Admin API keys and makes network requests, could potentially deviate from its stated benign purpose or be compromised, leading to unauthorized data access or exfiltration, despite the `SKILL.md`'s claims. This constitutes a risky capability without clear malicious intent in the `SKILL.md` itself, thus classifying it as suspicious.
能力评估
Purpose & Capability
The SKILL.md clearly requires an Anthropic Admin API key (sk-ant-admin...) and describes storing it in macOS Keychain, but the registry metadata lists no required environment variables or primary credential. Requiring the 'claude-usage' and 'node' binaries is consistent with a CLI wrapper, however the omission of the Admin API credential in the skill metadata is an inconsistency that reduces transparency.
Instruction Scope
The runtime instructions are limited to installing/running a CLI (claude-usage) and using Keychain to store an Admin API key; they do not ask the agent to read arbitrary files or system state. However, the SKILL.md makes concrete claims about network scope (only contacting api.anthropic.com over HTTPS) and key handling (never written to disk in plaintext) that cannot be verified from an instruction-only skill with no code. Because the skill delegates behavior to an external binary, those claims should be validated by inspecting the CLI's code or package.
Install Mechanism
SKILL.md recommends installing via npm (npm install -g claude-usage-cli) or git-clone/build. npm/global install is a common but moderately risky install vector because it executes third-party code from the registry; the SKILL.md references a GitHub repo which is a good sign, but the registry metadata reported 'No install spec' — the presence of install instructions inside SKILL.md but not in the top-level install spec is an inconsistency to confirm. Verify the npm package and GitHub source before installing.
Credentials
The tool requires an Admin API key to query organization usage/costs. Admin keys can be sensitive/powerful; the skill metadata does not declare any required credential or primaryEnv, which is misleading. The SKILL.md asserts read-only scope for that key, but you should treat an Admin key as a high-privilege secret and prefer least-privilege tokens if available.
Persistence & Privilege
The skill is not force-included (always:false) and does not request persistent system-wide privileges. It stores the API key in the user's macOS Keychain (as documented) and claims not to write plaintext to disk. There is no evidence in the provided files that the skill modifies other skills or system settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install claude-usage-cli
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /claude-usage-cli 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.2.0
DEPRECATED: Use claude-cost-cli instead. This skill is no longer maintained.
v0.1.0
Initial release of claude-usage-cli — a CLI for querying Claude API usage and cost reports: - Securely stores Anthropic Admin API keys in macOS Keychain. - Supports usage and cost reporting with table or JSON output. - Offers report filtering by date range, model, API key, grouping, and summary. - No sensitive data is written to disk; all data is read-only from the Admin API. - Requires Node.js (>=18) and macOS. Install via npm or from source.
元数据
Slug claude-usage-cli
版本 0.2.0
许可证
累计安装 3
当前安装数 3
历史版本数 2
常见问题

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. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1216 次。

如何安装 claude-usage-cli?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install claude-usage-cli」即可一键安装,无需额外配置。

claude-usage-cli 是免费的吗?

是的,claude-usage-cli 完全免费(开源免费),可自由下载、安装和使用。

claude-usage-cli 支持哪些平台?

claude-usage-cli 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(macos)。

谁开发了 claude-usage-cli?

由 cyberash-dev(@cyberash-dev)开发并维护,当前版本 v0.2.0。

💬 留言讨论