# wrangler-accounts
AWS-style multi-account convenience for Cloudflare Wrangler. Run commands against different Cloudflare accounts in parallel shells without switching global state.
```bash
wrangler-accounts login work # first-time setup (isolated)
wrangler-accounts default work # set persistent default
wrangler-accounts deploy # uses default profile
wrangler-accounts --profile personal deploy
wrangler-accounts exec personal -- npm run release
```
Two shells side by side, two different Cloudflare accounts, zero interference:
```bash
# terminal 1
wrangler-accounts --profile work tail my-worker
# terminal 2
wrangler-accounts --profile personal dev
```
## New in 1.9.0: built on wrangler's native profiles
Wrangler 4.149 added its own named login profiles (`wrangler auth create`, `wrangler --profile <name>`, optional OS-keychain encryption). wrangler-accounts now builds on them **without changing any command you already use**:
```bash
wrangler-accounts migrate work # move an OAuth profile into wrangler's own profile store
wrangler-accounts protect work # encrypt its OAuth credentials (key in macOS Keychain / Linux secret-tool)
wrangler-accounts --profile work deploy # same as before
wrangler --profile work deploy # now also works directly
wrangler-accounts --profile work cf dns records list --zone example.com # Cloudflare's new `cf` CLI
```
- **Two backends, one CLI.** Profiles you don't migrate keep the shadow-HOME backend and work with any wrangler version. Migrated profiles run as `wrangler --profile <name>`; `exec`, `list --deep`, `whoami`-style checks still isolate correctly (a bare `wrangler` or `npm run deploy` inside `exec` uses that profile only). **Projects that lock an older wrangler (< 4.149) keep working too (1.9.2+):** `exec <name> -- npx wrangler ...` also gets that profile's credentials as the old-style `default.toml` in the throw-away shadow HOME โ an encrypted profile is decrypted into a `0600` file there for the run only, a refreshed token is re-encrypted back into `<name>.enc`, and the copy is deleted when the command exits (also on Ctrl-C).
- **`migrate` is opt-in and reversible.** It copies the credentials, asks wrangler to read them back (`wrangler auth token`), and only then removes the old copy. `--dry-run` shows the plan, `unmigrate` moves it back. An existing wrangler profile with the same name is never overwritten without `--force` (and then it is backed up first). Names wrangler doesn't allow (`acme.prod`) become `acme-prod`, or pick one with `--as`.
- **OAuth encryption at rest (#3).** `protect <oauth-profile>` migrates if needed and lets wrangler encrypt the credentials (`<name>.enc`, AES-256-GCM, key in the OS keychain). Verified: no plaintext file is left. `unprotect` decrypts it back. `protect --all` now covers token *and* OAuth profiles.
- **cf support.** `wrangler-accounts --profile <name> cf ...` and `exec <name> -- cf ...` run Cloudflare's `cf`: token profiles get `CLOUDFLARE_API_TOKEN`/`CLOUDFLARE_ACCOUNT_ID`, OAuth profiles use cf's own login of the same name (`cf auth create <name>` once โ cf and wrangler log in separately). The guard hook and PATH shim also cover a bare `cf`, **only** when it is Cloudflare's โ Cloud Foundry's `cf` is never touched.
### Do I still need wrangler-accounts?
If you only use OAuth logins, run `wrangler` by hand, and are happy typing `--profile` or binding directories with `wrangler auth activate`, native profiles alone are enough. wrangler-accounts adds:
- a persistent default and `WRANGLER_PROFILE` for scripts, plus positional shorthand (`wrangler-accounts work deploy`)
- API-token profiles next to OAuth ones (and their tokens in the keychain)
- stripping of exported `CLOUDFLARE_API_TOKEN` / `CLOUDFLARE_ACCOUNT_ID`, which otherwise silently override or redirect `--profile`; the profile's own account id is exported for account-scoped commands
- `exec <name>` subshells where *every* wrangler (including `npx`/`npm run`) and `cf` use that account
- guard rails for AI agents: the Claude Code hook and the `wrangler`/`cf` PATH shim
- `list --deep` health checks, notes, JSON output, and the same commands for old wrangler versions
### Things to know about wrangler's keyring mode
- wrangler-accounts never changes wrangler's global keyring setting. For a protected profile it passes `CLOUDFLARE_AUTH_USE_KEYRING=true` itself. A bare `wrangler --profile <name>` needs `wrangler auth keyring enable` (or that env var) to read it.
- **`wrangler auth keyring disable` deletes every encrypted wrangler profile.** To go back to plaintext use `wrangler-accounts unprotect <name>`, which decrypts first.
- `remove <name>` on a migrated profile keeps wrangler's native profile (you may use it directly) and says so; `remove <name> --delete-native` deletes it and its keychain key.
- Shadow-HOME profiles always run with keyring mode off (every shadow profile looks like wrangler's `default` profile, so encryption there would share one key).
## Claude Code users (recommended)
Install the marketplace and plugin first:
```text
/plugin marketplace add leeguooooo/wrangler-accounts
/plugin install wrangler-accounts@leeguoo-tools
```
The plugin bundles the `wrangler-accounts` skill plus a Bash `PreToolUse` hook, so Claude Code can learn the workflow and block raw `wrangler` calls before they bypass your local profile isolation. No manual `settings.json` editing is required.
The plugin does **not** install the CLI binary. Keep the CLI on your `PATH` (installed straight from GitHub โ no npm registry, no token):
```bash
npm i -g github:leeguooooo/wrangler-accounts
```
The guard only blocks direct `wrangler ...` Bash commands when all of these are true:
- `wrangler-accounts` is installed on `PATH`
- at least one local profile is configured
- the current directory looks like a Cloudflare project (`wrangler.toml`, `wrangler.json`, or `wrangler.jsonc`) or Cloudflare API env vars are set
If you explicitly want raw `wrangler`, bypass the hook for that command:
```bash
NOWRANGLER_ACCOUNTS_GUARD=1 wrangler deploy
```
### Upgrading from the `skills.sh` install
If you previously installed this skill via `npx skills add leeguooooo/wrangler-accounts`, remove that standalone copy after installing the plugin โ otherwise Claude Code's slash command picker shows two identical `/wrangler-accounts` entries (one from the skills.sh directory, one from the plugin):
```bash
npx skills remove wrangler-accounts
# or, if the CLI is missing: rm -rf ~/.agents/skills/wrangler-accounts
```
Then run `/reload-plugins` and confirm only one entry remains.
## Any agent / any shell: the global `wrangler` shim
The Claude Code plugin hook above only protects Claude Code. To enforce "use `wrangler-accounts` instead of raw `wrangler`" for **every** caller โ Codex, Cursor, a plain terminal, a CI-less shell script โ install the global shim. **This is a separate, opt-in step** โ installing the CLI does *not* install the shim (it changes your `PATH`, so it's never automatic):
```bash
# 1. Install the CLI (if you haven't):
npm i -g github:leeguooooo/wrangler-accounts
# 2. Install the shim and add it to your shell's PATH automatically.
# --apply edits the right rc file for zsh / bash / fish:
wrangler-accounts shim install --apply
# 3. Open a new shell (or run the printed line once in the current one), then verify:
wrangler-accounts shim status # want: "Active (intercepts bare wrangler): yes"
```
`--apply` writes the correct syntax for your shell โ `export PATH="โฆ:$PATH"` for zsh/bash (into `~/.zshrc` / `~/.bashrc`), `fish_add_path -p โฆ` for fish (into `~/.config/fish/config.fish`). If you'd rather edit `PATH` yourself, run `wrangler-accounts shim install` (no `--apply`) and it prints the exact line for your shell.
Once the shim dir is at the front of `PATH`, a bare `wrangler deploy` is blocked with guidance whenever you have profiles configured:
```text
$ wrangler deploy
wrangler-accounts: direct `wrangler` is blocked.
...
wrangler-accounts deploy # runs under default profile 'work'
wrangler-accounts --profile <name> deploy
Profiles on this machine:
- work
- personal
To force raw wrangler this once: WA_PASSTHROUGH=1 wrangler deploy
```
Check it's active with `wrangler-accounts shim status` (reports whether the shim dir is ahead of the real `wrangler` on `PATH`). Remove it with `wrangler-accounts shim uninstall --apply`.
The shim **passes through to real `wrangler`** so it never gets in your way:
- `WA_PASSTHROUGH=1 wrangler ...` (one-off escape; the hook's `NOWRANGLER_ACCOUNTS_GUARD=1` is also honored)
- `wrangler --version` / `--help` (account-agnostic)
- when no profiles are configured
- inside `wrangler-accounts exec` and any wrangler-accounts-spawned subprocess (already isolated)
- `wrangler auth ...` (wrangler's own profile management) and an explicit `wrangler --profile <name> ...` when no `CLOUDFLARE_API_TOKEN` / `CLOUDFLARE_ACCOUNT_ID` / `CLOUDFLARE_API_KEY` is exported (1.9.0+)
If Cloudflare's `cf` CLI is on your `PATH`, `shim install` also adds a `cf` shim with the same rules (it passes `cf auth ...` and `cf --profile ...` through). It checks the real `cf` every time and steps aside for anything that isn't Cloudflare's, so Cloud Foundry's `cf` keeps working.
**Limitation:** `npx wrangler` / `pnpm wrangler` / `./node_modules/.bin/wrangler` run a project-local binary that a `PATH` shim can't shadow. The shim covers globally-invoked `wrangler`. The shim and the Claude Code hook are complementary and can both be installed.
## What it does
Profiles that you have not migrated (all of them, until you run `migrate` or `protect` on an OAuth profile) work like this โ and this backend works with every wrangler version:
Every execution runs `wrangler` inside a per-invocation **shadow HOME** โ a temporary directory that mirrors most of your real home, except `.wrangler/config/default.toml` is a symlink pointing at the saved profile's config. Token refreshes flow back to the profile automatically. Nothing touches your real `~/.wrangler`. Two parallel invocations get two independent shadow HOMEs.
Migrated (native) profiles live in wrangler's own store (`~/.wrangler/config/<name>.toml` or `.enc`) and run as `wrangler <args> --profile <name>` with your real HOME. Where wrangler does not accept `--profile` (`wrangler whoami`, a subshell from `exec`), wrangler-accounts uses a shadow HOME whose directory bindings point every directory at that one profile. Both backends strip inherited Cloudflare credentials, export the profile's own `CLOUDFLARE_ACCOUNT_ID`, and use a per-profile `WRANGLER_CACHE_DIR`.
## Install
If you do **not** use Claude Code plugins, install the CLI binary and the mirrored `skills.sh` skill separately:
```bash
# 1. The CLI (always required)
npm i -g github:leeguooooo/wrangler-accounts
# 2. The AI agent skill mirror (recommended if you use Cursor / Codex / Gemini CLI / etc.)
npx skills add leeguooooo/wrangler-accounts -g -y
```
The CLI works standalone โ you can skip step 2 if you don't use an AI coding agent. The skill is just markdown documentation the AI reads; it cannot run anything without the CLI installed.
### Why two steps?
| | Installs | For |
|---|---|---|
| `npm i -g github:leeguooooo/wrangler-accounts` | The `wrangler-accounts` executable onto your `PATH` | Your shell |
| `npx skills add leeguooooo/wrangler-accounts` | `SKILL.md` (markdown) into your AI agent's skills directory | Your AI agent to read |
The AI will tell you to run commands like `wrangler-accounts --profile work deploy`; without step 1 those commands fail with "command not found".
### `skills.sh` mirror โ more options
The repo keeps a mirrored Agent Skill at `skills/wrangler-accounts/SKILL.md` for [skills.sh](https://skills.sh). Claude Code users should prefer the plugin marketplace flow above; other agents can keep using `skills.sh` to install the same guidance markdown into their own skill directories.
```bash
npx skills add leeguooooo/wrangler-accounts -g -y # user-global, non-interactive
npx skills add leeguooooo/wrangler-accounts # project-scoped, interactive
npx skills add leeguooooo/wrangler-accounts -a claude-code cursor # specific agents only
npx skills add leeguooooo/wrangler-accounts --list # preview without installing
```
After both are installed, ask your AI agent something like "deploy my worker to the work account" or "set up a new Cloudflare profile" and the skill will guide it through the right commands.
## Usage
```bash
wrangler-accounts <wrangler-args...> # uses default profile
wrangler-accounts --profile <name> <wrangler-args...>
wrangler-accounts -p <name> <wrangler-args...>
WRANGLER_PROFILE=<name> wrangler-accounts <wrangler-args...>
wrangler-accounts exec <name> # interactive subshell
wrangler-accounts exec <name> -- <cmd> [args] # one command
wrangler-accounts login <name> # isolated OAuth login (browser)
wrangler-accounts token-add <name> <api-token> <account-id> [--force] [--protect] # API token profile (no browser)
wrangler-accounts protect <name> | --all # move token secrets into the OS keychain
wrangler-accounts unprotect <name> | --all # move them back into token.json
wrangler-accounts default [name | --unset] # manage persistent default
wrangler-accounts whoami [--profile <name>] # show resolved identity
wrangler-accounts list # fast table (name/status/expires/identity)
wrangler-accounts list --deep # authoritative check via wrangler whoami
wrangler-accounts list --json # structured output for scripts
wrangler-accounts status
wrangler-accounts save <name> # snapshot current Wrangler config
wrangler-accounts sync <name> # refresh a profile from current login
wrangler-accounts sync-default # refresh the default profile
wrangler-accounts remove <name>
wrangler-accounts gc [--older-than 1h] # clean stale shadow HOMEs
wrangler-accounts shim install [--apply] # global wrangler shim (any shell/agent)
wrangler-accounts shim status
wrangler-accounts shim uninstall [--apply]
-v, --version # print version
```
### `list` output
Fast default (no network calls โ read from saved `config.toml` only):
```
Default: work
NAME STATUS EXPIRES IDENTITY
* work valid in 47m (2026-04-10) work@example.com / 0123456789abcdef0123456789abcdef
personal valid in 53m (2026-04-10) me@example.com / fedcba9876543210fedcba9876543210
Legend: * = default profile, EXPIRED = access token past expiration_time (wrangler may still auto-refresh)
STATUS is derived from the saved file only. For a live check that runs 'wrangler whoami' against Cloudflare,
pass --deep (slower, makes network calls).
```
Authoritative `--deep` check (spawns `wrangler whoami` in a shadow HOME per profile, ~1s each, network required):
```
[wrangler-accounts] running deep check (wrangler whoami) for 2 profile(s)...
NAME STATUS EXPIRES VERIFIED IDENTITY
* work valid in 47m (2026-04-10) โ ok work@example.com / ...
personal valid in 53m (2026-04-10) โ not logged in (refresh token may be revoked) me@example.com / ...
```
**When to use `--deep`**: when you actually need to know whether a profile still works. The default fast check only reads the saved `expiration_time`, which can lie in both directions โ it can't tell you if Cloudflare has revoked the refresh token, and it flags fine profiles as `EXPIRED` just because their access token is past its 1-hour lifetime (wrangler auto-refreshes those transparently).
The `--json` output includes the same fields as the table plus raw `expirationTime`, `isDefault`, `isActive`, and (with `--deep`) `verified`, `verifyError`, and `liveIdentity`.
## Profile resolution order
When you run `wrangler-accounts <wrangler-args>`, the active profile is resolved in this order:
1. Explicit `--profile <name>` / `-p <name>`
2. Positional shorthand: `wrangler-accounts <profile> <wrangler-args...>` (only when `<profile>` matches a saved profile name)
3. `$WRANGLER_PROFILE`
4. `profilesDir/default` (set via `wrangler-accounts default <name>`)
5. Hard error with actionable hint
## API token profiles (no browser required)
Since 1.6.0 you can save a Cloudflare API token + account ID as a named profile โ no OAuth browser flow:
```bash
# Get your API token: Cloudflare dashboard โ My Profile โ API Tokens
wrangler-accounts token-add work CF_TOKEN_HERE ACCOUNT_ID_HERE
# Use exactly like an OAuth profile
wrangler-accounts --profile work deploy
wrangler-accounts work r2 list
```
Token profiles appear in `list` with `[token]` type and `STATUS: token`. There's no expiration; they're always ready.
**Env-var pass-through:** if `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` are already in the environment, no profile selection is needed at all:
```bash
CLOUDFLARE_API_TOKEN=xxx CLOUDFLARE_ACCOUNT_ID=yyy wrangler-accounts deploy
```
### Keep API tokens in the OS keychain (1.8.0+)
By default a token profile's secret sits in `token.json` (mode 0600). You can move it into the OS secret store instead, so the file only holds the account ID:
```bash
wrangler-accounts token-add work CF_TOKEN ACCOUNT_ID --protect # never written to disk
wrangler-accounts protect work # migrate an existing profile
wrangler-accounts protect --all # every token profile
wrangler-accounts unprotect work # put it back into token.json
```
- Stores: macOS Keychain (`security`) or Linux Secret Service (`secret-tool`). Elsewhere `protect` refuses and nothing changes.
- Migration is non-destructive: the token is written to the store and read back, and only then removed from `token.json`. `unprotect` writes the file first and deletes the keychain item last.
- At run time the token is read from the store into memory and handed to wrangler as `CLOUDFLARE_API_TOKEN`; it never touches disk. `list` shows `token (keychain)`.
- Set `WRANGLER_ACCOUNTS_PROTECT_TOKENS=1` to make `token-add` protect by default. `remove` also deletes the keychain item.
- If the keychain is locked (SSH session, headless box), commands for that profile fail with a clear error instead of running without a token.
- What this protects: the token in backups, synced `~/.config`, disk images and accidental `cat`s. What it doesn't: anything already running as your user can still call `security` or `wrangler-accounts exec`.
- OAuth profiles (1.9.0+, wrangler 4.149+): `protect <name>` moves the profile into wrangler's native store and lets wrangler encrypt it with a key in the OS keychain. See "New in 1.9.0" above and [#3](https://github.com/leeguooooo/wrangler-accounts/issues/3).
## When to use `wrangler-accounts` vs. native env vars
- **Local dev, multiple OAuth accounts** โ `wrangler-accounts login <name>` (the classic use case)
- **Local dev, API token accounts** โ `wrangler-accounts token-add <name> <token> <account-id>` (1.6.0+)
- **CI / deploy pipelines** โ either `CLOUDFLARE_API_TOKEN` + `CLOUDFLARE_ACCOUNT_ID` with plain `wrangler`, or the env-var pass-through mode above
- **Shared scripts** that run locally or in CI โ parameterize on `WRANGLER_PROFILE` so devs can run them with `WRANGLER_PROFILE=work wrangler-accounts ./deploy.sh`.
## Options
```text
-c, --config <path> Wrangler config path
--profiles <path> Profiles directory (long form only)
-p, --profile <name> Profile name for this invocation
--json JSON output
--plain Plain output for list (one name per line)
--include-backups Include backup profiles in list/status
-f, --force Overwrite existing profile on save
--unset With 'default': clear the persistent default
--deep, --verify With 'list': run wrangler whoami per profile for live verification
--older-than <dur> With 'gc': age threshold (e.g. 1h, 30m, 7d)
--all protect/unprotect: every profile; migrate/unmigrate: every OAuth profile
--as <name> With 'migrate': wrangler profile name to use
--dry-run With 'migrate': show the plan, change nothing
--no-verify With 'migrate': skip the 'wrangler auth token' check (offline)
--keep-native With 'unmigrate': leave wrangler's copy in place
--delete-native With 'remove': also delete the native wrangler profile and its key
-v, -V, --version Print version
-h, --help Show help
```
## Environment variables
- `WRANGLER_PROFILE` โ profile to use when no `--profile` flag is given
- `WRANGLER_CONFIG_PATH` โ Wrangler config path override
- `WRANGLER_ACCOUNTS_DIR` โ profiles directory override
- `WRANGLER_ACCOUNTS_PROTECT_TOKENS=1` โ `token-add` stores the token in the OS keychain by default (same as `--protect`)
- `WRANGLER_ACCOUNTS_SECRET_BACKEND` โ force `keychain` or `secret-service` (auto-detected by default)
- `WRANGLER_ACCOUNTS_SHIM_DIR` โ where `shim install` writes the `wrangler` shim (default `~/.wrangler-accounts/shims`)
- `WA_PASSTHROUGH=1` โ bypass the global `wrangler` shim for one command (`NOWRANGLER_ACCOUNTS_GUARD=1` also works)
- `WRANGLER_ACCOUNTS_NATIVE=0|1` โ force native wrangler profile support off / on (normally probed once per wrangler binary with `wrangler auth --help` and cached)
- `XDG_CONFIG_HOME` โ fallback base for the profiles directory
Inside an isolated session, these are automatically set for the child process:
- `HOME` โ the shadow HOME
- `WRANGLER_PROFILE` / `WRANGLER_ACCOUNT` โ current profile name (useful for shell prompt integration)
- `WRANGLER_ACCOUNT_REAL_HOME` โ path to your real home (escape hatch)
- `WRANGLER_CACHE_DIR` โ **per-profile**, points at `<profilesDir>/<name>/cache/`. Holds wrangler's `wrangler-account.json` (selected account ID), `pages-config-cache.json`, etc. Isolating this is critical: see "What is and isn't isolated" below.
- `WRANGLER_REGISTRY_PATH`, `WRANGLER_LOG_PATH` โ pointed at real HOME so Miniflare dev registry and debug logs are shared across profiles (cross-profile dev worker discovery is intentional)
- `CLOUDFLARED_PATH` โ set when `cloudflared` is on your PATH
- `WRANGLER_SEND_METRICS=false`
## What is and isn't isolated
`wrangler-accounts` isolates the things that determine **which account a wrangler command targets**, but deliberately shares some state for performance and ergonomics. Know the boundary:
| State | Location | Isolated? |
|---|---|---|
| OAuth credentials (`config.toml`, refresh token) | shadow `$HOME/.wrangler/config/default.toml` โ symlink to per-profile file | โ
per profile |
| Account-id cache (`wrangler-account.json`) | `WRANGLER_CACHE_DIR` = `<profilesDir>/<name>/cache/` | โ
per profile |
| Pages config cache | same as above | โ
per profile |
| Miniflare dev registry | `WRANGLER_REGISTRY_PATH` = `$HOME/.wrangler/registry` | โ **shared** (intentional โ local dev workers discover each other across profiles) |
| Wrangler debug logs | `WRANGLER_LOG_PATH` = `$HOME/.wrangler/logs` | โ **shared** (append-only) |
| Project-local state (`./.wrangler/state/`, `./node_modules/.cache/wrangler`) | inside the project directory | โ **shared at project level** โ same project from two profiles uses the same project-local state. If you hit a "wrong account" symptom, clearing `./.wrangler/state/` is a good first step. |
| `cloudflared` binary cache | `~/.wrangler/cloudflared/` or `$CLOUDFLARED_PATH` | โ shared (binary, not account-scoped) |
| Shell history, `.npmrc`, `.gitconfig`, `.ssh/` etc. | symlinked through to real `$HOME` | โ shared by design (so `exec` subshells feel like a normal terminal) |
> **Why this matters**: in 1.2.1 and earlier, `WRANGLER_CACHE_DIR` was pointed at real `$HOME/.wrangler/cache`, which meant `wrangler-account.json` was shared across profiles. Profile A's OAuth token could end up paired with profile B's cached account ID, causing wrangler to write resources to the wrong account *silently*. Fixed in 1.2.2 by per-profile `WRANGLER_CACHE_DIR`. Upgrade if you're on โค1.2.1.
## Breaking changes in 1.0
- **`-p` is now `--profile`** (was `--profiles` in 0.1.x). Use the long form `--profiles <path>` to specify the profiles directory.
- **`use` is no longer supported**. The command now exits with migration guidance. Use `default <name>` for persistence or `--profile <name>` for one-shot execution.
- **`sync-active` is deprecated**, replaced by `sync-default`. The alias still works with a warning.
- Profile names matching management subcommand names (`exec`, `default`, `whoami`, `gc`, `login`, `list`, `status`, `save`, `sync`, `sync-default`, `remove`, `use`, `sync-active`) cannot be reached via positional shorthand. Use `--profile <name>` instead.
- First-time setup of a new profile via `wrangler-accounts login <name>` no longer touches your real `~/.wrangler/config/default.toml`. All credential writes go directly into the profile directory.
## Defaults and paths
If you do not specify a config path, the CLI checks these paths and uses the first existing one:
- `~/.wrangler/config/default.toml`
- `~/Library/Preferences/.wrangler/config/default.toml`
- `~/.config/.wrangler/config/default.toml`
- `~/.config/wrangler/config/default.toml`
The profiles directory defaults to:
- `$XDG_CONFIG_HOME/wrangler-accounts` (if set)
- `~/.config/wrangler-accounts`
## Notes
- Profile names accept only letters, numbers, dot, underscore, and dash.
- Saved OAuth sessions can expire. If a profile is expired, running it will stop and tell you to run `wrangler-accounts login <name>` again.
- Legacy backups created by older `use` flows are hidden from `list` and `status` unless you pass `--include-backups`.
## FAQ
### How do I use Cloudflare Wrangler with multiple accounts?
`wrangler` itself only supports one OAuth login at a time โ running `wrangler login` overwrites `~/.wrangler/config/default.toml`, forcing you to re-login every time you switch accounts. `wrangler-accounts` saves each login as a named profile and runs `wrangler` inside a per-invocation **shadow HOME**, so different shells can use different Cloudflare accounts in parallel.
```bash
npm i -g github:leeguooooo/wrangler-accounts
wrangler-accounts login work
wrangler-accounts login personal
wrangler-accounts --profile work deploy
wrangler-accounts --profile personal tail my-worker
```
### How do I switch between Cloudflare Workers accounts without logging out?
Use `wrangler-accounts --profile <name>` for a single command, or `wrangler-accounts default <name>` to set a persistent default. Neither touches your existing `~/.wrangler/config/default.toml`; profiles live in their own directory.
### Can I run `wrangler dev` on one Cloudflare account while deploying to another?
Yes. That's the whole point of the shadow HOME isolation โ each shell gets its own temporary HOME with the profile's OAuth config, so two invocations never share state.
```bash
# terminal 1
wrangler-accounts --profile work tail my-worker --format pretty
# terminal 2
wrangler-accounts --profile personal dev
```
### How do I use Wrangler with multiple accounts in CI?
**Don't use `wrangler-accounts` in CI.** Use native env vars โ `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` โ with plain `wrangler`. That's what Cloudflare designed wrangler for; `wrangler-accounts` is a local developer convenience for juggling OAuth sessions on your workstation.
### Is this like `aws-vault` / `aws --profile` but for Cloudflare?
Yes. `wrangler-accounts` is to Cloudflare Wrangler what `aws --profile` and `aws-vault exec` are to the AWS CLI: named profiles, per-invocation isolation, subshell mode, AWS-style resolution order (`--profile` > `$WRANGLER_PROFILE` > persistent default). Unlike AWS CLI, `wrangler` has no native `--profile` flag, so `wrangler-accounts` sits in front of `wrangler` and sets up an isolated `HOME` per invocation.
### How do I know if a saved profile still works?
`wrangler-accounts list` shows a fast table with STATUS (derived from the saved `expiration_time`), but that can miss revoked refresh tokens. For an authoritative check, run:
```bash
wrangler-accounts list --deep
```
This spawns `wrangler whoami` inside each profile's shadow HOME and reports whether Cloudflare actually accepts the credentials.
### I get "Not logged in" even though I just ran `wrangler login`
If you used plain `wrangler login`, it wrote to your real `~/.wrangler/config/default.toml`. Capture that as a named profile before it gets overwritten:
```bash
wrangler-accounts save work
```
Or start fresh with `wrangler-accounts login work`, which does the OAuth flow inside an isolated shadow HOME and writes directly into the profile directory.
## Discoverability
Project: Cloudflare Wrangler multi-account manager โ save and switch between multiple Cloudflare Workers OAuth logins without re-authenticating each time.
**Search keywords**: cloudflare wrangler multi account, wrangler multiple accounts, cloudflare workers switch account, wrangler profile manager, wrangler login profiles, cloudflare account switcher, wrangler --profile, AWS-style profile for wrangler, aws-vault for cloudflare, wrangler oauth multi account, cloudflare workers different accounts, per-invocation isolation, shadow home, wrangler account management CLI.
**AI agent keywords**: agent skill, skills.sh, Claude Code skill, Cursor skill, Codex skill, Gemini CLI skill โ see "Install as an AI agent skill" above.
Related tools / alternatives:
- [AWS CLI `--profile`](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) โ same concept for AWS, natively supported
- [aws-vault](https://github.com/99designs/aws-vault) โ OAuth-safe AWS profile wrapper that inspired the `exec` design here
- [direnv](https://direnv.net/) โ directory-based env switching (orthogonal, can be combined)
## Shell completion (zsh)
```bash
mkdir -p ~/.zsh/completions
cp $(pnpm root -g)/@leeguoo/wrangler-accounts/completions/wrangler-accounts.zsh ~/.zsh/completions/_wrangler-accounts
```
Then add to your `~/.zshrc`:
```bash
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit
```