A SessionStart hook for Claude Code that warns when you launch a session from inside ~/.claude/, preventing the creation of a nested ~/.claude/.claude/ config directory.
See claude-code#37517 for background.
Requires jq.
git clone https://github.com/anthropics/nested-config-guard.git
cd nested-config-guard
chmod +x install.sh nested-config-guard.sh
./install.shThis adds a SessionStart hook to ~/.claude/settings.json that runs the guard script each time Claude Code starts.
Add the following to ~/.claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"command": "bash /path/to/nested-config-guard.sh"
}
]
}
}When Claude Code starts, the hook checks if the current working directory is ~/.claude/ or a subdirectory of it. If so, it prints a warning to stderr suggesting you switch to a project directory first.
Remove the SessionStart hook entry from ~/.claude/settings.json.