Skip to content
Back to projects

Side Projects

Claude Identity

Go CLI to switch between Claude Code accounts without logging in again.

  • Go
  • CLI
  • Claude Code
  • Keyring
  • GoReleaser
Role
Author and maintainer
Period
Oct 2026 – Present

Stack

Backend
Go 1.26go-keyring 0.2
Infrastructure
GoReleaserGitHub Actionsrelease-please
Testing
go test
Tooling
Claude Code plugin

Personal project, active since October 2026. It is open source and I maintain it alone.

The problem

Anyone using Claude Code with more than one account (say personal and work, or two with separate usage limits) has to log out and log in again, and loses the context of what they were doing. When an account hits its limit, the work stalls.

What I built

cid is a Go binary that stores each account in the OS keyring (Windows Credential Manager, macOS Keychain or Linux Secret Service) and switches between them inside a running Claude Code session. It includes:

  • A Claude Code plugin with an /account command that answers instantly without spending a model turn.
  • Per-account usage bars for the 5-hour and weekly windows.
  • Automatic switching between a principal and a reserve account as the limit approaches.
  • Self-update for the binary and the plugin, with checksum verification.
  • English and Spanish output.

How a user interacts

  1. Step 1

    User · Registers their accounts

    Isolated login, once per account

  2. Step 2

    User · Types /account in Claude Code

  3. Step 3

    Hook · Runs cid hook

    No model turn, no shell

  4. Step 4

    cid · Swaps the credentials

    Waits for lock files and verifies the login

  5. Step 5

    Claude Code · Continues the same session

Architecture

  1. Claude Code

    • PluginType: clientHooks and skills
    • Status lineType: channelUsage per account
  2. cid

    • CLIType: serviceGo 1.26
    • Safe swapType: workerLocks and rollback
    • Auto-switchType: workerAnti-flap policy
  3. System

    • OS keyringType: infraCredentials
    • Claude configType: dataLocal files

Connections

  • PluginCLIcid hook
  • Status lineAuto-switchusage
  • CLISafe swap
  • Auto-switchSafe swap
  • Safe swapOS keyring
  • Safe swapClaude config
Go test files
41
Lines of Go, excluding tests
8.4kapproximate
Binaries per release
6Windows, macOS and Linux, amd64 and arm64
Latest published release
v90

Architecture

cid is a single Go binary (cmd/cid) with its logic in internal/. The Claude Code plugin is Markdown and JSON: a hook calls cid hook and skills invoke the CLI. Each account’s credentials are stored in the OS keyring.

  1. Claude Code

    • PluginType: clientUserPromptExpansion
    • Status lineType: channelrate_limits
  2. internal/

    • cliType: serviceCommands, --json, exit 0/1/2
    • swapType: workerSafe swap
    • autoType: workerPolicy and state
    • profileType: dataProfiles and recovery
  3. System

    • KeyringType: infrago-keyring
    • FilesType: infraAtomic writes, flock

Connections

  • Pluginclicid hook
  • Status lineauto
  • cliswap
  • autoswap
  • swapprofile
  • swapKeyring
  • profileFiles

Account switch flow

  1. Step 1

    cid · Waits for Claude Code lock files

  2. Step 2

    cid · Refuses empty or unknown logins

    A token counts as expired 5 minutes early

  3. Step 3

    cid · Writes the target account credentials

    Atomic write

  4. Step 4

    cid · Verifies the login

  5. Step 5

    cid · Restores the previous login on failure

Repository layout

  • cmd/cid/: entry point
  • internal/
  • cli/: commands and hook
  • swap/: safe swap
  • claudecfg/: keyring and Claude files
  • credentials/
  • profile/: profiles and .bak recovery
  • auto/: auto-switch policy and JSON schemas
  • settings/: config: env, file, defaults
  • login/: isolated login
  • pathenv/
  • fsutil/: atomic writes, Windows rename
  • i18n/: English and Spanish
  • plugin/: hooks and skills
  • scripts/: install.ps1 and install.sh installers
  • docs/: RELEASING and spikes

Stack

Backend

  • Go1.26
  • go-keyring0.2

Infra

  • GoReleaser
  • GitHub Actions
  • release-please

Testing

  • go test

Tooling

  • Claude Code plugin

Key decisions

  1. OS keyring as the store. cid does not implement its own OAuth: login runs claude auth login in an isolated temp directory and the credentials end up in Windows Credential Manager, macOS Keychain or Linux Secret Service, through go-keyring.
  2. A swap that can be undone. It waits for Claude Code’s lock files, verifies the login after writing and restores the previous one if anything fails. Before building it I ran an experiment (docs/spikes/r2-hot-swap.md) showing the hot swap was viable.
  3. A hook with no model and no shell. /account resolves through a UserPromptExpansion hook that runs cid hook, so it answers instantly and uses no turn.
  4. Auto-switch with anti-flap rules. A principal account and reserves, with a 5-point headroom and 5 minutes between switches, so it does not bounce back and forth near the limit.
  5. Failure-resistant files. Atomic writes, flock locking and recovery of corrupt files from a .bak copy. JSON schemas validate the configuration.
  6. Stable contract. --json output and exit codes 0/1/2, so scripts can depend on the CLI.

Testing, CI and deployment

41 test files. GitHub Actions runs gofmt, go vet and go test -race ./... on Ubuntu, macOS and Windows, plus a lint job, CodeQL and Dependabot. Actions are pinned by commit SHA. release-please picks versions from conventional commits and GoReleaser publishes binaries for Windows, macOS and Linux on amd64 and arm64. The installers (install.ps1, install.sh) verify SHA-256 and use gh attestation verify when gh is present. Current version: v0.9.0.

Repository docs

The nicoarbelaez/claude-identity repository includes README.md, README.en.md, docs/architecture.md and docs/RELEASING.md.