configuring
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConfiguring
Configuring工具配置指南
Unified configuration management across AI coding environments. Load environment variables, secrets, and other opinionated configuration setups from any AI coding platform.
跨AI编码环境的统一配置管理。可从任意AI编码平台加载环境变量、密钥以及其他定制化配置。
Quick Start
快速开始
python
import sys
sys.path.insert(0, '/path/to/claude-skills') # or wherever skills are installed
from configuring import get_env, detect_environmentpython
import sys
sys.path.insert(0, '/path/to/claude-skills') # 或技能安装的其他路径
from configuring import get_env, detect_environmentGet a variable (searches all sources automatically)
获取变量(自动搜索所有来源)
token = get_env("TURSO_TOKEN", required=True)
token = get_env("TURSO_TOKEN", required=True)
With default
带默认值
port = get_env("PORT", default="8080")
port = get_env("PORT", default="8080")
What environment are we in?
检测当前运行环境
env = detect_environment() # "claude.ai", "claude-code-desktop", "codex", "jules", etc.
undefinedenv = detect_environment() # 返回 "claude.ai", "claude-code-desktop", "codex", "jules" 等
undefinedSupported Environments
支持的环境
| Environment | Config Sources |
|---|---|
| Claude.ai Projects | |
| Claude Code | |
| OpenAI Codex | |
| Jules | Environment settings UI, |
| Universal | |
| 环境 | 配置来源 |
|---|---|
| Claude.ai Projects | |
| Claude Code | |
| OpenAI Codex | |
| Jules | 环境设置UI, 仓库中的 |
| 通用环境 | |
API Reference
API参考
python
undefinedpython
undefinedCore
核心方法
get_env(key, default=None, *, required=False, validator=None) -> str | None
load_env(path) -> dict[str, str] # Load specific file
load_all(force_reload=False) -> dict # Load all sources
get_env(key, default=None, *, required=False, validator=None) -> str | None
load_env(path) -> dict[str, str] # 加载指定文件
load_all(force_reload=False) -> dict # 加载所有来源
Utilities
工具方法
detect_environment() -> str # Current platform
mask_secret(value, show_chars=4) -> str # Safe logging
debug_info() -> dict # Troubleshooting
get_loaded_sources() -> list[str] # What was checked
undefineddetect_environment() -> str # 当前运行平台
mask_secret(value, show_chars=4) -> str # 安全日志输出(隐藏密钥)
debug_info() -> dict # 故障排查信息
get_loaded_sources() -> list[str] # 已检查的配置来源
undefinedCredential File Formats
凭证文件格式
.envTURSO_TOKEN=eyJhbGciOiJFZERTQSI...
EMBEDDING_API_KEY=sk-svcacct-...Single-value files (, ):
*-token.txt*-key.txteyJhbGciOiJFZERTQSI...Filename becomes key: →
turso-token.txtTURSO_TOKENClaude Code settings.json:
json
{
"env": {
"TURSO_TOKEN": "eyJhbGciOiJFZERTQSI..."
}
}.envTURSO_TOKEN=eyJhbGciOiJFZERTQSI...
EMBEDDING_API_KEY=sk-svcacct-...单值文件(, 格式):
*-token.txt*-key.txteyJhbGciOiJFZERTQSI...文件名会作为键名:例如 →
turso-token.txtTURSO_TOKENClaude Code settings.json格式:
json
{
"env": {
"TURSO_TOKEN": "eyJhbGciOiJFZERTQSI..."
}
}Priority Order
加载优先级
Later sources override earlier:
- OS environment variables
- Platform-specific sources (detected automatically)
- files in cwd
.env - OS environment variables (again - explicit exports always win)
后续来源的配置会覆盖之前的:
- 系统环境变量
- 平台专属配置来源(自动检测)
- 当前目录下的文件
.env - 系统环境变量(再次生效 - 显式导出的配置始终优先级最高)
Debugging
调试
python
import sys
sys.path.insert(0, '/path/to/claude-skills')
from configuring import debug_info
print(debug_info())python
import sys
sys.path.insert(0, '/path/to/claude-skills')
from configuring import debug_info
print(debug_info()){'environment': 'claude.ai', 'sources': ['os.environ', 'claude.ai:/mnt/project/'], ...}
返回结果示例: {'environment': 'claude.ai', 'sources': ['os.environ', 'claude.ai:/mnt/project/'], ...}
CLI:
```bash
cd /path/to/claude-skills/configuring
python scripts/getting_env.py # Show debug info
python scripts/getting_env.py TURSO_TOKEN # Get specific key
命令行工具:
```bash
cd /path/to/claude-skills/configuring
python scripts/getting_env.py # 显示调试信息
python scripts/getting_env.py TURSO_TOKEN # 获取指定键的值Migration from api-credentials / getting-env
从api-credentials/getting-env迁移
Replace:
python
undefined替换旧代码:
python
undefinedOld (api-credentials)
旧代码(api-credentials)
from credentials import get_anthropic_api_key
key = get_anthropic_api_key()
from credentials import get_anthropic_api_key
key = get_anthropic_api_key()
Old (getting-env)
旧代码(getting-env)
from getting_env import get_env
key = get_env("ANTHROPIC_API_KEY")
from getting_env import get_env
key = get_env("ANTHROPIC_API_KEY")
New (configuring)
新代码(configuring)
import sys
sys.path.insert(0, '/path/to/claude-skills')
from configuring import get_env
key = get_env("ANTHROPIC_API_KEY", required=True)
undefinedimport sys
sys.path.insert(0, '/path/to/claude-skills')
from configuring import get_env
key = get_env("ANTHROPIC_API_KEY", required=True)
undefined