
claude-usage-widget
Claude plan usage limits as a macOS desktop widget (Übersicht) — reads Claude Code's OAuth token, polls /api/oauth/usage, auto-refreshes token
Install with your AI
Paste into Claude Code, Cursor, or any agent — it reads the repo and wires the tool into your project.
Install and set up claude-usage-widget (git-clone project) into my current project. Found on https://claudeers.com/claude-usage-widget-2 Repo: https://github.com/PanithanNanti/claude-usage-widget Homepage/docs: — Detected install method: git-clone → git clone https://github.com/PanithanNanti/claude-usage-widget Category: devops. Platforms: cli, api, desktop. Read the repo's README for exact setup and env vars, then install it and wire it into my project. Claudeers Health Verdict: unknown; community-verified: false. Confirm the source before running anything.
git clone https://github.com/PanithanNanti/claude-usage-widget
Claude Usage — Desktop Widget (macOS / Übersicht)
การ์ดแสดง plan usage limits ของ Claude (session / weekly / per-model) เป็น widget บน desktop ของ Mac อัปเดตอัตโนมัติทุก ~5 นาที มีปุ่ม refresh ทันที, ล็อกเลือกจอ, และล็อกอิน/รีเฟรช token ในตัว
ทำงานได้เพราะดึงผ่าน OAuth endpoint ของ Claude Code (
/api/oauth/usage) โดยตรง — ไม่ผ่านclaude.aiที่ติด Cloudflare จึงยิงจาก background script ได้ (ดู ความรู้เบื้องหลัง)
![แบบ A · การ์ดเต็ม — พื้นเข้ม glassy มุมขวาบน]
✨ ฟีเจอร์
- 🟦 Progress bar ต่อ limit: session / weekly (ทุกโมเดล) / weekly per-model (สีน้ำเงิน → เหลืองเมื่อ ≥80% → แดงเมื่อ ≥95%)
- ⏱️ เวลา reset: session แสดง "รีเซ็ตใน Xh Ym", weekly แสดงวัน+เวลา (เวลาเครื่อง)
- 🏷️ ป้าย plan อัตโนมัติ (Max 20× / Max 5× / Pro …) อ่านจาก credential ของแต่ละคน
- 🖱️ ลากย้ายได้ — จับที่แถบหัวการ์ด จำตำแหน่งไว้ (localStorage)
- 🖥️ รองรับหลายจอ — คลิก "📍 ล็อกจอนี้" เพื่อให้โชว์เฉพาะจอที่เลือก
- 🔄 ปุ่ม Refresh now — ดึงข้อมูลทันทีไม่ต้องรอ 5 นาที
- 🔑 ปุ่มล็อกอิน/รีเฟรช token — เปิด Terminal รัน
claudeเมื่อ session หลุด - 💾 Cache/stale — ถ้า token หมดอายุจะโชว์ค่าเดิม + ไฟเตือน แทนที่จะว่างเปล่า
📦 ความต้องการของระบบ
- macOS (Apple Silicon หรือ Intel)
- Claude Code CLI ติดตั้งและ ล็อกอินอยู่ (widget อ่าน OAuth token ที่มันเก็บ)
- Übersicht (installer ติดตั้งให้ผ่าน Homebrew ได้)
python3(มากับ macOS)
🚀 ติดตั้ง (เครื่องใหม่ / เพื่อนร่วมทีม)
git clone <repo-url> claude-usage-widget
cd claude-usage-widget
bash install-claude-usage-widget.command # หรือดับเบิลคลิกไฟล์นี้ใน Finder
installer จะ:
- เช็ก/ติดตั้ง Übersicht (ผ่าน
brew install --cask ubersicht) - copy
claude-usage.jsxไปโฟลเดอร์ widgets ของ Übersicht พร้อมแก้ path สคริปต์ให้ตรงเครื่องอัตโนมัติ - ดึง usage ครั้งแรก (วอร์ม cache)
- เปิด + รีเฟรช Übersicht
การ์ดจะขึ้นมุมขวาบนของ desktop ภายในไม่กี่วินาที
ครั้งแรกกับหลายจอ: การ์ดจะขึ้นทุกจอ — คลิก "📍 ล็อกจอนี้" บนจอที่ต้องการ จออื่นจะซ่อนเอง (เปลี่ยนใจภายหลังกด "⇄ ย้ายจอ" เพื่อเลือกใหม่)
ถอนการติดตั้ง
bash uninstall-claude-usage-widget.command
🧩 ไฟล์ในโปรเจกต์
| ไฟล์ | หน้าที่ |
|---|---|
claude-usage.sh | ดึง usage ผ่าน OAuth token — โหมด --json (ให้ widget ใช้) และโหมด pretty (ดีบั๊กใน terminal) |
claude-usage.jsx | Übersicht widget (แบบ A การ์ดเต็ม) — เรนเดอร์จาก limits[], ลาก/ล็อกจอ/refresh/login |
install-claude-usage-widget.command | ตัวติดตั้ง (idempotent — รันซ้ำเพื่ออัปเดต widget ได้) |
uninstall-claude-usage-widget.command | ตัวถอน |
CLAUDE.md | บันทึกการทำงาน/ความรู้แบบละเอียด (ภาษาไทย) |
รันสคริปต์ตรงๆ เพื่อทดสอบ:
bash claude-usage.sh # แสดงผลอ่านง่ายใน terminal
bash claude-usage.sh --json # JSON ดิบ (แบบที่ widget ใช้)
🔍 ความรู้เบื้องหลัง (สำคัญ)
ใช้ OAuth endpoint ของ Claude Code — ไม่ใช่ claude.ai
GET https://api.anthropic.com/api/oauth/usage
Authorization: Bearer <ACCESS_TOKEN>
- endpoint นี้คือตัวที่คำสั่ง
/usageใน Claude Code ใช้ → ไม่ติด Cloudflare ยิงจากสคริปต์ได้ - ตรงข้ามกับ
https://claude.ai/api/.../usage(cookiesessionKey) ที่ยิงนอกเบราว์เซอร์แล้วโดน Cloudflare เด้ง (403 / "Just a moment...") — ทางตัน สำหรับ background script
token เก็บที่ไหน (macOS)
Claude Code เก็บ OAuth credential ไว้ที่ Keychain:
- service:
Claude Code-credentials· account:$USER - โครงสร้าง (ห่อด้วย
claudeAiOauth):{ "claudeAiOauth": { "accessToken": "sk-ant-oat01-…", "refreshToken": "…", "expiresAt": 0, "subscriptionType": "max", "rateLimitTier": "default_claude_max_20x" } } - อ่านด้วย:
security find-generic-password -a "$USER" -w -s "Claude Code-credentials" /usr/bin/securityอ่านได้โดย ไม่มี GUI prompt แม้ถูกเรียกจาก Übersicht (ทดสอบด้วยlaunchctl asuser)- บาง setup เก็บเป็นไฟล์
~/.claude/.credentials.jsonแทน (สคริปต์รองรับทั้งสองแบบ) - แกะ token ด้วย
python3(parse JSON) ไม่ใช่sed— blob เป็นบรรทัดเดียวยาว sed พลาดง่าย
โครงสร้าง response (/api/oauth/usage)
five_hour.utilization / .resets_at ← session (0-100 %)
seven_day.utilization / .resets_at ← weekly ทุกโมเดล
limits[] { kind: session|weekly_all|weekly_scoped, percent, severity,
resets_at, scope.model.display_name } ← มี label สวย + per-model
oauth endpoint ก็มี
limits[](ไม่ใช่แค่ฝั่ง claude.ai) — widget เรนเดอร์จากตรงนี้เป็นหลัก
token refresh / session หลุด
- accessToken หมดอายุทุก ~1 ชม. (
expiresAt), refreshToken อายุ ~28 วัน - auto-refresh (built-in): ถ้า accessToken เหลือ <5 นาที สคริปต์จะขอ token ใหม่เองด้วย refreshToken
แล้วเขียนกลับ Keychain — เพราะ widget รันทุก 5 นาที จึงเลี้ยง token ให้สดได้เองยาวๆ โดยไม่ต้องเปิด claude
เขียน Keychain เฉพาะตอน refresh สำเร็จ (ล้มเหลว → credential เดิมไม่ถูกแตะ, fallback เป็น stale)
POST https://platform.claude.com/v1/oauth/token { "grant_type":"refresh_token", "refresh_token":"…", "client_id":"9d1c250a-e61b-44d9-88ed-5944d1962f5e" } # client_id ของ Claude Code - ถ้า refreshToken หมดอายุจริง (นานเป็นเดือนไม่ได้ใช้) → widget โชว์ 🔑 ให้เปิด
claudeล็อกอินใหม่ - แยก HTTP status:
429= rate limit (ชั่วคราว, ไม่ใช่ token หมด) ·401/403= auth
🛠️ ปรับแต่ง
- ตำแหน่ง/ขนาดเริ่มต้น: แก้
.cu-card { top / right / width }ในclaude-usage.jsx(หรือแค่ลากการ์ดเอา แล้วมันจำตำแหน่งให้) - ความถี่รีเฟรช:
refreshFrequency(มิลลิวินาที) ในclaude-usage.jsx - สี threshold: ฟังก์ชัน
barColor()ในclaude-usage.jsx - ป้าย plan: ตรวจอัตโนมัติจาก credential — เพิ่ม mapping ได้ที่
PY_PLANในclaude-usage.sh
❓ แก้ปัญหา
| อาการ | วิธีแก้ |
|---|---|
| การ์ดไม่ขึ้นเลย | คลิกไอคอน Übersicht บนเมนูบาร์ → Refresh All Widgets / เปิด Show widgets on desktop |
| ไม่มีไอคอน Übersicht บนเมนูบาร์ | เปิดแอป Übersicht จาก Launchpad (หรือ brew install --cask ubersicht ใหม่) แล้วรัน installer อีกครั้ง |
| การ์ดโชว์ไฟเหลือง/แดง "token หมดอายุ" | กดปุ่ม 🔑 บนการ์ด (หรือเปิด Terminal พิมพ์ claude เอง) แล้วกด ↻ รีเฟรช |
| โชว์ทุกจอ | คลิก 📍 ล็อกจอนี้ บนจอที่ต้องการ |
| ป้าย plan ไม่ตรง | เพิ่ม mapping tier ที่ PY_PLAN ใน claude-usage.sh |
English (short)
Desktop widget for macOS (Übersicht) showing Claude plan
usage limits. It reads Claude Code's OAuth token from the macOS Keychain
(security … -s "Claude Code-credentials") and calls
GET https://api.anthropic.com/api/oauth/usage — the same endpoint /usage uses, which is not
behind Cloudflare (unlike claude.ai). Features: draggable, per-monitor lock, refresh-now, and
a key button to re-login/refresh the token when the session drops.
Install: bash install-claude-usage-widget.command (handles Übersicht install + path rewrite).
See ความรู้เบื้องหลัง for the reverse-engineering notes.
// compatibility
| Platforms | cli, api, desktop |
|---|---|
| Operating systems | — |
| AI compatibility | claude |
| License | — |
| Pricing | open-source |
| Language | Shell |
// faq
What is claude-usage-widget?
Claude plan usage limits as a macOS desktop widget (Übersicht) — reads Claude Code's OAuth token, polls /api/oauth/usage, auto-refreshes token. It is open-source on GitHub.
Is claude-usage-widget free to use?
claude-usage-widget is open-source, so it is free to use.
What category does claude-usage-widget belong to?
claude-usage-widget is listed under devops in the Claudeers registry of Claude-compatible tools.
// embed badge
[](https://claudeers.com/claude-usage-widget-2)
// retro hit counter
[](https://claudeers.com/claude-usage-widget-2)
// reviews
// guestbook
// related in DevOps & CI/CD
⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI…
Use Claude Code as the foundation for coding infrastructure, allowing you to decide how to interact with the model while enjoying updates from Anthropic.
Professional Antigravity Account Manager & Switcher. One-click seamless account switching for Antigravity Tools. Built with Tauri v2 + React (Rust).专业的 Antig…
Roadmap to becoming an ASP.NET Core developer in 2026