claude-usage

TotalClaw 作者 totalclaw

检查克劳德代码/克劳德最大使用限制。当用户询问使用情况、限制、配额或剩余多少 Claude 容量时运行。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~aligurelli-claude-usage-checker
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~aligurelli-claude-usage-checker/file -o aligurelli-claude-usage-checker.md
# Claude Usage Checker

Launches the Claude CLI interactively (PTY) and reads the `/usage` output to report your Claude Code / Claude Max quota.

## Prerequisites
- **Claude CLI** must be installed (`npm i -g @anthropic-ai/claude-code`) and logged in
- If running `claude` shows "Missing API key", the user must log in manually first: open a terminal, run `claude`, and complete the browser login flow
- Requires an interactive PTY — the agent will launch a local process and read its output (quota info only)

## Steps

1. Launch `claude` with PTY
2. Wait for the welcome screen (poll until it appears)
3. Send `/usage` + Enter
4. Read the output (poll until usage data appears)
5. Close with Escape then `/exit`
6. Report the results

## Commands

```bash
# Launch claude with PTY
exec pty=true command="claude"

# Wait and check log
process action=poll sessionId=XXX timeout=5000

# Send /usage
process action=send-keys sessionId=XXX literal="/usage"
process action=send-keys sessionId=XXX keys=["Enter"]

# Read output
process action=poll sessionId=XXX timeout=5000

# Exit
process action=send-keys sessionId=XXX keys=["Escape"]
process action=send-keys sessionId=XXX literal="/exit"
process action=send-keys sessionId=XXX keys=["Enter"]
```

## Notes
- If you see "Missing API key" → tell the user to log in; browser-based login won't work headlessly
- Allow a few seconds between polls — Claude CLI starts slowly
- "Current week" = weekly reset, not daily

## Output Format

Report in a table:

| | Usage | Resets |
|---|---|---|
| **Current session** | X% used | today at HH:MM (timezone) |
| **Weekly (all models)** | X% used | HH:MM (timezone) |
| **Weekly (Sonnet only)** | X% used | HH:MM (timezone) |
| **Extra usage** | X% used / $X of $Y spent | date (timezone) |

Always show reset times. The CLI displays them as "Resets Xpm" — convert to HH:MM format.

---

## 中文说明

# Claude Usage Checker

以交互方式(PTY)启动 Claude CLI,读取 `/usage` 的输出,以报告你的 Claude Code / Claude Max 配额。

## 前提条件
- 必须已安装 **Claude CLI**(`npm i -g @anthropic-ai/claude-code`)并已登录
- 如果运行 `claude` 显示 "Missing API key",用户必须先手动登录:打开终端,运行 `claude`,并完成浏览器登录流程
- 需要交互式 PTY——代理将启动一个本地进程并读取其输出(仅限配额信息)

## 步骤

1. 以 PTY 启动 `claude`
2. 等待欢迎界面(轮询直到出现)
3. 发送 `/usage` + Enter
4. 读取输出(轮询直到出现使用数据)
5. 用 Escape 然后 `/exit` 关闭
6. 报告结果

## 命令

```bash
# Launch claude with PTY
exec pty=true command="claude"

# Wait and check log
process action=poll sessionId=XXX timeout=5000

# Send /usage
process action=send-keys sessionId=XXX literal="/usage"
process action=send-keys sessionId=XXX keys=["Enter"]

# Read output
process action=poll sessionId=XXX timeout=5000

# Exit
process action=send-keys sessionId=XXX keys=["Escape"]
process action=send-keys sessionId=XXX literal="/exit"
process action=send-keys sessionId=XXX keys=["Enter"]
```

## 注意事项
- 如果看到 "Missing API key" → 告知用户去登录;基于浏览器的登录无法在无界面环境下工作
- 在每次轮询之间留出几秒——Claude CLI 启动较慢
- "Current week"(本周)= 每周重置,而非每日重置

## 输出格式

以表格形式报告:

| | Usage | Resets |
|---|---|---|
| **Current session** | X% used | today at HH:MM (timezone) |
| **Weekly (all models)** | X% used | HH:MM (timezone) |
| **Weekly (Sonnet only)** | X% used | HH:MM (timezone) |
| **Extra usage** | X% used / $X of $Y spent | date (timezone) |

始终显示重置时间。CLI 将其显示为 "Resets Xpm"——请转换为 HH:MM 格式。