Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BetterCC

A lightweight native macOS menu bar app for managing Claude Code sessions, MCP servers, and tracking token usage — all from your status bar.

macOS 14+ Swift 6 License MIT

Why?

Running Claude Code spawns dozens of processes — Claude instances, MCP servers, Node.js workers — that pile up quickly. A typical session can reach 3+ GB RAM for Claude processes alone, with MCP servers adding another 6+ GB from ~142 orphaned processes. BetterCC gives you visibility and control over all of it from a single menu bar icon.

Features

Session Management

  • Live process monitoring — see all active Claude Code sessions with CPU, memory, and uptime
  • Last chat preview — view the most recent user/assistant message per session
  • Grouped by type — CLI, Cursor, VS Code instances grouped separately
  • Kill controls — terminate individual sessions, groups, or all orphaned processes
  • Smart detection — automatically identifies orphaned processes (no parent terminal)

MCP Server Management

  • Dashboard view — see all configured MCP servers from ~/.claude.json
  • Add / Remove / Toggle — manage servers directly from the UI (disabled servers use _prefix convention)
  • mcp-proxy integration — start/stop @anthropic-ai/mcp-proxy, auto-configure Claude to use HTTP proxy
  • Inline confirmations — no popover-closing dialogs (MenuBarExtra-safe inline UI)

Usage Tracking

  • 5-hour rolling window — track token consumption against tier limits
  • Weekly usage — monitor cumulative weekly token usage
  • Tier support — Pro (44K/5h), Max 5x (88K/5h), Max 20x (220K/5h)
  • Burn rate — tokens/hour with ETA to limit
  • Reset countdown — time until your 5-hour window resets
  • Accurate formulainput_tokens + cache_creation + cache_read (matches Anthropic's billing)

Extras

  • Vietnamese IME fix — one-click patch for OpenKey/EVKey/Unikey input issues in Claude Code terminal
  • Launch at login — auto-start via SMAppService
  • Standalone settings window — native NSWindow, doesn't interfere with the menu bar popover

Requirements

  • macOS 14.0 (Sonoma) or later
  • XcodeGen (for building from source)
  • Claude Code installed (~/.claude/ directory)

Build

# Clone
git clone https://github.com/trananhhh/better-cc.git
cd better-cc

# Generate Xcode project
xcodegen generate

# Build & run
open BetterCC.xcodeproj
# Or from CLI:
xcodebuild -scheme BetterCC -configuration Debug build

The built app appears in DerivedData/BetterCC-*/Build/Products/Debug/BetterCC.app.

Architecture

BetterCC/
├── BetterCCApp.swift          # Entry point — MenuBarExtra with .window style
├── Core/
│   ├── AppState.swift         # Central @Observable state
│   └── Constants.swift        # App-wide constants
├── Models/
│   ├── ClaudeProcess.swift    # Process model (PID, CPU, memory, command)
│   ├── ClaudeInstance.swift   # Instance = main process + child MCP servers
│   ├── ChatMessage.swift      # Last chat message model
│   ├── MCPServerConfig.swift  # MCP server configuration from ~/.claude.json
│   ├── TokenEntry.swift       # Single token usage entry from JSONL
│   └── UsageSnapshot.swift    # Computed usage state (5h window, weekly, burn rate)
├── Services/
│   ├── ProcessMonitor.swift   # Timer-based process scanning + caching
│   ├── ProcessScanner.swift   # ps aux parsing
│   ├── ProcessClassifier.swift # Classify processes by type (CLI, Cursor, etc.)
│   ├── ProcessTreeBuilder.swift # Build parent-child process trees
│   ├── OrphanDetector.swift   # Detect orphaned processes
│   ├── SessionResolver.swift  # Map PIDs to Claude session JSONL files
│   ├── SessionJSONLParser.swift # Parse ~/.claude/projects/*/*.jsonl
│   ├── UsageMonitor.swift     # Token usage tracking with tier limits
│   ├── RollingWindowCalculator.swift # 5-hour rolling window math
│   ├── BurnRateEstimator.swift # Token consumption rate estimation
│   ├── MCPConfigReader.swift  # Read MCP servers from ~/.claude.json
│   ├── MCPConfigWriter.swift  # Add/remove/toggle MCP servers
│   └── MCPProxyManager.swift  # Start/stop mcp-proxy, auto-configure
├── Views/
│   ├── MainPopoverView.swift  # Root view with custom tab bar
│   ├── SessionListView.swift  # Session list with grouped sections
│   ├── SessionRowView.swift   # Individual session row with chat preview
│   ├── MCPDashboardView.swift # MCP server management dashboard
│   ├── UsageTabView.swift     # Usage tracking with gauges and progress bars
│   └── SettingsView.swift     # Settings form (refresh, launch at login, IME fix)
└── Utilities/
    ├── SettingsWindowController.swift # Standalone NSWindow for settings
    ├── TimeFormatter.swift    # Static relative time (no layout shift)
    ├── ShellExecutor.swift    # Shell command execution helper
    └── TerminalFocuser.swift  # Focus terminal via PPID chain

How It Works

  • Process scanning: Parses ps aux output every 5 seconds, classifies processes by command pattern, builds parent-child trees
  • Session resolution: Maps process working directories to ~/.claude/projects/<encoded-path>/<session>.jsonl, reads last 32KB via FileHandle for performance
  • Usage tracking: Parses all JSONL files under ~/.claude/projects/, computes rolling 5-hour window and weekly totals using quotaTokens (input + cache tokens)
  • MCP management: Reads/writes ~/.claude.json directly, uses _serverName prefix convention for disabled servers

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors