
Security News
Scaling Socket from Zero to 10,000+ Organizations
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.
@hcg1023/claude-env-manager
Advanced tools
Claude Environment Manager - Manage and switch Claude Code configurations
CEM 是一个命令行工具,用于管理和快速切换 Claude Code 的多个配置(baseURL 和 TOKEN)。
# 克隆仓库
git clone <your-repo-url>
cd cem
# 安装依赖
npm install
# 构建
npm run build
# 全局链接
npm link
cem add <alias>
交互式添加新配置,需要输入:
示例:
$ cem add work
? Enter baseURL: https://api.claude.ai
? Enter TOKEN: ********
✓ Configuration 'work' added successfully
? Switch to this configuration now? Yes
cem import <json> --alias <alias>
从 JSON 格式的配置导入。支持灵活的字段名:
baseURL 或 ANTHROPIC_BASE_URLtoken 或 ANTHROPIC_AUTH_TOKEN示例:
# 使用 ANTHROPIC 字段名
cem import '{"ANTHROPIC_BASE_URL":"https://api.anthropic.com","ANTHROPIC_AUTH_TOKEN":"sk-ant-xxx"}' --alias prod
# 包含自定义变量
cem import '{
"ANTHROPIC_BASE_URL": "https://api.anthropic.com",
"ANTHROPIC_AUTH_TOKEN": "sk-ant-xxx",
"ANTHROPIC_VERSION": "2023-06-01",
"DEBUG": "true"
}' --alias dev
# 交互式模式(不提供 JSON 参数)
cem import
cem ls
# 或
cem list
以表格形式显示所有配置:
┌──────────┬───────────────────────────┬─────────┐
│ Alias │ Base URL │ Current │
├──────────┼───────────────────────────┼─────────┤
│ default │ https://api.claude.ai │ ✓ │
│ work │ https://work.claude.ai │ │
└──────────┴───────────────────────────┴─────────┘
cem show <alias>
示例:
$ cem show work
Configuration: work
──────────────────────────────────────────────────
Base URL: https://work.claude.ai
Token: sk-xxx...******
Status: Active
cem current
显示当前激活的配置信息。
cem use <alias>
切换到指定的配置。首次使用时会自动在你的 shell 配置文件中注入加载语句。
示例:
$ cem use work
✓ Switched to configuration 'work'
✓ Claude settings: /Users/username/.claude/settings.json
Configuration will take effect immediately for new Claude Code sessions
cem rm <alias>
# 或
cem remove <alias>
cem delete <alias>
删除指定配置(需确认)。注意:不能删除当前正在使用的配置。
CEM 使用独立环境文件方案,具有以下特点:
~/.cem/env.sh 文件中~/.cem/
├── config.json # 配置管理文件
└── env.sh # 环境变量文件
~/.cem/config.json:
{
"version": "1.0.0",
"current": "work",
"configs": {
"default": {
"baseURL": "https://api.claude.ai",
"token": "sk-xxx..."
},
"work": {
"baseURL": "https://work.claude.ai",
"token": "sk-yyy..."
}
}
}
CEM 会在你的 shell 配置文件(如 .zshrc、.bashrc 等)中添加以下内容:
# CEM
[ -f ~/.cem/env.sh ] && source ~/.cem/env.sh
| 命令 | 别名 | 说明 |
|---|---|---|
cem add <alias> | - | 添加新配置(交互式) |
cem import <json> | - | 从 JSON 导入配置 |
cem ls | list | 列出所有配置 |
cem show <alias> | - | 显示配置详情 |
cem current | - | 显示当前配置 |
cem use <alias> | - | 切换配置 |
cem rm <alias> | remove, delete | 删除配置 |
cem edit <alias> | - | 编辑配置 |
cem local | - | 设置或显示语言 |
cem --help | -h | 显示帮助 |
cem --version | -V | 显示版本 |
A: 使用 cem import 命令从 JSON 格式导入配置。适合从其他工具迁移或备份恢复。
示例:
cem import '{"ANTHROPIC_BASE_URL":"https://api.anthropic.com","ANTHROPIC_AUTH_TOKEN":"sk-ant-xxx"}' --alias prod
A: 支持灵活的字段名:
baseURL 或 ANTHROPIC_BASE_URLtoken 或 ANTHROPIC_AUTH_TOKENANTHROPIC_VERSION 等)A: 需要运行 source ~/.cem/env.sh 或重启终端。
A: 支持所有 POSIX-compatible shell(bash、zsh、sh、ksh、dash)和 fish shell。
A: 存储在 ~/.cem/config.json,权限为 600(仅用户可读写)。
A: 可以直接编辑 ~/.cem/config.json 文件,但建议使用 cem 命令进行管理。
A: 可以!运行 cem use 切换配置后,在当前终端执行 source ~/.cem/env.sh 即可。不同终端窗口可以有不同的环境变量。
# 安装依赖
npm install
# 开发模式(监听文件变化)
npm run dev
# 构建
npm run build
# 代码格式化
npm run format
# 代码检查
npm run lint
MIT
FAQs
Claude Environment Manager - Manage and switch Claude Code configurations
We found that @hcg1023/claude-env-manager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.

Research
Socket Threat Research maps a rare inside look at OtterCookie’s npm-Vercel-GitHub chain, adding 197 malicious packages and evidence of North Korean operators.

Research
Socket researchers identified a malicious Chrome extension that manipulates Raydium swaps to inject an undisclosed SOL transfer, quietly routing fees to an attacker wallet.