🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@hcg1023/claude-env-manager

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hcg1023/claude-env-manager

Claude Environment Manager - Manage and switch Claude Code configurations

npmnpm
Version
1.0.2
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

CEM (Claude Version Manager)

CEM 是一个命令行工具,用于管理和快速切换 Claude Code 的多个配置(baseURL 和 TOKEN)。

特性

  • 🚀 快速切换多个 Claude Code 配置
  • 🎯 直接修改 Claude Code 的 settings.json,无需手动 source
  • 🔐 安全的配置存储(文件权限 600)
  • ⚡ 立即生效,无需重启终端
  • 🎨 友好的交互式界面和彩色输出

安装

# 克隆仓库
git clone <your-repo-url>
cd cem

# 安装依赖
npm install

# 构建
npm run build

# 全局链接
npm link

使用方法

添加配置

cem add <alias>

交互式添加新配置,需要输入:

  • Base URL:Claude API 的基础 URL
  • Token:认证令牌

示例:

$ cem add work
? Enter baseURL: https://api.claude.ai
? Enter TOKEN: ********
✓ Configuration 'work' added successfully
? Switch to this configuration now? Yes

列出所有配置

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 文件中
  • 自动注入加载语句:首次使用时,在你的 shell 配置文件中添加一行加载语句
  • 跨 Shell 兼容:支持 bash、zsh、sh、ksh、fish 等多种 shell

文件结构

~/.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..."
    }
  }
}

Shell 配置注入

CEM 会在你的 shell 配置文件(如 .zshrc.bashrc 等)中添加以下内容:

# CEM
[ -f ~/.cem/env.sh ] && source ~/.cem/env.sh

命令参考

命令别名说明
cem add <alias>-添加新配置
cem lslist列出所有配置
cem show <alias>-显示配置详情
cem current-显示当前配置
cem use <alias>-切换配置
cem rm <alias>remove, delete删除配置
cem --help-h显示帮助
cem --version-V显示版本

常见问题

Q: 切换配置后环境变量没有生效?

A: 需要运行 source ~/.cem/env.sh 或重启终端。

Q: 支持哪些 Shell?

A: 支持所有 POSIX-compatible shell(bash、zsh、sh、ksh、dash)和 fish shell。

Q: 配置文件存储在哪里?

A: 存储在 ~/.cem/config.json,权限为 600(仅用户可读写)。

Q: 如何手动编辑配置?

A: 可以直接编辑 ~/.cem/config.json 文件,但建议使用 cem 命令进行管理。

Q: 能否在不同终端窗口使用不同配置?

A: 可以!运行 cem use 切换配置后,在当前终端执行 source ~/.cem/env.sh 即可。不同终端窗口可以有不同的环境变量。

开发

# 安装依赖
npm install

# 开发模式(监听文件变化)
npm run dev

# 构建
npm run build

# 代码格式化
npm run format

# 代码检查
npm run lint

许可证

MIT

Keywords

claude

FAQs

Package last updated on 31 Oct 2025

Did you know?

Socket

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.

Install

Related posts