Cross-platform CLI for switching Claude and Codex API profiles.
Project description
agentkeyswitch
agentkeyswitch is a cross-platform CLI for switching API profiles used by local AI agents such as Claude Code and Codex.
It keeps your reusable profiles in one local store and applies them to the real config files only when you run a switch command.
Current scope
- Supported platforms:
- Linux
- Windows
- Supported agents:
claudecodex
- Supported commands:
agswitch listagswitch statusagswitch add <profile>agswitch import <profile>agswitch import-existingagswitch use <agent> <profile>agswitch remove <profile>agswitch help [command]
Install
pip install agentkeyswitch
For local development:
pip install -e .
Profile store
Profiles are stored at:
Linux: ~/.config/agentkeyswitch/profiles.json
Windows: %APPDATA%\agentkeyswitch\profiles.json
You can override the runtime locations with environment variables:
AGSWITCH_HOMEAGSWITCH_STOREXDG_CONFIG_HOMEAPPDATA
This is mainly useful for testing or migration.
Examples
Add a profile interactively:
agswitch add max
Add a profile non-interactively:
agswitch add CCC \
--agent all \
--claude-token 'xxx' \
--claude-base-url 'https://CCCai.online/v1' \
--claude-model 'opus' \
--codex-key 'xxx' \
--codex-base-url 'https://CCCai.online/v1' \
--codex-provider 'CCC'
Import the current live configs into a reusable profile:
agswitch import max --agent all
Batch import your existing named files:
agswitch import-existing
Batch import when your filenames use another separator:
agswitch import-existing --separator "_"
Also include the current live config as current:
agswitch import-existing --include-current
Switch Claude only:
agswitch use claude max
Switch both Claude and Codex:
agswitch use all CCC
Check current live status:
agswitch status
Show detailed help:
agswitch help
agswitch help use
Output style
agswitch list now prints profiles as readable blocks instead of one compressed line:
Stored Profiles (3)
-------------------
- AAA
claude yes (token: AAA-...oken)
codex no
- BBB
claude no
codex yes (key: BBB...-key)
- CCC
claude yes (token: CCC...oken)
codex yes (key: CCC...-key)
agswitch status uses the same block style:
Live Status
-----------
- claude
profile CCC
base_url https://CCCai.online/v1
token CCC...oken
model opus
paths 1
/home/you/.claude/settings.json
- codex
profile CCC
base_url https://CCCai.online/v1
api_key CCC...-key
provider CCC
wire_api responses
paths 2
/home/you/.codex/auth.json
/home/you/.codex/config.toml
agswitch import-existing also shows imported items in the same format:
Imported Profiles (2)
---------------------
- max
agents claude
- CCC
agents claude, codex
agswitch use all CCC will print the applied profile and backup files:
Applied Profile
---------------
profile CCC
agent all
- claude
backups 1
/home/you/.config/agentkeyswitch/backups/.../settings.json
- codex
backups 2
/home/you/.config/agentkeyswitch/backups/.../auth.json
/home/you/.config/agentkeyswitch/backups/.../config.toml
What gets changed
claude
~/.claude/settings.json
codex
~/.codex/auth.json~/.codex/config.toml
Named files discovered by import-existing
Default naming rule:
- Claude:
~/.claude/settings - <profile>.json - Codex:
~/.codex/auth - <profile>.json
That means these files:
~/.claude/settings - max.json~/.codex/auth - max.json
will be imported as the same profile: max
If you use a different separator, pass it explicitly:
agswitch import-existing --separator "_":- Claude:
~/.claude/settings_<profile>.json - Codex:
~/.codex/auth_<profile>.json
- Claude:
agswitch import-existing --separator "-":- Claude:
~/.claude/settings-<profile>.json - Codex:
~/.codex/auth-<profile>.json
- Claude:
Import behavior:
- If only Claude exists for a profile name, the stored profile gets only a
claudesection. - If only Codex exists for a profile name, the stored profile gets only a
codexsection. - If both exist with the same profile name, they are merged into one stored profile.
--include-currentwill additionally import the currently active live config as profilecurrent.--overwriteallows replacing already stored sections with newly imported ones.
The tool updates only the necessary fields and keeps unrelated settings intact. Before writing, it creates timestamped backups under:
Linux: ~/.config/agentkeyswitch/backups/
Windows: %APPDATA%\agentkeyswitch\backups\
Notes
- Secrets are not bundled with the package.
- The package is designed so you can publish the code without publishing your tokens.
- For Codex, the tool updates both
auth.jsonandconfig.tomlso provider selection remains consistent.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentkeyswitch-0.4.0.tar.gz.
File metadata
- Download URL: agentkeyswitch-0.4.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21aeadac80807cda6435976b7ba49900ee642e37c29c6034c68e4092718579a
|
|
| MD5 |
27538a76eb89f8a811536ff9a33e6a77
|
|
| BLAKE2b-256 |
f6a210eac15b1b9d85c1c10a0daa803967d0a9f7b4e38467d1e7c1b03f0fea08
|
File details
Details for the file agentkeyswitch-0.4.0-py3-none-any.whl.
File metadata
- Download URL: agentkeyswitch-0.4.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
984067dc3316b95b16e2c8d25a8dbd0eff5e4d7a6b5e282bcd4ed6a593331e7b
|
|
| MD5 |
c8b1d61b2e9fd6f9b0b25541f05a49c3
|
|
| BLAKE2b-256 |
0dae1af167755437b7a79062bcf2c884f44b5a56e62a99a11f3e95cce307a238
|