Add opt-in raw-git nudge hook, independent of anti-chaining hook
Forces a normal confirmation prompt (never a silent block, never a silent allow) when Bash runs raw git instead of git_cmd.sh, worded more insistently when the subcommand is one the wrapper already supports. Raw git stays a valid fallback for unsupported subcommands and unregistered repos - a hard deny would remove that fallback entirely. Also documents in SKILL.md that repo ambiguity (which registered repo is meant, or none at all) must be resolved by asking the user rather than guessing - a hook only sees the literal command string, not the conversation, so that judgment can't live in the hook itself.
This commit is contained in:
+17
-5
@@ -19,8 +19,8 @@ to locate the plugin itself.
|
||||
|
||||
## 1. Ask the user — three selectable questions first, repo path last
|
||||
|
||||
**1a. First turn: three questions via the selection UI, fixed options for
|
||||
all three:**
|
||||
**1a. First turn: four questions via the selection UI, fixed options for
|
||||
all four:**
|
||||
- Whether to register any repos at all: yes/no.
|
||||
- Settings scope: `project` (`.claude/settings.json` in the current
|
||||
project) or `user` (`~/.claude/settings.json`). Mention: if they work
|
||||
@@ -32,6 +32,16 @@ all three:**
|
||||
`|`, backticks, `$(...)`), as a safety net given Claude Code's Bash
|
||||
allow-list matching has had bugs around compound commands (see
|
||||
`hooks/force-ask-on-chaining.sh` for details).
|
||||
- Ask-before-raw-git hook: yes/no, after explaining it never silently
|
||||
blocks or silently allows anything either — it only forces the normal
|
||||
confirmation prompt when a Bash command runs raw `git` instead of the
|
||||
`git_cmd.sh` wrapper. It never fully blocks raw git (that stays a valid
|
||||
fallback for subcommands the wrapper deliberately doesn't support, e.g.
|
||||
`stash`/`merge`/`rebase`/`reset`, or for repos that aren't registered
|
||||
yet) — it just makes sure raw git use is always a visible, confirmed
|
||||
choice rather than something that slips through unnoticed (see
|
||||
`hooks/force-ask-on-raw-git.sh` for details). Independent of the
|
||||
anti-chaining hook — either, both, or neither can be installed.
|
||||
|
||||
**1b. Only if the answer to "register any repos" was yes: a second turn,
|
||||
plain chat message, no tool call.** Ask exactly: "Which repos should
|
||||
@@ -57,11 +67,13 @@ this has since changed), that's:
|
||||
--settings-scope <project|user> \
|
||||
[--project-dir <path>] \
|
||||
[--repo <name>=<path> ...] \
|
||||
[--install-hook]
|
||||
[--install-hook] \
|
||||
[--install-raw-git-hook]
|
||||
```
|
||||
|
||||
Include `--repo name=path` once per repo from step 1, `--install-hook` only
|
||||
if the user opted in, and `--project-dir` only if `--settings-scope
|
||||
Include `--repo name=path` once per repo from step 1, `--install-hook` and
|
||||
`--install-raw-git-hook` only for the ones the user opted into (they're
|
||||
independent flags), and `--project-dir` only if `--settings-scope
|
||||
project` and the project isn't the current working directory. Try this
|
||||
path directly first — don't `find`/`ls` preemptively.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user