{"version":"2.1.321","anchor":"stop-hook-git-check-can-be-limited-to-repositories-by-an-env","canonical_anchor":"stop-hook-git-check-can-be-limited-to-repositories-by-an-env","heading":"Environment variable to limit the built-in git check to git repositories","tier":"use","area":"Hooks","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.321\/e\/stop-hook-git-check-can-be-limited-to-repositories-by-an-env","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.321","markdown":"### Environment variable to limit the built-in git check to git repositories\n\nSetting `CLAUDE_CODE_GIT_CHECK_ONLY_IN_REPOSITORY` lets Claude Code skip its built-in git check when you are not inside a git repository\n\n**Unclear.** It is not confirmed that setting the variable actually stops the hook from running.\n\n**What**\n\nA 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.\n\nThe hook is skipped only if it is the unchanged default command. It is never skipped in these cases:\n\n- on Windows\n\n- when the hook comes from a plugin, a skill, the project, or an SDK host program\n\n- when `CLAUDE_CODE_SHELL_PREFIX`, `GIT_DIR` or `BASH_ENV` is set\n\n**Why**\n\nRunning 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.\n\n- Area: Hooks\n- Names: `CLAUDE_CODE_GIT_CHECK_ONLY_IN_REPOSITORY`\n- Tier: Use it now\n- Useful: 5\/5\n- Signal: 3\/5\n- Scope: individual\n- Heads-up: no"}