Home / All Skills / Workflow & Core Tools / claude-switch-models-setup
Workflow & Core Tools · daymade/claude-code-skills

claude-switch-models-setup

Set up and maintain multiple isolated Claude Code CLI profiles so students and power users can run different LLM providers (Kimi K3, Kimi K2.7 highspeed, MiniMax M3, MiniMax M2.7, GLM, DeepSeek, StepFun, Anthropic) in separate terminal windows at the same time. Use this skill whenever the user asks about multi-provider Claude setup, multiple Claude Code windows, switching models or the csk/csd/csg aliases, CLAUDE_CONFIG_DIR, the ~/.claude-profiles directory, or running Kimi/MiniMax/GLM/DeepSeek/StepFun alongside Anthropic. It also owns profile-drift troubleshooting — a third-party profile missing skills/hooks/plugins the default profile has, claude-profiles-doctor reporting a real directory where a symlink belongs, or settings not converging — and per-provider context-window configuration (the [1m] marker or explicit CLAUDE_CODE_MAX_CONTEXT_TOKENS).

L4 High-Privilege · Graded auth & full auditV1 Commit-PinnedExecute CommandNetwork AccessWrite FileDual-pass Audit
Author daymadeGitHub daymade/claude-code-skills ↗Stars 1385License MIT(仓库根 LICENSE:Copyright (c) 2025 daymade;GitHub API spdx MIT)Commit d5c4678cb5
Control levels describe skill capabilities and suggested control measures; they do not represent quality or safety certifications, nor do they dictate usability. Usage decisions rest entirely with users and administrators. Different agent hosts apply varying constraints; do not assume hosts provide automatic protection. Third-party skill copyrights belong to their original authors. Use at your own risk.

1How It Works & Mechanism

Implement process-level isolation using CLAUDE_CONFIG_DIR: each provider has a ~/.claude-profiles/<name>/ directory and an independent .claude.json (credentials and session history), while shared directories (skills/projects/hooks/agents/plugins content) are symlinked back to ~/.claude, enabling multiple windows to run different providers concurrently without configuration cross-contamination.

daymade-claude-code/claude-switch-models-setup/SKILL.md
The result: you can open one terminal with Kimi, another with DeepSeek, another with Anthropic — each running as a fully independent Claude Code process, without configuration bleed.
Launching is handled by claude-profile in claude-profiles.sh: CLAUDE_CONFIG_DIR=profile directory + claude --settings <provider>.json, where provider routing env is supplied by ~/.claude/settings/<name>.json.

Enforce 'convergence from default profile' at the settings.json layer: sync-profile-settings.py is registered as a SessionStart hook to copy keys from the default profile's settings.json into each third-party profile (preserving identity keys such as model/advisorModel and provider routing env without overwriting), resolving hook, marketplace, and env drift across third-party windows.

daymade-claude-code/claude-switch-models-setup/scripts/sync-profile-settings.py
Two denylists define the identity boundary — these are NEVER synced:
Docstrings document verified production metrics: 9/9 profiles had zero hooks and 7/9 had zero marketplaces; ENV_KEY_DENYLIST includes ANTHROPIC_* prefixes + isolation flags like CLAUDE_CODE_SUBAGENT_MODEL.

Apply allowlist convergence + three-category guardrails for .claude.json behavioral keys: synchronize a select few behavioral keys like workflowSizeGuideline, permanently exclude state/credential/identity keys (oauthAccount/userID/token/secret…) from syncing, and report gray keys without automatically writing them—preventing session state or account identity from one profile leaking into another.

daymade-claude-code/claude-switch-models-setup/scripts/sync-profile-settings.py
State keys (is_state_key(): prefixes/substrings/exact names) — per- profile runtime state, caches, counters, migration flags, identity and credentials. NEVER synced
Empirical motivation (SKILL body): on 2026-08-17, workflowSizeGuideline:small was only present in the primary profile, causing a Kimi session to fan out a Dynamic Workflow to 30+ agents.

Special handling for plugin state: known_marketplaces.json must be per-profile (Claude validates installLocation via path.resolve() without dereferencing symlinks, causing other profiles to report 'corrupted installLocation' if shared), while claude-plugins-sync.py rebuilds the per-profile directory structure for each profile and mirrors enabledPlugins.

daymade-claude-code/claude-switch-models-setup/scripts/claude-plugins-sync.py
Each profile runs with its own CLAUDE_CONFIG_DIR, so `c` is a DIFFERENT literal string per profile
The script docstrings explain why sharing the entire plugins/ via symlinks fails (last-writer-wins) and describe the per-profile remediation structure.

Maintainer-dedicated local source sync: sync-local-skill-sources.py symlinks local skill source repositories into the Claude plugin cache as well as Codex ~/.agents/skills and ~/.codex/skills; runs in dry-run mode by default and only applies changes with --apply; uses O_NOFOLLOW dirfd, atomic renaming via renameat2/renameatx_np, and timestamped backups to prevent concurrency and directory race conditions.

daymade-claude-code/claude-switch-models-setup/scripts/sync-local-skill-sources.py
Real files/directories and third-party links are never deleted or automatically moved.
At 2,153 lines, this script represents the heaviest safety engineering in the repository: it freezes source/root identity before modification, opens affected root directories with no-follow descriptors, and supports rollback on failure (bi-directional round-trip via exclusive_rename).

Formalize context window configuration into decision rules: use the literal [1m] suffix only for genuine ~1M context windows (which Claude Code matches literally), use explicit CLAUDE_CODE_MAX_CONTEXT_TOKENS/AUTO_COMPACT for known smaller windows, and never guess for unverified models; dual entries in deepseek/glm templates are intentionally preserved.

daymade-claude-code/claude-switch-models-setup/SKILL.md
Claude Code matches this literal string, not a made-up marker like `[1million]` or `[max]`.
references/context-window-config.md details the complete [1m] mechanism and includes a local http.server capture recipe to inspect whether env changes actually alter over-the-wire payload bytes.

Deployment discipline: deploy scripts via symlinks rather than cp (preventing two-way drift—such as the historical incident where a bug fix sat idle in the repo for 26 days while cleanup code only existed in the deployed copy), accompanied by the setup.sh installer and the claude-profiles-init/doctor/rm operational command suite.

daymade-claude-code/claude-switch-models-setup/scripts/setup.sh
# Symlink rather than copy.
SKILL.md provides a dedicated one-liner command to verify live links; claude-profile-rm first scans for unexpected real files and prompts for y/N confirmation before issuing rm -rf on the isolated directory.

2Core Capabilities

01One-click multi-profile management (create/start/audit/remove): claude-profiles-init / claude-profile <name> / doctor / rm
02Comprehensive settings.json convergence engine (SessionStart hook auto-remediation + --all/--check)
03.claude.json behavioral key allowlist sync (e.g., workflowSizeGuideline) with three-category state/credential protection
04Plugin structure remediation and enabledPlugins mirroring (claude-plugins-sync.py, auto-triggered on profile launch/write)
05Local skill source ↔ Claude/Codex active site synchronization (dry-run preview + --apply + macOS LaunchAgent daemon)
0611 provider configuration templates (Kimi/MiniMax×2/GLM/DeepSeek/StepFun/Anthropic, etc., with [1m] or explicit context windows) + context window decision rules
07Profile drift troubleshooting (orphan detection, real-dir drift, corrupted installLocation, and non-converging settings)

3External Dependencies

KindDependency / Endpoint
cliclaude(官方 CLI,按 profile 启动)
clipython3
cliuv(仅 daemon --install 时 uv python install 3.12 取托管运行时)
clilaunchctl(macOS LaunchAgent 安装/启动)
networkprovider API 端点(经 claude CLI 转发;模板列出 base URL 需用户核实)

4Recommended Governance & Evidence

Suggested Controls for Safe Operation
For Agent Runtime
Graded/per-use authorization, sandbox recommended
For Administrators
Approval workflow, rollback support, full audit
Evidence & Triggers (File Paths & Excerpts)
  • scripts/: Executes local scripts or commands: scripts/setup.sh
  • 网络端点: Declares external network access: (User actions during SKILL execution) claude CLI outbound traffic to provider endpoints/gateways; uv python during daemon --install
  • 本地工作目录: File I/O and artifact output: ~/.claude-profiles/<name>/ directory structure (.claude.json, symlinked folders)
Audit Notes: The direct subject of this skill is configuration management involving plaintext credentials: SKILL instructs users to write API keys in plaintext to ~/.claude/settings/<provider>.json (consistent with native Claude Code behavior). The script suite inspects and classifies settings.json and .claude.json across primary and third-party profiles (explicitly skipping state keys such as oauthAccount, token, and secret to prevent them from ever being overwritten back, maintaining a strictly unidirectional default-to-third-party convergence guarded by denylist/allowlist boundaries). No proprietary outbound network traffic is introduced; network activity is strictly limited to claude CLI connecting to configured provider endpoints (determined by user configuration) plus uv fetching managed Python from astral official sources during daemon installation. Trigger conditions: runs solely when the user requests creating/maintaining multi-provider profiles or debugging profile drift. Security evaluations should center on two aspects: storing plaintext API keys across additional configuration copies and treating local source repositories as trusted active sources.

5Second-Pass Verification

  • [ok] 脚本零网络外发 — 全部脚本无 urllib/requests/socket;grep 到的 https 仅 setup.sh echo 链接与模板/文档里的 provider base URL
  • [ok] 凭证键不被同步(防串 profile) — STATE_EXACT 含 projects/oauthAccount/userID 等;STATE_SUBSTR 匹配 token/secret/credential/apikey;ENV_KEY_DENYLIST 拦 ANTHROPIC_* 与隔离旗标;灰键仅报告
  • [ok] converger 方向单向(默认→第三方) — docstring:'every key present in main's settings.json overwrites the profile's, except denylisted ones';顶层 profile-only 键保留
  • [ok] 删除/修复路径受控 — claude-profile-rm:意外真实文件即 ABORT + y/N 确认;init --repair 把 real dir 归档为 .pre-symlink-bak-<ts> 再 symlink,不直接删
  • [ok] 源码同步竞态防护真实存在 — O_NOFOLLOW 打开每个路径组件、libc renameat2/renameatx_np 独占改名、失败 exclusive_rename 回滚、KEEP_JSON_BACKUPS=20
  • [ok] ‘claude-profiles-doctor 报 real dir’等能力声明有脚本支撑 — doctor 遍历 profile 目录对比 symlink 与 real dir('WARN: <name> is a real directory (expected symlink...)')

6Verdict & Scenarios

  • Systematizes configuration drift in multi-provider concurrent setups via a clear three-tier model: symlink sharing + config convergence + state isolation
  • Rigorous credential and state security: three-tier classification (allowlist/state/gray) + unidirectional convergence + gray-key tripwire reporting to prevent account identity leakage across profiles
  • Robust concurrency and directory race protection (no-follow fd, renameat2, atomic rollback), rare in standard tooling scripts
  • Documentation functions as an empirical audit log (dates + metrics), allowing future maintainers to trace the exact rationale behind every design decision
  • Guardrails on all destructive operations: archive-first remediation, explicit y/N deletion prompts, and dry-run defaults
  • Best for: Ideal for power users running multiple LLM providers concurrently via Claude Code, workshop environments performing batch setups for students, or maintainers who manage local skill source repositories and need real-time synchronization into the active Claude/Codex execution surface. It specifically solves systematic multi-window isolation and automated convergence of profile drift.
    Not for: Not intended for users running only the official single Anthropic model without multi-provider requirements (where this framework adds unnecessary overhead); organizations whose security policies prohibit storing plaintext API keys across multiple configuration files; end-users unfamiliar with Claude Code internal configurations attempting unguided troubleshooting (who should refer to student-setup-guide or human support); or environments treating unvetted local repositories directly as skill sources.
    Install Agent-Ready
    ① Verified Mirror 2026-09-09
    Option A · Direct DownloadDownload claude-switch-models-setup.tar.gz
    sha256: 1c1947b7efbf6091…
    Option B · Copy Guide for Agent
    install.json
    Agents automatically download and verify mirrors from this JSON guide.
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit d5c4678cb5.