feat(claude): leave only git fetch origin unasked #206
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fetch-origin-exclusion"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Every change starts with
open-worktree, which runsgit fetchon themain branch's remote. The
Bash(git fetch *)ask rule made Claude Codeprompt for that fetch in every permission mode,
bypassPermissionsincluded, so a session running several changes answered the same prompt
each time. The rule guarded the
git fetch *sandbox exclusion, which aquoted, escaped, or variable spelling of
--upload-packcould ride outof the sandbox past the text deny rule.
Set aside: keeping the ask rule, which keeps the prompt; a Bash
PreToolUsehook that checks which repository the fetch runs in, a newmechanism that needs its own design; dropping the ask on
git pullandgit pushtoo, which saves no prompt a workflow meets.What changed
Before, any
git fetchleft the sandbox and asked first. Now only theexact command
git fetch originleaves it, with no ask rule: it followsthe permission mode, asking in Manual and
acceptEditsunless adeveloper's allow rule covers it, going to the classifier in auto mode,
and running unasked in
bypassPermissions. A fetch with options, quotes,escapes, or variables, or of another remote, runs sandboxed and falls to
the usual unsandboxed retry when it fails.
git pullandgit pushkeeptheir exclusion and their ask rule.
The README's sandbox paragraph now names the three git commands that
leave the sandbox, says when each prompts in each mode and why pull and
push always ask, and states the residual below.
How to verify
In a Claude Code session on the branch where the sandbox starts, in
bypassPermissionsmode, ask Claude to rungit fetch origin: it runswith no prompt, where
mainasks first. Then ask it to rungit fetch --prune origin: it runs sandboxed, and over SSH fails and isretried outside the sandbox.
git push origin <branch>still prompts.On
b9215a5,bash tests/verify-agent-config.sh(231 tests),bash tests/check-work-folder.sh,.agents/hooks/shellcheck.sh repo,prettier --check '**/*.md',scripts/verify-agent-config.sh, andgit diff --check mainpass; the rewritten settings assertion fails onmain. Not tried: a live session, since the sandbox could not start inthe container the work ran in, so whether
git fetch originprompts inManual mode, outside Claude Code's read-only git set, is unconfirmed.
Considerations
The exact exclusion fixes the command text, not the repository it runs
in. A sandboxed command can prepare a repository outside the checkout's
protected
.git, and the unasked fetch then runs with itsconfiguration, so an injected instruction could have it run a program on
the host with no prompt in auto mode or under a developer's allow rule.
The maintainer accepts that for the fetch every change starts with; in
bypassPermissionsan unsandboxed retry already runs unasked.