Skip to main content
The Claude provider tracks usage for Anthropic’s Claude coding assistant, supporting multiple authentication methods with automatic fallback.

Features

  • Session (5-hour) and weekly rate limit tracking
  • Model-specific windows (Sonnet, Opus, Haiku)
  • Extra usage cost tracking (monthly spend/limit)
  • Local token cost analysis from project logs
  • Multi-account support via manual tokens
  • Status page integration with Anthropic incidents

Authentication Methods

Claude supports three primary authentication methods with automatic fallback:

Data Source Selection

Default Selection (Debug Menu Disabled)

  1. OAuth API - If Claude CLI credentials include user:profile scope
  2. CLI PTY - If OAuth is unavailable or fails
  3. Web API - If OAuth and CLI are unavailable or fail

Manual Override

Preferences → Providers → Claude → Usage source:
  • Auto - Uses the default selection above
  • OAuth - Forces OAuth API only
  • Web - Forces Web API with cookies
  • CLI - Forces CLI PTY only

Local Cost Usage

CodexBar scans local project logs to compute token costs: Source roots:
  • $CLAUDE_CONFIG_DIR (comma-separated paths, each uses <root>/projects)
  • Fallback roots:
    • ~/.config/claude/projects
    • ~/.claude/projects
Files:
  • **/*.jsonl under project roots
Parsing:
  • Lines with type: "assistant" and message.usage
  • Per-model token counts (input, cache read/create, output)
  • Deduplicates streaming chunks by message.id + requestId
Cache:
  • ~/Library/Caches/CodexBar/cost-usage/claude-v1.json
  • Window: last 30 days (rolling), 60s minimum refresh interval
View cost summary:
  1. Settings → General → Show cost summary
  2. Menu shows “Cost (30d): $X.XX” below usage meters

Multi-Account Support

CodexBar supports multiple Claude accounts via manual tokens: Setup:
  1. Edit ~/.codexbar/config.json:
{
  "tokenAccounts": [
    {
      "name": "Work",
      "token": "sessionKey=sk-ant-..."
    },
    {
      "name": "Personal",
      "token": "sk-ant-oat..."
    }
  ]
}
  1. Preferences → Providers → Claude → Cookie source: Manual
  2. Preferences → Advanced → Display: choose “Stacked” or “Switcher”
Display modes:
  • Stacked - Shows all accounts in the menu
  • Switcher - Shows one account at a time with a switcher bar

Status Page Integration

CodexBar monitors Anthropic Status for incidents:
  • Polls Statuspage.io API every 5 minutes (configurable)
  • Displays incident badge on menu bar icon
  • Shows incident details in menu
  • Click “View Status” to open status page

Troubleshooting

Claude CLI tokens with only user:inference scope cannot call the usage API.Solution:
  1. Re-authenticate: claude auth logout && claude auth login
  2. Ensure the new token includes user:profile scope
  3. Or use Web API with browser cookies instead
Browser session keys expire periodically.Solution:
  1. Visit https://claude.ai in your browser
  2. Log out and log back in
  3. Return to CodexBar and click “Refresh”
  4. CodexBar will import fresh cookies automatically
The Claude CLI status output may change formats.Solution:
  1. Try OAuth API or Web API instead
  2. Preferences → Providers → Claude → Usage source: OAuth or Web
  3. Report the issue with CLI output attached
Claude OAuth credentials stored in Keychain may trigger prompts.Solution:
  1. Open Keychain Access.app
  2. Search for “Claude Code-credentials”
  3. Open the item → Access Control
  4. Add CodexBar.app to “Always allow access by these applications”
  5. Or adjust Keychain prompt policy in Settings → Providers → Claude
Cost summary requires local Claude project logs.Solution:
  1. Verify Claude projects exist: ls ~/.config/claude/projects or ls ~/.claude/projects
  2. Ensure Claude CLI has been used recently (logs from last 30 days)
  3. Enable cost summary: Settings → General → Show cost summary

CLI Usage

# Show Claude usage
codexbar --provider claude
codexbar -p claude

# Force specific source
codexbar -p claude --source oauth
codexbar -p claude --source web
codexbar -p claude --source cli

# Show cost summary
codexbar cost --provider claude

Key Files

  • OAuth: Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/*
  • Web API: Sources/CodexBarCore/Providers/Claude/ClaudeWeb/ClaudeWebAPIFetcher.swift
  • CLI PTY: Sources/CodexBarCore/Providers/Claude/ClaudeStatusProbe.swift, Sources/CodexBarCore/Providers/Claude/ClaudeCLISession.swift
  • Cost usage: Sources/CodexBarCore/CostUsageFetcher.swift, Sources/CodexBarCore/Vendored/CostUsage/*

Build docs developers (and LLMs) love