claude-code-profiles
AGENTS.md96 starsChanged 3 months agoMITView on GitHub
Cross-platform shell functions for managing multiple Claude Code configuration profiles via CLAUDE_CONFIG_DIR. Each profile is a complete, isolated config directory. A transparent claude() wrapper auto-resolves the active profile so users just run claude normally. Three equivalent implementations: POSIX sh (sourced), PowerShell (dot-sourced), and Windows cmd batch. The POSIX and PowerShell implementations are sourceable function files (not standalone scripts). They each define two functions: claude() (transparent wrapper) and claude-profile() (management). The cmd batch script is standalone since cmd lacks a function-sourcing…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- docs/llms-full.txtllms.txt
- docs/llms.txtllms.txt
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
All three implementations share the same command interface:
- Distinctive: line 89
No build step. No test framework.
- Very specific: line 101
Use git worktree (via .worktrees/) for parallel branch work.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project
Cross-platform shell functions for managing multiple Claude Code configuration profiles via CLAUDE_CONFIG_DIR. Each profile is a complete, isolated config directory. A transparent claude() wrapper auto-resolves the active profile so users just run claude normally.
Three equivalent implementations: POSIX sh (sourced), PowerShell (dot-sourced), and Windows cmd batch.
Architecture
The POSIX and PowerShell implementations are sourceable function files (not standalone scripts). They each define two functions: claude() (transparent wrapper) and claude-profile() (management). The cmd batch script is standalone since cmd lacks a function-sourcing mechanism.
claude-profile.sh(POSIX sh) — reference implementation. Sourced in.bashrc/.zshrc. Providesclaude()wrapper that auto-resolves the default profile before calling the real binary viacommand claude. Providesclaude-profile()for management commands. Strict POSIX only: nolocal, no[[ ]], no arrays, no bashisms. Usesprintfoverecho,_cp_-prefixed variables,return(notexit— runs in user's shell). On Git Bash / MSYS2 (detected via$MSYSTEM), profiles are stored at%LOCALAPPDATA%\claude-profiles\and paths are converted viacygpath -wbefore invokingclaude.exeso they are shared with the cmd/PowerShell implementations.claude-profile-init.ps1(PowerShell 5.1+/pwsh 6+) — cross-platform. Dot-sourced in$PROFILE. Same two-function model. Uses$argsmanual parsing (notparam()) to avoid conflicts with PowerShell parameter binding.Get-Command -CommandType Applicationto find the realclaudebinary past the function.claude-profile.cmd(Windows batch) — standalone script. Usesgoto :labeldispatch,setlocal enabledelayedexpansion,endlocal & setidiom to leakCLAUDE_CONFIG_DIRto the caller. No transparentclaudewrapper (cmd limitation). Users runcall claude-profile.cmd use <name>thenclaudeseparately.
Profile data lives at $XDG_DATA_HOME/claude-profiles/ (Linux/macOS/WSL, default ~/.local/share/claude-profiles/) or %LOCALAPPDATA%\claude-profiles\ (Windows, including Git Bash/MSYS2). A .default file stores the default profile name as plain text without trailing newline.
The tool itself is installed at $XDG_DATA_HOME/claude-profile/ (Linux/macOS) or %LOCALAPPDATA%\claude-profile\ (Windows) — note the singular form, distinct from the plural claude-profiles/ data directory.
Command Interface
All three implementations share the same command interface:
| Command | Description |
claude-profile | Show current profile status (active + default) |
claude-profile use <name> | Switch to a profile for the current session |
claude-profile create <name> | Create a new profile |
claude-profile list | List all profiles (marks default and active) |
claude-profile default [name] | Get or set the default profile |
claude-profile local [name] | Show, set, or --remove the directory-local .claude-profile |
claude-profile auto [on|off|status] | Control directory-local auto-switching (sh/ps1 only) |
claude-profile skills ... | Manage the shared skill pool and per-profile selections (see below) |
claude-profile which [name] | Show the resolved config directory path |
claude-profile delete <name> | Delete a profile (with confirmation) |
claude-profile help | Show help |
Directory-Local Profiles
A .claude-profile file (first non-empty, non-comment line = profile name) switches CLAUDE_CONFIG_DIR when the shell enters that directory or any descendant, and reverts on leaving. An explicit claude-profile use pins the session and wins until claude-profile auto on.
The pin is tracked via an exported CLAUDE_PROFILE_AUTO_SET marker: auto-switching only manages CLAUDE_CONFIG_DIR when its value equals that marker, so anything set by hand (or inherited from outside) is left alone. Exporting it means nested shells keep auto-managing rather than treating the inherited value as manual.
Directory-change hooks differ per shell: zsh chpwd, bash PROMPT_COMMAND, cd wrapper elsewhere; PowerShell 6+ LocationChangedAction, PowerShell 5.1 prompt wrapper. cmd.exe has no hook — a bare call claude-profile.cmd resolves the dotfile at invocation time instead.
Because bash re-runs the resolver on every prompt, _cp_auto_switch short-circuits when $PWD is unchanged and the upward walk uses only parameter expansion (no dirname fork per component). That short-circuit also rate-limits the "invalid/missing profile" warnings to once per directory entry.
Per-Profile Skills
A shared skill pool lives at <data-root>/skills/ (the profile name
skills is therefore reserved and rejected by validation in all three
implementations, including the .claude-profile resolvers). skills
register <name> <path> links a skill source directory (must contain
SKILL.md) into the pool — ln -s on POSIX, directory junctions
(mklink /J, no admin rights) on Windows including via Git Bash
(cmd //c mklink /J + cygpath -w) so all three implementations share
the links.
Each profile may have a skills.conf manifest (one pool-skill name per
line, # comments, same parser style as .claude-profile). Absent
manifest = all pool skills (backward-compatible default); empty manifest
= none. skills add/remove first materialize the implicit "all" list
into skills.conf so edits stay sticky.
Sync (skills sync, also run by create and every manifest-editing
command) is two-pass: remove managed links that are dangling or
undesired, then create missing ones. A link is managed iff its literal
target lies under the pool directory — anything else in
<profile>/skills/ (hand-made symlinks, real dirs) is never touched;
name collisions warn and the unmanaged entry wins. Sync never runs on
use or the auto-switch hot path. In cmd, link targets are read by
parsing dir /AL output and managed detection is an exact-target
comparison against <pool>\<name>.
Validation Rules
Profile names must match [A-Za-z0-9_-]+. Reject: empty, starts with ., contains / or \ or ... This prevents path traversal — all three implementations enforce this identically.
Checking Scripts
shellcheck claude-profile.sh # Lint POSIX sh function file
checkbashisms claude-profile.sh # Verify no bashisms (hyphenated function name is expected)No build step. No test framework. Manual verification by running commands against real profiles.
Branching Model
This project uses git-flow. Branch types:
main— stable, release-ready. Never commit directly; merge via PR only.develop— integration branch for next release. Feature branches merge here.feature/*— new features and non-trivial changes. Branch fromdevelop, merge back todevelop.release/*— release prep (version bumps, changelog). Branch fromdevelop, merge to bothmainanddevelop.hotfix/*— urgent fixes for production. Branch frommain, merge to bothmainanddevelop.
Use git worktree (via .worktrees/) for parallel branch work.
When Modifying
Any behavioral change must be applied to all three implementations (claude-profile.sh, claude-profile.cmd, claude-profile-init.ps1) plus updated in README.md. The install scripts (install.sh, install.ps1) reference https://raw.githubusercontent.com/quinnjr/claude-code-profiles/main/ for download URLs.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

