fix(setup): let sandboxed git see the whole-user hook dir - #1364
Merged
Merged
Conversation
Whole-user scope sets core.hooksPath to ~/.claude/git-hooks, but nothing granted the sandbox read access to it. Git inside the sandbox then sees no hook directory and treats that as "no hooks": every commit the agent makes skips pre-commit (prek included), commit-msg and the rest without a warning, and CI is the first to notice. - Install Step P.3-whole-user gains a step proposing the read-only user-scope allowRead grant for ~/.claude/git-hooks/ (and ~/.claude-config/git-hooks/ when the hooks are symlinked from the sync repo). - secure-agent-setup.md explains the grant beside the whole-user trade-offs, and sandbox-troubleshooting.md catalogues the silent skip. - setup-isolated-setup-verify check 8 probes the hook dir from inside the sandbox and reports an unreadable one as a failure, with a new step-1 fixture. Generated-by: Claude Code (Opus 5)
The doctor's probes follow the troubleshooting catalogue, and the previous commit adds the "git hooks silently skipped" entry. Git prints nothing when it cannot see core.hooksPath, so the error-hint hook cannot catch it; a probe that looks from inside the sandbox can. Probe 8 (probe-8-git-hooks.sh) reports skip when there is no global core.hooksPath, fail when the hook dir or a hook's symlink target is unreadable inside the sandbox, warn when the dir holds none of the common hooks, and pass with the hooks it can see. The doctor now counts eight probes, and the interpret-probes eval gains a git_hooks_status field and a case-17 fixture. Generated-by: Claude Code (Opus 5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
core.hooksPathto~/.claude/git-hooks, but nothing grants the sandbox read access to that directory. Git inside the sandbox sees no hook directory and treats that as "no hooks". Every commit an agent makes skipspre-commit(and soprek),commit-msg,pre-pushand the rest without a warning, and CI is the first place the skipped checks fail.allowReadgrant for~/.claude/git-hooks/, plus~/.claude-config/git-hooks/when the hooks are symlinked from the sync repo, because the sandbox checks the resolved path.secure-agent-setup.mdexplains the grant next to the whole-user trade-offs.sandbox-troubleshooting.mdcatalogues the silent skip, quoting the errors exactly as printed.setup-isolated-setup-verifycheck 8 now probes the hook directory from inside the sandbox and reports an unreadable one as ✗.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
git hook run pre-commitfails witherror: cannot find a hook named pre-commit, andls ~/.claude/git-hooksfails withNo such file or directory.prek runon the PR's diff passes, and so do thecheck-doc-syncandskill-token-counthooks tree-wide (rebased ontomainat feat(setup): probe prek and uv in the sandbox doctor #1362).magpie-run-evals.sh(claude -p).setup-isolated-setup-install: 13/13.setup-isolated-setup-verify: the new case passes. step-1 case-7 and step-2 case-3 / case-5 fail identically onmain. step-1 case-8 and step-2 case-4 failed once on grader wording and passed on rerun.step-1-classify/case-9-whole-user-hooks-unreadable(check 8 ✗). Caveat: it also passes againstmain'sconditional-checks.md, because the fixture's evidence is explicit enough that the model marks it ✗ without the new rule. It guards against regressions rather than proving the new rule is needed.RFC-AI-0004 compliance
Linked issues
Notes for reviewers (optional)
core.hooksPath, sosandbox-error-hint.shhas nothing to match. The verify probe is where this surfaces.test -ras check 8, now that probe 7 (feat(setup): probe prek and uv in the sandbox doctor #1362) has landed.~/.claude/may stay hidden until Claude Code restarts. That's what was observed: grants for~/.local/bin/~/.cachetook effect on the next command, but~/.claude/git-hooksdid not appear in the sandbox's view of~/.claude/during the session that added it.Generative AI disclosure: this change was prepared with Claude Code (Claude Opus 5) and reviewed by the author before submission.
🤖 Generated with Claude Code