ccx

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: MIT

README

ccx — Claude Code eXtended

CI Release Go Report Card

Switch between Claude Code accounts in one command, see your real usage across all of them — from a single Go binary.

ccx demo

Install

# macOS / Linux
brew install arafa-dev/ccx/ccx

# Windows
scoop bucket add ccx https://github.com/arafa-dev/scoop-ccx
scoop install ccx

# Debian / Ubuntu
curl -fsSL https://github.com/arafa-dev/ccx/releases/latest/download/ccx_linux_amd64.deb -o /tmp/ccx.deb
sudo dpkg -i /tmp/ccx.deb

# One-liner (macOS / Linux)
curl -fsSL https://raw.githubusercontent.com/arafa-dev/ccx/main/install.sh | sh

# From source
go install github.com/arafa-dev/ccx/cmd/ccx@latest

60-second quick start

# 1. Register your existing default account as a profile
ccx profile add personal --config-dir ~/.claude

# 2. Add a second profile and authenticate it
ccx profile add work --config-dir ~/.claude-profiles/work
eval "$(ccx use work)"
claude /login        # authenticate the work account

# 3. Switch any time
eval "$(ccx use personal)"

# 4. See usage across all profiles
ccx usage

# 5. Open the dashboard
ccx dashboard

# 6. Keep usage fresh in the background
ccx daemon start
ccx daemon status

dashboard screenshot

Why ccx?

If you run more than one Claude Code account — Pro plus Max, work plus personal, multiple Pro accounts on a shared machine — you've probably ended up with a directory of shell aliases that hot-swap ~/.claude, plus ccusage open in another tab for analytics. Two tools to do one job.

ccx is the one tool. It switches accounts (the part ccusage doesn't do) and tracks usage (the part the bash-alias scripts don't do), all from a single Go binary.

How it works

ccx never proxies API calls. The upstream claude CLI does what it always did — ccx just chooses which config dir and which keychain entry claude reads from, by exporting CLAUDE_CONFIG_DIR in your shell. The optional daemon, hooks, and suggestions all work from local files and the local SQLite cache.

architecture diagram

For details, see docs/architecture.md.

Common usage

Background daemon:

ccx daemon start              # run local scanner/dashboard API in the background
ccx daemon status             # show pid and URL; add --json for paths
ccx daemon logs --follow      # stream ~/.ccx/daemon.log
ccx daemon restart            # stop and start the daemon
ccx daemon stop

Hook telemetry:

ccx hooks install             # install ccx-managed hooks for all profiles
ccx hooks install --profile work
ccx hooks status
ccx hooks uninstall --profile work

Hooks update each profile's settings.json, create settings.json.ccx-backup-* files before modifying existing settings, and record local session telemetry such as starts, stops, failures, and compactions.

Advisory profile suggestions:

ccx profile set work \
  --daily-tokens 200000 \
  --weekly-tokens 1000000 \
  --monthly-usd 100 \
  --priority 5 \
  --rate-limit-cooldown 5h \
  --suggestions enabled

ccx suggest
ccx suggest --json

ccx suggest ranks registered profiles by configured budgets, recent usage, hook failures, cooldowns, and priority. It prints a suggested ccx use <name> command; it does not switch accounts automatically.

Plan-aware quota

ccx v0.2 adds quota windows for Claude plan tiers. Configure each profile with its plan tier and optional caps:

ccx profile set personal --plan-tier pro
ccx profile set max-work --plan-tier max5 --caps-5h-turns 225 --caps-weekly-turns 900

Hook telemetry counts completed turns from local Stop events, so ccx usage --quota and the dashboard quota panel can show 5-hour and weekly pressure without proxying Claude traffic.

ccx usage --quota
ccx dashboard --daemon

Suggestions are pressure-aware. Near a soft or hard cap, ccx suggest lowers a profile's score or marks it unavailable, and ccx run can pick a healthier profile before launching Claude:

ccx run -- claude -p "summarize this repo"
ccx run --supervise -- claude

ccx run --supervise waits for a completed turn, then relaunches Claude with --resume <session-id> if the daemon reports a better profile. For continuity, new profiles link their projects/ directory to ~/.ccx/shared-projects/. Existing profiles can opt in safely with a dry run first:

ccx migrate-shared-history --dry-run
ccx migrate-shared-history

Comparison

Capability ccx ccusage claude-account-switcher ccs
Profile switching ✅ (bash only)
Usage analytics ✅ (deepest) partial
Local dashboard
Single binary npm shell script TS + Tauri
Cross-platform macOS · Linux · Windows macOS-focused
Distribution brew · scoop · apt · curl|sh npm manual GitHub Releases

Be honest: ccusage has deeper analytics than ccx (per-message drilldowns, custom date ranges). If analytics is your only need, use ccusage. If you also juggle accounts, ccx replaces both.

Configuration

ccx state lives in ~/.ccx/:

  • ~/.ccx/profiles.toml — registered profile list (human-editable)
  • ~/.ccx/state.db — SQLite cache of parsed events
  • ~/.ccx/pricing.yaml — optional override for the embedded model pricing table

Profile config dirs live wherever you put them (commonly ~/.claude-profiles/<name>). On macOS the credential lives in Keychain under a service name derived from the config dir path — ccx does not touch your credentials directly.

See docs/installation.md for per-platform setup details.

Roadmap

Planned, not promised:

  • Dashboard refinements on top of the background daemon
  • Richer hook-based session analytics
  • More transparent headroom scoring and suggestion explanations
  • Team workspace primitives, profile sync via git

Contributing

Issues, bug reports, and PRs welcome. Please read CONTRIBUTING.md and docs/conventions.md before opening a PR.

License

MIT

Directories

Path Synopsis
cmd
ccx command
Command ccx is the user-facing CLI binary for the ccx workspace manager.
Command ccx is the user-facing CLI binary for the ccx workspace manager.
internal
cli
Package cli wires Phase 1 packages into the cobra command tree exposed by cmd/ccx.
Package cli wires Phase 1 packages into the cobra command tree exposed by cmd/ccx.
contracts
Package contracts defines the shared types and interfaces used across all ccx internal packages.
Package contracts defines the shared types and interfaces used across all ccx internal packages.
dashboard
Package dashboard exposes the embedded Next.js static export as an http.FileSystem.
Package dashboard exposes the embedded Next.js static export as an http.FileSystem.
doctor
Package doctor implements `ccx doctor` — a structured set of diagnostic checks reported as ✅/⚠/❌.
Package doctor implements `ccx doctor` — a structured set of diagnostic checks reported as ✅/⚠/❌.
headroom
Package headroom ranks profiles for advisory profile selection.
Package headroom ranks profiles for advisory profile selection.
hooks
Package hooks installs Claude Code hooks and records hook telemetry.
Package hooks installs Claude Code hooks and records hook telemetry.
platform
Package platform contains small OS-conditional helpers used by the rest of ccx: resolving the default Claude Code config directory, locating the ccx state directory, expanding user-supplied paths, detecting the user's shell, and figuring out where Claude Code stores credentials per OS.
Package platform contains small OS-conditional helpers used by the rest of ccx: resolving the default Claude Code config directory, locating the ccx state directory, expanding user-supplied paths, detecting the user's shell, and figuring out where Claude Code stores credentials per OS.
pricing
Package pricing loads the embedded model→USD rate table and computes estimated cost for a given model + usage + timestamp.
Package pricing loads the embedded model→USD rate table and computes estimated cost for a given model + usage + timestamp.
profile
Package profile manages the ccx profile registry (~/.ccx/profiles.toml).
Package profile manages the ccx profile registry (~/.ccx/profiles.toml).
quota
Package quota computes per-profile plan-aware quota windows from local hook telemetry.
Package quota computes per-profile plan-aware quota windows from local hook telemetry.
quotamigrate
Package quotamigrate owns the symlink layout that B3b introduces: every profile's <CLAUDE_CONFIG_DIR>/projects/ is a symlink to one shared directory at <CCX_HOME>/shared-projects/.
Package quotamigrate owns the symlink layout that B3b introduces: every profile's <CLAUDE_CONFIG_DIR>/projects/ is a symlink to one shared directory at <CCX_HOME>/shared-projects/.
quotawire
Package quotawire constructs a server.QuotaProvider from concrete repo types so the daemon and foreground dashboard can share quota wiring.
Package quotawire constructs a server.QuotaProvider from concrete repo types so the daemon and foreground dashboard can share quota wiring.
recstream
Package recstream broadcasts pressure-driven RecommendationEvents from the daemon's ingest loop to subscribers (the /api/recommendations/live SSE handler and, in B3b, the ccx run --supervise process).
Package recstream broadcasts pressure-driven RecommendationEvents from the daemon's ingest loop to subscribers (the /api/recommendations/live SSE handler and, in B3b, the ccx run --supervise process).
run
Package run wraps the claude binary, setting the right CLAUDE_CONFIG_DIR for a chosen ccx profile and forwarding stdio, signals, and exit code.
Package run wraps the claude binary, setting the right CLAUDE_CONFIG_DIR for a chosen ccx profile and forwarding stdio, signals, and exit code.
scanner
Package scanner walks a profile's JSONL session files and emits parsed contracts.Events.
Package scanner walks a profile's JSONL session files and emits parsed contracts.Events.
server
Package server implements the local HTTP API consumed by the embedded dashboard.
Package server implements the local HTTP API consumed by the embedded dashboard.
sharedscan
Package sharedscan classifies profiles by whether their projects directory points at the shared-projects history root.
Package sharedscan classifies profiles by whether their projects directory points at the shared-projects history root.
shell
Package shell emits shell-specific snippets for `ccx use` (eval-style) and `ccx init` (one-time rc-file paste).
Package shell emits shell-specific snippets for `ccx use` (eval-style) and `ccx init` (one-time rc-file paste).
storage
Package storage provides a SQLite-backed implementation of contracts.Store.
Package storage provides a SQLite-backed implementation of contracts.Store.
tui
Package tui provides the bubbletea-based profile picker used by `ccx use` when invoked with no profile name.
Package tui provides the bubbletea-based profile picker used by `ccx use` when invoked with no profile name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL