How it works

The exact files and operations behind a switch. No magic, three moves.

Where Claude Code keeps your login

On macOS, Claude Code stores OAuth credentials in the Keychain under the service Claude Code-credentials. On Linux and Windows, the same credential blob lives in a plaintext file at ~/.claude/.credentials.json. On every platform, your account identity (email, organization) sits in the oauthAccount block of ~/.claude.json. A Yoink profile is a snapshot of both. If CLAUDE_CONFIG_DIR is set, Yoink follows it for these files, matching Claude Code.

$ security find-generic-password -w -s "Claude Code-credentials"

What a switch does

1. Re-snapshot. Claude Code refreshes tokens silently in the background, so Yoink first reads the live credential and folds it back into the profile that is currently active. A token refreshed five minutes ago is preserved, not clobbered.

2. Write the target.The target profile's credential blob goes into the Keychain entry on macOS or .credentials.json elsewhere, and its oauthAccount block into ~/.claude.json, preserving the file's existing indentation.

3. Reconcile the env block. For a Claude account, the seven managed ANTHROPIC_* keys are stripped from ~/.claude/settings.json so OAuth wins. For an external provider, they are written. Nothing else in the file changes.

Storage

Profiles live in ~/.config/yoink/profiles.json on every OS, created with chmod 600 inside a 0700 directory on POSIX. The credentials file keeps owner-only permissions too: 0600on Linux, and on Windows it inherits your user profile's ACLs, the same protection Claude Code itself applies. On macOS the credential never touches a file: it stays in the Keychain. Every write in Yoink, the profile store, the credentials file, ~/.claude.json, and both settings files, is atomic: content goes to a temp file first, then a rename replaces the original, so a crash mid-write can never leave a truncated file.

Why a restart is needed

A running Claude Code session holds its token in memory and may write it back to the credential store on its next refresh, overwriting what Yoink just placed there. Yoink detects a running session (pgrep on macOS and Linux, tasklist on Windows) and asks before switching. Restart Claude Code after a switch and it boots from the new credentials.