Claude Code Profiles and Local Skill Activation
Overview
This skill creates an isolated-but-shared profile system for Claude Code CLI. Each profile gets its own .claude.json state file (provider credentials and session history) while sharing skills, projects, hook scripts, agents, and installed plugin state across all profiles — and converging each profile's settings.json (hook registration, marketplaces, env feature flags, permissions, preferences) plus the behavior slice of its .claude.json (e.g. workflowSizeGuideline) from the default profile, so the only intended difference between profiles is the model/provider.
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.
For reducing fixed startup context from preloaded MCP tool schemas, read
references/mcp-startup-context.md. It owns
same-mode measurement, active-profile discovery, provider compatibility checks,
reversible server suppression, and fresh-process acceptance.
How It Works
CLAUDE_CONFIG_DIRtells Claude Code CLI which directory to use as its config root.- Each profile lives in
~/.claude-profiles/<name>/with an isolated.claude.json. - Content directories (
skills/,projects/,hooks/,agents/,settings/) are symlinked back to the main~/.claude/directory so you only maintain one copy. Note this shares hook scripts, not hook registration — registration lives in each profile's ownsettings.json(next bullet). - Config layer —
settings.json: each profile has its ownsettings.json(Claude Code treats it as config-dir-local), so everything stored there — hook registration,extraKnownMarketplaces,enabledPlugins,envfeature flags,permissions, behavior preferences — silently drifts the moment it changes in the default profile (measured 2026-07-18: 9/9 real profiles had zero hook registrations).sync-profile-settings.pyis the converger: registered as a SessionStart hook, it copies every key from the default profile'ssettings.jsoninto every profile's, except identity keys (top-levelmodelandadvisorModel— the latter is Anthropic-model routing a third-party endpoint can't serve; and env vars that carry provider routing or Anthropic-native isolation —ANTHROPIC_*,CLAUDE_CODE_SUBAGENT_MODEL,ENABLE_TOOL_SEARCH,DISABLE_GROWTHBOOK/TELEMETRY/AUTOUPDATER— which the provider settings file deliberately sets differently). Withinenv, convergence is two-way for non-identity keys: main's keys overwrite the profile's, and a non-identity key main no longer carries is deleted from the profile and reported (identity keys are exempt — main never carries them, so their absence is not deletion evidence). Profile-only top-level keys are preserved; nested collections inside a key main also has (e.g.permissions.allow,enabledPlugins) converge wholesale to main's value, and any profile-only nested entries dropped that way are listed (count on write, detail under--check) so the loss is visible rather than silent. This is what makes "everything except the model works in every profile" actually hold. - Scope is every profile, in every invocation. No argument-free,
--all, or--checkrun ever covers a subset: all of~/.claude-profiles/*plus$CLAUDE_CONFIG_DIR, every time. A run prints one line per profile it actually changed and nothing when there is no drift — so drift shows up in the session-start output instead of hiding, and a silent session start means converged. A$CLAUDE_CONFIG_DIRthat is unset, empty, or not a profile directory is skipped, never created. - Exit codes: the argument-free run exits 0 unconditionally — it is a session-start hook and never blocks a session, including when a main file is corrupt (it warns, converges nothing, and exits 0, because a corrupt main reads as empty and converging toward empty would strip hooks from every profile).
--checkexits 1 on drift and 2 on a corrupt main file or a profile it could not read;--allwrites and exits 2 on those same two failures — the difference between them is that--checkwrites nothing, not which failures return 2.--check --allis the same audit as--check. One unreadable profile is reported and skipped — it never cancels convergence for the others. - State layer —
.claude.jsonbehavior keys:settings.jsonis not the only per-profile config file. Claude Code also keeps a per-profile state file (the main profile's is~/.claude.json; each third-party profile's is<profile>/.claude.json— asymmetric paths, verified on disk), and a few behavior settings live only there (workflowSizeGuideline, notification/UI preferences). On 2026-08-17workflowSizeGuideline: smallexisted only on the main profile and 10/11 third-party profiles had no copy — a Kimi session fanned one Dynamic Workflow out to 30+ agents with no size guidance in its system prompt. The same converger therefore also syncs an allowlist of behavior keys into each profile's.claude.json. The safety mechanism is a three-way classifier in the script, not a hand-maintained key list: allowlisted behavior keys sync; state/cache/counter/migration/credential keys (matched by name patterns) are never touched; anything unknown-and-different is reported — one line per drifted key per run, until a human classifies it (the tripwire that surfaces the next behavior key the day it appears). Writes are backup + atomic-replace; measured safe against a live harness rewriting the file (a marker key survived 30+ minutes of an active session). Applies next session — the harness reads this file at startup. - Exception —
plugins/: marketplace content and install state are shared, but each profile keeps its ownknown_marketplaces.json. Claude validates a marketplace'sinstallLocationwithpath.resolve()(which does NOT resolve symlinks), so a single shared file would make every non-writing profile report "corrupted installLocation".claude-plugins-sync.pybuilds and maintains this per-profile structure. claude-plugins-sync.pyalso mirrorsenabledPluginsfrom the default~/.claude/settings.jsoninto each profile'ssettings.json(sharing cache files is not enough; Claude Code treats "enabled" state as config-dir-local). It runs at profile launch and reactively — the LaunchAgent in the next bullet re-runs it on every write to the default profile'ssettings.json, soclaude plugin enable/disable --scope usertypically propagates to every profile within seconds without a relaunch (verified 2026-08-22). The mirror adopts first: enabledPlugins keys that exist only in some profile's settings.json (the wayclaude plugin installwrites them) are written back into the default profile before mirroring — consistent values only; cross-profile conflicts stay per-profile behind a standing warning instead of being silently overwritten. The SessionStart converger above covers the same key as part of its whole-settings sync;claude-plugins-sync.pyremains the owner of the per-profileknown_marketplaces.jsonstructure.skill-install-audit.pyreconciles the registry / installed / enabled / Codex-manifest /~/.agents/skillslayers read-only, plus the daemon's pinned runtime version and whether the checkouts it judged everything against are themselves behind.prune-source-sync-backups.pyremoves only the.source-sync-backups/buckets git can reproduce; a bucket holding even one blob no repository has is reported and left alone.- Local source sync keeps approved source-backed routes aligned for each host.
Before selecting or repairing entries, read the
host-specific activation contract.
It owns the manifest fields, marketplace expansion, Claude plugin/direct-link
distinction, unresolved-name handling, collision safety, and legacy compatibility.
Source registration alone does not choose activation policy; do not hand-create
links or repurpose the manifest to manage third-party inventory.
- Sync scripts use a shared cross-process lock. This is required because users often open several provider windows from tmux or multiple terminals at once; concurrent launches must serialize marketplace/cache rewrites while still allowing all profiles to start.
- For the full local-source architecture, read
references/local-source-sync-architecture.mdbefore changing these scripts. - For Skill authoring in an approved independent Fleet clone, use the
leased-authoring owner procedure.
- Provider routing is done via
~/.claude/settings/<name>.json, which sets non-secretANTHROPIC_MODELandANTHROPIC_BASE_URLfor that window. Deliver credentials through the explicit export binding in setup step 4; existing in-file credentials remain readable for legacy compatibility. That file is a full settings file rather than an env file, and it is the one layer the converger never touches —claude-profilelaunches withclaude --settings ~/.claude/settings/<name>.json, while the converger only ever writes<profile>/settings.json. So anything that has to be per-profile and has to survive every session start belongs here; put it in the profile's ownsettings.jsonand the next convergence takes it back. This includes per-profilepermissions.deny, such as denyingWebSearchandWebFetch. - Per-profile thinking effort lives in that provider file too. The default profile sets effort per Anthropic model via
modelSettingsin~/.claude/settings.json; a third-party profile that needs a different effort pinsCLAUDE_CODE_EFFORT_LEVEL(e.g."max") in its~/.claude/settings/<name>.jsonenv instead. The provider file is the only layer that can hold that pin: put it in the profile's ownsettings.jsonenv and the converger deletes it at the next session start (a non-identity env key the default profile doesn't carry is deletion-propagated away); put it in the default profile's env and it applies there and converges into every third-party profile'ssettings.json— usually wrong, because weaker third-party models benefit from forced max effort exactly when the default flagship no longer does (verified end-to-end 2026-10-06: a session launched viaclaude-profilereads the pinned value back from its own environment). - A scripted profile needs its provider settings and its credential binding. Use
claude-profileor the registered execution owner so the model, endpoint and authorized token reach the same process. A caller that supplies onlyCLAUDE_CONFIG_DIRcan omit those inputs;Not logged indoes not by itself mean a new login or key is needed. Resolve the existing source and reproduce its explicit per-profile export binding first. Legacy in-file tokens remain readable, but new setup must not put a secret in a settings file. - The converger has no single-profile mode: every invocation covers all of
~/.claude-profiles/*plus$CLAUDE_CONFIG_DIR, and no flag narrows that. To converge one profile on demand, pointCLAUDE_PROFILES_ROOTat a directory holding only it, or run--checkand read the per-profile lines. The default profile's own files are the source and are never written.
⚠️ Never run the converger against a synthetic main
Scope is every profile — all of ~/.claude-profiles/* plus $CLAUDE_CONFIG_DIR
— and the source of truth is CLAUDE_MAIN_CONFIG_DIR. Point that at a throwaway
directory while CLAUDE_PROFILES_ROOT or $CLAUDE_CONFIG_DIR still reaches a
real profile, and the run converges that real profile toward the synthetic
main: its whole hooks object is replaced by whatever the fake main holds, and
its env gains the fake main's keys. **Every guard registered in that profile
stops firing.** The output does name hooks among the keys it synced and, when
the overwrite drops profile-only entries, reports how many — but nothing in it
says guards stopped firing, so it reads as the converger doing its job. A
synthetic main is safe only when the profiles root and $CLAUDE_CONFIG_DIR are
synthetic and disposable too.
Before running it by hand, check both halves of the scope:
echo "MAIN=$CLAUDE_MAIN_CONFIG_DIR ROOT=$CLAUDE_PROFILES_ROOT ACTIVE=$CLAUDE_CONFIG_DIR"
An unset CLAUDE_PROFILES_ROOT is not a green light — it defaults to the
real ~/.claude-profiles, so every real profile converges. Stop unless both
CLAUDE_PROFILES_ROOT and $CLAUDE_CONFIG_DIR are synthetic and disposable.
Test fixtures must build the subprocess environment from a scrubbed base instead
of inheriting the live one — a shell profile sets these variables, and unset
inside a script does not reliably reach a child process:
env -u CLAUDE_CONFIG_DIR -u CLAUDE_MAIN_CONFIG_DIR -u CLAUDE_PROFILES_ROOT …
Decide whether a run wrote anything mechanically, not by eye. Record the target
profile's settings.json size before the run and compare after. .sync-backup
is written with shutil.copy2, which preserves the source mtime, so **an old
backup timestamp does not prove nothing was written** — compare size and bytes.
If a real profile did get written, restore from that profile's own backup and
verify byte-for-byte:
cp -p <profile>/settings.json.sync-backup <profile>/settings.json
Check size, JSON validity, top-level key count, hooks length, unexpected env
keys, and sandbox signatures such as /bin/true. Then scan the other profiles:
scope is all of them, so one run can hit several.
Callers that capture native structured output
Source scripts/claude-profiles.sh and call
claude-profile-with-command "<absolute-executable>" <profile> [claude arguments...]
when a caller must attach stdout capture at the native invocation. The supplied
executable file (or a symlink to one) receives the original --settings and Claude arguments with the
profile's CLAUDE_CONFIG_DIR; profile validation, synchronization, launch output
and credentials keep their existing owners. The executable controls only its
native invocation and returns that invocation's exit status.
Use a trusted, version-matched script with the
claude-profile-native-command-api: 1 contract before invoking this entry. A caller
that requires this boundary must refuse an unsupported script before running
profile setup; intercepting a shell function named claude cannot cover `command
claude or an absolute native path. Ordinary claude-profile` calls retain their
existing behavior.
One-Click Setup Workflow
When the user says something like "set up Claude Code profiles" or "I want to use Kimi and DeepSeek in different windows":
- Check prerequisites
claudeCLI is installed:which claude- Shell is zsh or bash: detect via
$SHELL python3is available
- Install the profile manager scripts — symlink them, do not copy
On a machine that has this repo checked out (the maintainer case), run the
bundled installer:
```bash
<absolute-path-to-this-repo>/daymade-claude-code/claude-switch-models-setup/scripts/setup.sh
```
scripts/setup.sh is the single source for the exact deployment set. It links
each helper into ~/.config/claude-switch-models-setup/ and seeds the activation
manifest only when it does not already exist. Do not maintain another helper list
here. No chmod step is needed: the deployment is by symlink, and the source
files retain their committed modes.
Recorder files are deployed without enabling the optional wrapper. Existing
ordinary recorder copies must be compared and preserved before setup replaces
them with links; pinned deployments follow the “advance the pin” procedure.
Why symlinks and not cp: ~/.config/… is what actually runs — the
LaunchAgent and claude-profile invoke scripts by that path — while this
repo holds their source. Copies drift, and nothing about a deployed copy
looks different from its source. A link prevents independent edits and
source updates from silently diverging, *for as long as it stays a
link* — an atomic-save editor, an rsync or a stray cp turns one back into
a real file without saying so, which is why this is worth re-checking rather
than declaring solved. It also lets sync-local-skill-sources.py locate its
own source repo by resolving its own path, instead of falling back to
guessing.
Worth re-checking how? Any periodic check works; there is none bundled with
this skill. One line, run wherever you keep such things:
```bash
for f in ~/.config/claude-switch-models-setup/.py ~/.config/claude-switch-models-setup/.sh; do
[ -L "$f" ] && [ -e "$f" ] || echo "not a live link: $f"
done
```
If one has become a real file, move it aside before re-linking — it may
hold edits that exist nowhere else, which is the whole problem being
described: mv "$f" "$f.local-edits" && ln -sf <source> "$f", then diff.
On a machine without the repo, copy the scripts listed by the installer out of this skill
bundle instead — and accept that repo fixes will not reach it until you copy
again.
On a machine whose LaunchAgent runs the pinned plugin copy (the maintainer
layout described in local-source-sync-architecture.md),
these same links point at that copy's version directory under .../plugins/cache/...,
not at the checkout, and move only when the pin is advanced
(troubleshooting.md, "advance the pin"). The
installer refuses to relink such a machine to the checkout
(CSMS_SETUP_RELINK_TO_CHECKOUT=1 overrides), because the daemon and
claude-profile would then follow whatever branch the checkout sits on. The
live-link check above applies to both layouts.
- Add shell integration
- Source the profile manager in
~/.zshrcor~/.bashrc - Add aliases:
csk,csd,csg - Add any further per-account/per-plan variant alias by hand if needed —
the script's help text only lists the base examples above; variants like
cssplan/cssp are hand-added, not generated
- Tell the user to run
source ~/.zshrc(or open a new terminal)
- Generate provider settings files
- For each provider the user wants, create
~/.claude/settings/<provider>.json - Use the templates in
assets/templates/as a starting point - Source the API key by machine class before asking anyone for anything:
- Owner's own or explicitly authorized machine: first locate the key
where it is already registered — the owner's provider credential setup
and recovery entry (their operations docs or account-provider skill),
the shell exports it already maintains, and any existing profile
binding. A missing key at the default settings path does not mean
the credential is unavailable. Hand the token to consumers as a
~/.zprofile export with an explicit per-profile binding, and verify
by actually invoking the original consumer — a real headless request
succeeding, not a written file or an echoed variable.
- A new user's or student's machine: prompt them for their own valid
API key and base URL; never hardcode defaults, and never copy or
lend the maintainer's credentials. Have them store the key the same
way — a shell export (e.g. in ~/.zprofile) bound explicitly to the
profile that consumes it — not as a secret inside a settings file.
- Set the context window correctly for this specific provider —
[1m]suffix vs explicitCLAUDE_CODE_MAX_CONTEXT_TOKENS/CLAUDE_CODE_AUTO_COMPACT_WINDOW, see "Configuring Context Window Size" below. Do this explicitly for every new profile rather than copying whatever the nearest template happens to already have — the nearest template not needing it is not evidence that this one doesn't either. - Include the required isolation flags:
CLAUDE_CODE_SUBAGENT_MODEL(same asANTHROPIC_MODEL)ENABLE_TOOL_SEARCH: "false"DISABLE_GROWTHBOOK: "1"DISABLE_TELEMETRY: "1"- (Optional)
DISABLE_AUTOUPDATER: "1"— only needed for offline or version-pinned setups. Native auto-update fetches only from publicdownloads.claude.ai/claude-code-releaseswithout using Anthropic account login, so leaving it unset lets third-party profiles keep the sharedclaudebinary up to date automatically. - Optionally pin
CLAUDE_CODE_EFFORT_LEVEL(e.g."max") when this provider's model benefits from a forced thinking effort different from the default profile's. It belongs in this provider file — never in the profile'ssettings.jsonenv, where the converger deletes it (see "Per-profile thinking effort" under How It Works). - Keep
~/.claude/settings/<provider>.jsonhost-portable: put only host-independent routing, isolation flags, effort pins, and tool-namepermissionshere. Do not copy host-specific absolute-pathhooks(such as/Users/<user>/scripts/...) into provider settings files — hooks are converged per machine from that machine's default~/.claude/settings.jsonbysync-profile-settings.py, and hardcoded host paths break when the profile file is synced to Linux or another username. - Upgrading or cloning a sibling provider profile (
<old>→<new>):sync-profile-settings.pyintentionally does not manage provider settings files, profile-localCLAUDE.md, shell aliases, or fleet policy. When retiring one model generation for a sibling profile, align each layer below explicitly and read each back:
1. ~/.claude/settings/<new>.json: carry over host-portable permissions (deny/allow), isolation flags, context-window configuration, and CLAUDE_CODE_EFFORT_LEVEL from <old>.json (keep host-specific hooks out).
2. ~/.claude-profiles/<new>/CLAUDE.md: if <old> carried profile-local session constraints (such as rules paired with a permissions.deny entry), mirror and update them for <new>.
3. Shell aliases (~/.zshrc / ~/.bashrc): add or repoint shortcuts so interactive shells launch <new>, and read back via an interactive shell (alias <name>).
4. Managed worker/fleet model policy (if configured on the host): update the allowed profile list, sync reachable workers, and record any offline workers separately.
- Initialize profile directories
- Run
claude-profiles-init - This creates
~/.claude-profiles/<provider>/with isolated.claude.jsonand symlinks - On maintainer machines, this also repairs local source symlinks before syncing plugin metadata
Statusline wiring: claude-profiles-init auto-detects a statusline script from
~/.claude/settings.json or ~/.claude/statusline.sh and injects it into each new
profile. If neither is present, profiles will work but without a status bar. **It is
the AI's job** to decide whether the user needs a statusline, install the
statusline-generator skill if appropriate, and run its installer — not the profile
setup script. Do not hardcode dependency installs into shell scripts.
- Register the settings converger
- Add the converger as a SessionStart hook in the default profile's
~/.claude/settings.jsonhooks.SessionStartlist, using an absolute direct-Python command such as'/absolute/path/to/python3' '/absolute/path/to/sync-profile-settings.py'. Do not register the.pyfile by shebang or through a package manager: this hook exists to repair every profile and must not wait on a shared environment/cache lock. Register it without arguments — the argument-free call is the session-start mode, which converges every profile and never blocks the session. Do not add--allto the hook command:--allis the human mode and exits 2 on a corrupt main file or a profile it could not read, which would block session start. - Run the initial alignment:
python3 ~/.config/claude-switch-models-setup/sync-profile-settings.py --all - From then on every profile converges its
settings.jsonand the behavior slice of its.claude.jsonfrom the default profile at each session start, whoever starts it (changes apply next session). The default profile's own files are the SSOT and are never written. Audit without writing:--check(or--check --all, the same audit).
- Verify isolation
- Run
claude-profiles-doctor - Confirm each profile directory has
.claude.jsonand valid symlinks
- Select local source Skills for Codex and Claude
- Skip this for normal students or users who do not edit the skill source repos
- Read the host-specific activation contract, then edit the machine's activation manifest for the requested hosts. Use its compatibility rules only for consumers that still retain a legacy path.
- Preview with
python3 ~/.config/claude-switch-models-setup/sync-local-skill-sources.py, read every affected path, then apply withpython3 ~/.config/claude-switch-models-setup/sync-local-skill-sources.py --apply. - If the target canonical checkout has in-scope WIP or must consume published bytes without changing HEAD/index, do not use that ordinary preview/apply pair as a substitute for adoption. Follow the published-content adoption procedure, including host scope, writer handoff, exact-tree comparison, backup/atomic write, and the pre-apply owner/inventory recheck. If HEAD must advance instead, wait for the WIP owner and use a verified guarded synchronizer.
- On a maintainer macOS machine, run
~/.config/claude-switch-models-setup/sync-local-skill-sources-daemon.sh --install - This watches the activation manifest, default Claude install state, and local marketplace manifests, then repairs derived state after selection, install/uninstall, or plugin topology changes
- Show the user how to launch
csk→ Kimi windowcsd→ DeepSeek windowcsg→ GLM windowclaude(no alias) → default Anthropic profile- Optional: hand-add per-account/per-plan variant aliases yourself —
claude-profiles.sh does not generate them. StepFun is the running
example: its subscription plan only answers at a dedicated plan base URL
(https://api.stepfun.com/step_plan, single model), while pay-as-you-go
goes through the provider's standard endpoint or whatever gateway fronts
it — same provider, two billing modes, so they live as two profiles with
two aliases (always ask for the exact base URLs):
```bash
alias cssplan='claude-profile step-plan --dangerously-skip-permissions'
alias cssp='claude-profile step-pay --dangerously-skip-permissions'
```
Commands
After setup, the user can run:
claude-profiles-init # Re-scan settings/*.json, create missing profiles;
# reports symlink drift (real dirs that should be symlinks).
# Add --repair to archive drift and replace with symlinks.
claude-profile <name> # Launch a specific profile
claude-profiles-ls # List profiles
claude-profiles-doctor # Check symlink health
claude-profile-rm <name> # Remove a profile's isolation directory
python3 ~/.config/claude-switch-models-setup/claude-plugins-sync.py
# Repair per-profile plugin structure and enabledPlugins
python3 ~/.config/claude-switch-models-setup/sync-profile-settings.py --all
# Converge every profile from the default profile:
# settings.json (hooks, marketplaces, env flags,
# permissions, preferences) + .claude.json behavior
# keys (workflowSizeGuideline etc.). Session start
# already does this for all profiles; run --all to
# apply a manual settings edit immediately.
# --check audits the same scope without writing
python3 ~/.config/claude-switch-models-setup/sync-local-skill-sources.py
# Maintainers: preview host selections and affected paths
python3 ~/.config/claude-switch-models-setup/sync-local-skill-sources.py --apply
# Apply the inspected Codex, Claude, and explicit
# legacy compatibility changes
~/.config/claude-switch-models-setup/sync-local-skill-sources-daemon.sh --install
# Maintainers: install automatic macOS watcher
These are not day-to-day commands. Edits to activated canonical sources are live through symlinks. The one-shot commands are for repair, bootstrap, or non-macOS environments without the LaunchAgent watcher. When a repair would adopt a published ref into a live canonical checkout, use the published-content adoption procedure instead of treating --apply as sufficient.