diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index a4673729..6b91ecc1 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -25,6 +25,10 @@ bunx ccusage pnpm dlx ccusage ``` +```bash [claude x] +BUN_BE_BUN=1 claude x ccusage +``` + ::: This will show your daily usage report by default. diff --git a/docs/guide/index.md b/docs/guide/index.md index 8cf992b6..23eef93f 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -34,7 +34,7 @@ ccusage analyzes the local JSONL files that Claude Code automatically generates ### 🚀 Ultra-Small Bundle Size -Unlike other CLI tools, we pay extreme attention to bundle size. ccusage achieves an incredibly small footprint even without minification, which means you can run it directly without installation using `bunx ccusage` for instant access. +Unlike other CLI tools, we pay extreme attention to bundle size. ccusage achieves an incredibly small footprint even without minification, which means you can run it directly without installation using `bunx ccusage` or `BUN_BE_BUN=1 claude x ccusage` for instant access. ### 📊 Multiple Report Types diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 021aa1c5..b661f7c9 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -33,6 +33,10 @@ pnpm dlx ccusage deno run -E -R=$HOME/.claude/projects/ -S=homedir -N='raw.githubusercontent.com:443' npm:ccusage@latest ``` +```bash [claude x] +BUN_BE_BUN=1 claude x ccusage +``` + ::: ::: tip Speed Recommendation @@ -43,6 +47,33 @@ We strongly recommend using `bunx` instead of `npx` due to the massive speed dif Consider using `deno run` if you want additional security controls. Deno allows you to specify exact permissions, making it safer to run tools you haven't audited. ::: +::: details Running with `claude x` + +If you have the **native version** of Claude Code installed, you can run ccusage directly using the `claude x` command: + +```bash +BUN_BE_BUN=1 claude x ccusage +``` + +**How it works:** + +The native Claude Code binary is built with [Bun's standalone executable](https://bun.sh/docs/bundler/executables) feature. When you set `BUN_BE_BUN=1`, the Claude Code executable exposes the full Bun CLI capabilities instead of running its bundled entry point. This allows you to use `claude x` as a drop-in replacement for `bunx`. + +**Requirements:** + +- **Native Claude Code installation** (installed via `curl -fsSL https://claude.ai/install.sh | bash` or Homebrew/WinGet) +- This does **NOT** work with the npm version (`npm install -g @anthropic-ai/claude-code`) +- Run `claude doctor` to verify whether you have the native version installed + +**Why use this?** + +- No need to install Bun separately +- Uses the same Bun runtime bundled with Claude Code +- Convenient for Claude Code users who want to check their usage without additional tools + +For more details, see the [Bun documentation on BUN_BE_BUN](https://bun.sh/docs/bundler/executables#act-as-the-bun-cli) and [Claude Code setup guide](https://code.claude.com/docs/en/setup). +::: + ### Performance Comparison Here's why runtime choice matters: diff --git a/docs/guide/opencode/index.md b/docs/guide/opencode/index.md index ab74d50d..10ba9551 100644 --- a/docs/guide/opencode/index.md +++ b/docs/guide/opencode/index.md @@ -6,15 +6,30 @@ The `@ccusage/opencode` package reuses ccusage's responsive tables, pricing cach ## Installation & Launch -```bash -# Recommended - always include @latest -npx @ccusage/opencode@latest --help +::: code-group + +```bash [bunx (Recommended)] bunx @ccusage/opencode@latest --help +``` + +```bash [npx] +npx @ccusage/opencode@latest --help +``` -# Alternative package runners +```bash [pnpm] pnpm dlx @ccusage/opencode --help ``` +```bash [opencode x] +BUN_BE_BUN=1 opencode x @ccusage/opencode@latest --help +``` + +::: + +::: tip opencode x option +The `opencode x` option requires the native version of OpenCode. If you installed OpenCode via npm, use the `bunx` or `npx` options instead. +::: + ### Recommended: Shell Alias ```bash diff --git a/docs/guide/statusline.md b/docs/guide/statusline.md index 221aa117..b99ced0a 100644 --- a/docs/guide/statusline.md +++ b/docs/guide/statusline.md @@ -18,16 +18,44 @@ The `statusline` command provides a compact, real-time view of your Claude Code Add this to your `~/.claude/settings.json` or `~/.config/claude/settings.json`: -```json +::: code-group + +```json [bun x (Recommended)] { "statusLine": { "type": "command", - "command": "bun x ccusage statusline", // Use "npx -y ccusage statusline" if you prefer npm - "padding": 0 // Optional: set to 0 to let status line go to edge + "command": "bun x ccusage statusline", + "padding": 0 + } +} +``` + +```json [claude x] +{ + "statusLine": { + "type": "command", + "command": "BUN_BE_BUN=1 claude x ccusage statusline", + "padding": 0 } } ``` +```json [npx] +{ + "statusLine": { + "type": "command", + "command": "npx -y ccusage statusline", + "padding": 0 + } +} +``` + +::: + +::: tip claude x option +The `claude x` option requires the native version of Claude Code (not the npm version). If you installed Claude Code via npm, use the `bun x` or `npx` options instead. +::: + By default, statusline uses **offline mode** with cached pricing data for optimal performance. ### Online Mode (Optional)