@chunhuizk/ch-code-cli
v1.9.0
Published
CH Code CLI - Internal system authentication tool
Readme
@chunhuizk/ch-code-cli
Internal CLI tool (chcode) for workspace members to authenticate and configure Claude Code with their corporate account.
After a successful OIDC login, the CLI provisions a LiteLLM API key and automatically configures Claude Code so you can use it through your organization's account. The API key expires every 2 weeks, so you will need to run chcode login again to refresh it.
Requirements
- Node.js ≥ 18
- Access to your organization's workspace (login permission required)
Installation
npm install -g @chunhuizk/ch-code-cliOr build from source:
pnpm install
pnpm buildThe chcode binary is output to dist/index.js.
Usage
First-Time Setup
Before your first login, you must provide your organization's OIDC issuer URL:
chcode login --issuer https://auth.example.comThe issuer URL will be saved to your local configuration, so subsequent logins only require chcode login.
Alternatively, you can set it via the config command first:
chcode config set issuer https://auth.example.comLogin
Authenticate via OIDC and provision an API key for Claude Code:
chcode login # interactive OIDC login
chcode login --force # force re-login even if session is activeAfter login, Claude Code will be configured automatically — no extra steps needed.
Status
Check your current session and API key status (including expiration):
chcode statusConfig
View or update CLI configuration:
chcode configLogout
Clear stored tokens and API key:
chcode logoutHow It Works
chcode loginopens your browser for OIDC authentication (with PKCE).- Upon successful login, a LiteLLM API key is provisioned.
- The API key is stored securely in your system keychain and configured for Claude Code.
- The key is valid for 2 weeks. After expiration, run
chcode loginagain.
Development
pnpm dev # build in watch mode
pnpm typecheck # type-check without emitting
pnpm test # run tests
pnpm test:watch # run tests in watch modeLicense
UNLICENSED — Internal use only.
@chunhuizk/ch-code-cli(中文说明)
内部 CLI 工具(chcode),供工作区成员认证并配置 Claude Code,使用公司账户进行访问。
成功通过 OIDC 登录后,CLI 会自动生成 LiteLLM API 密钥,并配置 Claude Code,让你可以通过公司账户使用 Claude Code。API 密钥每 2 周过期一次,届时需要重新执行 chcode login 刷新密钥。
环境要求
- Node.js ≥ 18
- 拥有组织工作区的登录权限
安装
npm install -g @chunhuizk/ch-code-cli或从源码构建:
pnpm install
pnpm build构建产物为 dist/index.js。
使用方法
首次设置
首次登录前,需要提供组织的 OIDC 签发者(issuer)URL:
chcode login --issuer https://auth.example.com签发者 URL 会保存到本地配置中,之后登录只需执行 chcode login 即可。
也可以先通过配置命令设置:
chcode config set issuer https://auth.example.com登录
通过 OIDC 认证并生成 Claude Code API 密钥:
chcode login # 交互式 OIDC 登录
chcode login --force # 强制重新登录(即使会话仍有效)登录成功后,Claude Code 会自动完成配置,无需额外操作。
查看状态
查看当前会话和 API 密钥状态(包括过期时间):
chcode status配置
查看或修改 CLI 配置:
chcode config登出
清除已存储的令牌和 API 密钥:
chcode logout工作原理
chcode login打开浏览器进行 OIDC 认证(使用 PKCE)。- 登录成功后,自动生成 LiteLLM API 密钥。
- 密钥安全存储在系统钥匙串中,并自动配置 Claude Code。
- 密钥有效期为 2 周,过期后需重新执行
chcode login。
开发
pnpm dev # 监听模式构建
pnpm typecheck # 类型检查(不输出文件)
pnpm test # 运行测试
pnpm test:watch # 监听模式运行测试许可证
UNLICENSED — 仅供内部使用。
