使用说明
claude-profiles
Swap Claude Code configurations in one command
Quick Start • Commands • Auto-Switching • npm • Discussions
克劳德简介 允许您维护多个Claude Code配置并立即在它们之间切换。不同的插件、钩子、MCP服务器和不同工作流的设置——没有冲突。
npm install -g claude-profiles
一个命令。你的 ~/.claude 自动成为默认配置文件。不需要安装向导。
为什么?
Claude Code将您的所有设置、钩子、MCP服务器和插件存储在一个地方 ~/.claude 目录。这很好,直到你需要不同的设置——工作与个人、不同的客户端、生产仓库的严格权限与副项目的宽松权限。插件如 超级克劳德 和 ClaudeKit 的 修改相同的全局配置。你不应该选择。
| 无配置文件 | 有配置文件 |
|---|---|
一个 ~/.claude 配置一切 |
多个配置,立即切换 |
| 到处都是相同的插件,即使你不需要它们 | 根据配置文件切换插件 |
| 切换工作流时手动备份/还原 | claude-profiles use work |
| 不同客户端的不同MCP服务器?手动编辑 | 一个切换命令 |
| 无法为每个项目自动切换 | .claude-profile 每个仓库的文件(如 .nvmrc) |
快速开始
# Install (that's it — shell hook + slash commands auto-configured)
npm install -g claude-profiles
# Create a work profile
claude-profiles create work
# Switch to it
claude-profiles use work
# >>> RESTART CLAUDE CODE <<<
# Switch back to default
claude-profiles use default
运作原理
你的 ~/.claude 是 默认 个人资料——未被触碰,始终存在。新配置文件是存储在中的克隆 ~/.claude-profiles/saved/<name>/.切换直接在内部交换配置文件 ~/.claude --没有环境变量,没有符号链接。
~/.claude/ <-- always the active config (files get swapped in/out)
~/.claude-profiles/
├── state.json <-- which profile is active
└── saved/
├── default/ <-- default profile backup
└── work/ <-- work profile config (restored to ~/.claude on switch)
├── settings.json <-- different plugins, hooks, permissions
├── mcp.json <-- different MCP servers
└── CLAUDE.md <-- different instructions
状态行
非默认配置文件在Claude Code状态行中显示其名称:
work | Opus 4.6 (1M context) | ctx 9% | $5.2030 | 1h 4m
命令
claude-profiles create <name> # Create profile (clones ~/.claude)
claude-profiles use <name> # Switch profile
claude-profiles list # List all profiles (* = active)
claude-profiles current # Show active profile
claude-profiles delete <name> # Delete a profile
claude-profiles toggle plugin <name> on|off # Toggle plugin per profile
claude-profiles init # Guided setup (optional)
claude-profiles uninstall # Clean removal
克劳德代码内部
这些斜线命令直接在Claude Code会话中工作:
/profiles # List profiles + show available commands
/profiles-list # List all profiles (* = active)
/profiles-use <name> # Switch profile
/profiles-create <name> - <description> # Create a new profile
/profiles-current # Show active profile
/profiles-delete <name> # Delete a profile
/profiles-configure # Toggle plugins in the active profile
无需离开Claude代码——内置的钩子会立即执行命令并显示结果。
示例:工作vs个人
# Create separate profiles
claude-profiles create work -d "Work — Vercel + Jira MCP servers"
claude-profiles create personal -d "Personal — minimal plugins"
# Configure each profile
claude-profiles use work
# >>> RESTART CLAUDE CODE <<<
# Set up work MCP servers, plugins, permissions...
claude-profiles use personal
# >>> RESTART CLAUDE CODE <<<
# Different plugins, no work MCP servers...
# Switch between them anytime
claude-profiles use work # back to work setup
claude-profiles use default # back to your original config
每个配置文件都有自己的 settings.json, mcp.json, CLAUDE.md, commands/,以及 hooks/切换会原子性地交换它们。
按项目自动切换
添加a .claude-profile 文件到任何仓库:
echo "work" > .claude-profile
当你 cd 在该目录中,shell钩子会自动切换。Leave--恢复默认值。
喜欢 .nvmrc 适用于Node.js版本,但适用于Claude Code配置。
分辨率链
CLAUDE_PROFILES_ACTIVEenv-var(最高优先级).claude-profile文件(沿目录树向上移动)- 活动配置文件来自
state.json - 退路:
default(~/.claude)
安装/卸载
# Install — one command, everything configured
npm install -g claude-profiles
# Uninstall — asks which profile to keep, cleans everything
claude-profiles uninstall
npm uninstall -g claude-profiles
自动安装:
- 增加
/profiles-*Claude代码的斜线命令 - 安装外壳挂钩
.zshrc/.bashrc/config.fish(自动打开cd) - 注册一个快速执行钩子(因此
/profiles-list在1秒内响应) - 为添加自动批准权限
claude-profiles命令
卸载会删除上述所有内容。 ~/.claude 永远不会被修改。
What profiles isolate
每个配置文件都有自己的:
settings.json--插件、钩子、权限、模型首选项mcp.json--MCP服务器配置CLAUDE.md--自定义说明commands/--斜线命令settings.local.json--本地覆盖
在所有配置文件中共享:
- 插件缓存(下载的文件)
- 项目/会话数据
- 身份验证凭据
- 自动内存(中的每个项目
~/.claude/projects/,不按配置文件)
Shell integration details
shell钩子在安装时使用conda风格的哨兵注释自动添加:
# >>> claude-profiles >>>
# !! Contents within this block are managed by claude-profiles !!
_claude_profiles_hook() { ... }
# <<< claude-profiles <<<
支持 Z shell, bash,以及 鱼。自动检测您的外壳。卸载时已完全删除。
要手动添加,请执行以下操作: eval "$(claude-profiles shell-init)"
Design influences
- Python 版本管理器 --解析链(环境变量>文件>默认值)
- direnv --自动开启
cd - 非易失性存储器 —
.nvmrc惯例 - 康达 --shell配置的哨兵注释
- Codex CLI --配置文件覆盖
相关
- GitHub问题#7075 --对原生Claude Code配置文件的功能请求
- Codex CLI配置文件 --OpenAI的方法
贡献
看 贡献.md.PR欢迎。
许可证
麻省理工学院
