# cloaked

Switch between multiple Claude Code accounts without logging out.

---

Claude Code stores auth in two places: a Keychain entry and a field in `~/.claude.json`. Switching accounts normally means logging out, waiting, logging back in. `cloaked` snapshots both spots per account and swaps them on demand.

## Install

```
cargo install cloaked
```

Or build from source:

```
git clone https://github.com/simplysabir/cloaked
cd cloaked
cargo build --release
```

## Setup

Log in to your first account in Claude Code, then run:

```
cloaked add
```

Log out, log in to your second account, then run it again:

```
cloaked add
```

That's all the setup needed.

## Usage

```
cloaked list                    # see all managed accounts
cloaked switch 2                # switch by number
cloaked switch work@company.com # switch by email
cloaked status                  # verify what's active
cloaked remove 2                # remove a managed account
```

After switching, restart Claude Code.

## How it works

Claude Code stores OAuth tokens (access token, refresh token, expiry) in the macOS Keychain under the service name `Claude Code-credentials`. It also stores account metadata — email, UUID — in `~/.claude.json` under the `oauthAccount` field.

`cloaked add` snapshots both for the currently logged-in account. Credentials go into a separate Keychain entry (`cloaked-account-{n}-{email}`), and the `oauthAccount` blob goes into `~/.cloaked/configs/`. `~/.cloaked/accounts.json` tracks the list.

`cloaked switch` runs in the opposite direction: it snapshots the current account (in case tokens refreshed), then writes the target account's credentials and `oauthAccount` back into Claude Code's live locations. Only the `oauthAccount` field in `~/.claude.json` is touched — everything else in that file is left alone.

## Data

Everything lives in `~/.cloaked/`:

```
~/.cloaked/
├── accounts.json          # account list and active pointer
└── configs/
    ├── 1-personal@gmail.com.json
    └── 2-work@company.com.json
```

Credentials stay in the Keychain. Config files and the directory are created with permissions 600/700.

## Platform

macOS only for now. Linux support via the Secret Service is straightforward to add — PRs welcome.

## License

MIT
