Unclear It is not confirmed that setting the variable actually stops the hook from running.
A Stop hook is a script that runs when Claude finishes responding. Claude Code ships a default one, ~/.claude/stop-hook-git-check.sh, which checks the state of git. A new environment variable, CLAUDE_CODE_GIT_CHECK_ONLY_IN_REPOSITORY, lets Claude Code skip that hook outside a git repository. An environment variable is a named value set in your shell before you start Claude Code. Claude Code reads it once and then removes it, so programs it starts do not see it. To decide whether you are in a repository, Claude Code looks for .git or HEAD in the current folder or any folder above it.
The hook is skipped only if it is the unchanged default command. It is never skipped in these cases:
- on Windows
- when the hook comes from a plugin, a skill, the project, or an SDK host program
- when
CLAUDE_CODE_SHELL_PREFIX,GIT_DIRorBASH_ENVis set
Running a git check in a folder that is not a git repository does nothing useful. This lets you stop it there. Anything you have customised, or any setup that changes how git or the shell behaves, still runs the hook.
It is not confirmed that setting the variable actually stops the hook from running.
New in this build: CLAUDE_CODE_GIT_CHECK_ONLY_IN_REPOSITORY