agent-shim
A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling — precisely, and per working directory — what gets shared between them.

The problem
Claude Code keeps everything it knows in one place: ~/.claude. Skills, memory, conventions, but also every conversation transcript, session file, and task list you've ever produced, across every project you've ever touched. If you want a second login (a personal account alongside a work one, say) or you want to keep one client's work cleanly separated from another's, there's no built-in way to say "share the skills and conventions, but not the history" — it's all one directory, all or nothing.
agent-shim solves this with two independent things:
- An identity is a login. It's the thing that owns credentials and daemon state, and it's what you switch between with
claude @work or claude @personal.
- A configuration profile is a reusable, named bundle of sharing rules — what's visible, what isn't. It exists independently of any identity, and which one applies can depend entirely on which directory you're working in.
Keeping these separate matters because they answer different questions. "Which login am I using?" and "What should this login see right now?" don't have to have the same answer every time, and forcing them to share one concept (as most ad hoc setups do) means you can't express "one login, several different sharing postures depending on where I am" — which turns out to be the common case.
Install
curl -fsSL https://github.com/ExaDev/agent-shim/releases/latest/download/install.sh | sh
This installs agent-shim alone into ~/.local/bin; your existing claude command is left untouched. agent-shim run [args...] reaches the same identity-resolve, farm-resync, spawn pipeline a claude-named binary would, so every feature already works with no further setup. Run agent-shim shim enable once for the shorter claude @<name> form (shim disable reverses it).
Also available: npm (npm install -g agent-shim, needs Node 22.18 or later, or 24 and above), Homebrew (brew install ExaDev/agent-shim/agent-shim), Scoop on Windows, a scoped GitHub Packages alias, and installing straight from the git repository with no registry at all. Each channel's exact commands, the platform support matrix, and the one architecture (macOS x64) that needs a different install path are in docs/installation.md.
Renamed from claude-use
agent-shim was called claude-use until it was renamed. Everything written for the old name keeps working, and agent-shim doctor lists what still uses it:
- The
claude-use command is installed beside agent-shim by every channel and runs the same program.
CLAUDE_USE_* environment variables are read wherever AGENT_SHIM_* is; the current name wins when both are set.
- An existing
~/.claude-use is used in place when there is no ~/.agent-shim. Do not move it: macOS Claude Code keys each identity's Keychain login on the exact path of its configuration directory (<root>/identities/<id>), so relocating the root signs every identity out. A fresh installation uses ~/.agent-shim.
- A committed
.claude-use.json or .claude-use.local.json is read when the directory has no .agent-shim.json or .agent-shim.local.json; configure keeps writing into the legacy local file while it is the only one.
- A farm manifest written under the old name is read, and replaced by the current one on the next resync.
- A session launched by a release under the old name keeps working against a newer front door: its internal
x-claude-use-* request headers are accepted as their x-agent-shim-* equivalents and never forwarded upstream.
- npm:
claude-use is still published, identical to agent-shim and exposing both commands, so npm install -g claude-use keeps tracking releases. Homebrew moves an installed claude-use formula to agent-shim on upgrade.
Quick start
agent-shim identity add personal # create your first identity (a fresh login)
agent-shim run @personal # log in and start using it
Want the shorter claude @personal instead? Run agent-shim shim enable once — see Install.
That's it — with no further configuration, everything in ~/.claude that isn't credentials or daemon runtime is classified into categories (see below) and shared according to sensible defaults. Add a second identity, add configuration profiles, and add directory rules only once you actually need more control than that.
Codex CLI
Create a separate Codex identity and launch the installed Codex CLI:
agent-shim identity add codex-work --agent codex
agent-shim run --agent codex @codex-work login
agent-shim run --agent codex @codex-work
Each Codex identity gets its own CODEX_HOME, credentials and databases, with Codex-specific sharing rules over ~/.codex. Native flags and subcommands are forwarded to Codex. See docs/codex-cli.md for selection, sharing, configuration and supported integrations.
Concepts
agent-shim separates two things most ad hoc multi-account setups conflate:
- An identity is a login: the thing that owns credentials and daemon state, selected with
agent-shim run @<name> or, once agent-shim shim enable has run, claude @<name>. Its name is the name in its identity.json; its directory is named by an id fixed when it is created, so identity rename changes the name and every reference to it without moving the directory, the login or the usage, while sessions keep running on it. See docs/configuration-model.md.
- A configuration profile is a reusable, named bundle of sharing rules, independent of any identity, resolved per working directory via directory rules or a committed
.agent-shim.json.
A third, optional thing sits on top of identities: a pool is a named list of them. Select pool:<name> where an identity name goes (claude @pool:subs) and agent-shim picks the member whose unused quota is closest to expiring, skipping any that are refused right now, using the usage it already records. A pool can instead declare --preference listed, which tries the members in the order the pool lists them, skipping only one that is refused right now. A member entry may itself name another pool (pool:<name>), which is ranked with its own policy and contributes its pick at that position, so "this identity first, then the fleet" nests the fleet rather than copying its member list; cycles are refused. Members that hold the same login (the same account in the same organisation) share one quota window, so a pool ranks them as one candidate and never fails over from one to the other; pool add, pool set and doctor warn when a pool lists two of them. See docs/configuration-model.md. On a terminal, agent-shim run asks which identity to run as when none resolves, when a pool pick would change account, or when the identity is refused right now (--pick forces the question, --no-pick never asks); see docs/configuration-model.md.
Every top-level entry in ~/.claude is classified into one of five categories, shipped as a default map (config/categories.default.json):
| Category |
Default shared? |
Example entries |
secret |
Never — hardcoded, cannot be overridden by any configuration layer |
.credentials.json, backups, settings.json.bak* |
runtime |
No |
daemon*, .git*, .DS_Store, mcp-needs-auth-cache.json, codex-quota.json, file-transfers, shell-snapshots, statsig, telemetry, stats-cache.json, usage-data, ide, cache, scheduled_tasks.lock, policy-limits.json*, remote-settings.json*, state |
history |
Yes |
projects, sessions, session-env, teams, tasks, todos, history.jsonl, transcripts, paste-cache, file-history, plans, workflows, jobs, debug, downloads, chrome |
knowledge |
Yes |
skills, agents, rules, memory, commands, plugins, hooks, AGENTS.md, CLAUDE.md, README.md |
settings |
Yes |
settings.json, settings.local.json |
Sharing composes through a cascade (shipped defaults, then a user-global override, then the active configuration profile, then directory rules for $PWD, shallowest to deepest); a specific path override always outranks a category default regardless of which layer set it. A committed .agent-shim.json at a project's root makes this portable: anyone who clones the repo and runs claude inside it gets the same isolation rules with no local setup.
claude refuses to launch while ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, CLAUDE_CODE_OAUTH_TOKEN or a CLAUDE_CODE_USE_BEDROCK/VERTEX/FOUNDRY variable is set in the environment, because those outrank every identity's stored credential and would make all identities authenticate as the same account. Opt in deliberately with AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1 for one launch or agent-shim identity set <name> --allow-ambient-credential.
Providers and identities take their token from one credential block: an ordered list of sources (env, file, command, and the op and keychain presets, plus a literal placeholder for a local proxy), tried in turn, and a target (bearer, apiKey, or oauthToken for an identity). An identity's token reaches the child's environment only; a provider's never reaches the child at all (the front door attaches it at the provider's route, which is also what lets provider inference and Remote Control share one session). check, doctor and --json report the source kind and target, never the value.
The full mechanics, including the credential block, the merge algorithm, conditional sharing rules (age, size, git branch, environment), the ambient-credential launch guard, and how ~/.claude/projects/ history is pattern-matched, are in docs/configuration-model.md. Worked examples are in docs/examples.md.
CLI reference
Every command is agent-shim <noun> <verb> [name] [options], over the nouns identity, profile, pool, provider, model, route, rule and job, plus the top-level run, configure, check, doctor, usage, update and the others; claude @<identity> is the same as agent-shim run @<identity> once agent-shim shim enable has run. The full list of commands with every flag is in docs/cli-reference.md, and agent-shim --help and agent-shim <noun> --help print it from the installed version.
Every list, show, check, doctor and headroom status prints text by default and JSON with --json, and so do the mutating commands (add, set, remove and use on identities, profiles, providers, pools, routes and rules), which print one object naming the action, the kind, the name and, for a creation or update, the stored value; route remove also names each key it took as removed. identity rename prints its report of what it rewrote (and with --move moved) as the value, with the action planned under --dry-run. Prompts appear only when standard input is a terminal; without one, a command that needs input fails with the option that supplies it (a remove needs --yes). Failures print as agent-shim: <message> and exit 1, usage errors exit 2, a selected provider or identity whose credential block yields no token exits 64, and AGENT_SHIM_DEBUG=1 adds stack traces to unexpected errors. agent-shim completion <bash|zsh|fish> prints a shell completion script.
agent-shim check [path]