Repository navigation
Block agent commands that skip git hooks - #55
Merged
Merged
Conversation
homeSpec.agents.gitHookGuard (on by default) adds a claude-code PreToolUse hook on Bash that blocks git commands skipping the git hooks: --no-verify, git commit -n, core.hooksPath, PREK_ALLOW_NO_CONFIG or SKIP. The org shell's hooks (external-systems/pkgs#45) are part of the gate and the ground rules (external-systems/skills#25) say never to skip them; this enforces it for the agent. The command is parsed with shlex, so a commit message that mentions a flag is not a false hit. Bumps skills (the new ground rule) and org-pkgs (git hooks, sync-locks), and opts this repo in to the org git hooks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andrewthomaslee
enabled auto-merge (squash)
November 26, 2026 11:24
andrewthomaslee
added a commit
to external-systems/home
that referenced
this pull request
Nov 26, 2026
## What - `devenv.yaml`: follows `org-pkgs/git-hooks`, which opts home in to the org shell's git hooks (external-systems/pkgs#45). - `.gitignore`: `.pre-commit-config.yaml` (the shell writes it as a link into the nix store). - `devenv.nix`: a `pre-push` hook, `clan vars check`, on top of the org `fmt` pre-commit hook. It uses the real clan binary (no key, no 1Password prompt) through an absolute path, so it also works from a plain shell outside devenv. - `flake.lock` / `devenv.lock`: bumps `org-pkgs` (with `sync-locks`) and `modules`. That brings in the skills ground rule (external-systems/skills#25) and the claude git hook guard (external-systems/modules#55). - `AGENTS.md`, `documentation/docs/machines/index.md`: say where `clan vars check` runs now (`check`, pre-push) and the worktree note. ## Why CI's `checks.clan-vars-present` only checks that the vars files exist. `clan vars check` also validates hashes and recipients, but until now it only ran if someone ran `check` by hand. Now every push runs it. ## Checks - `fmt`: clean. `check`: all checks passed; `clan vars check` passed for all 6 machines. - This commit went through `fmt` on pre-commit (Passed), and the push went through `clan vars check` on pre-push (Passed, about 2.7s for the whole push). - I re-ran the pre-push hook with an empty environment (no `DEVENV_*` variables, only HOME and the system PATH): Passed. So an agent pushing from a plain shell gets the check, and the private `secrets` input resolves. ## Reviewer notes - **No machine change on merge.** The modules bump changes the netsa and matt home-manager profiles (claude settings get the PreToolUse guard; CLAUDE.md gets the new ground rule). Those only reach machines with a deploy, which is the owner's call: `clan machines update <machine>` from `main`. - After merging, enter the shell once in the home clone, and in any existing worktree, so each has its hook config. ## Merge order pkgs#45, skills#25 and modules#55 (all merged), then **this** (last). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
flake-parts/homeModules/agents/_git-hook-guard.nix(new):agent-git-hook-guard, a Python script. It's a claude-codePreToolUsehook on Bash, and it exits 2, which blocks the tool call, when a git command skips the hooks:--no-verifyon any subcommandgit commit -n, also inside a short-option cluster like-anmcore.hooksPathset throughgit -corgit configPREK_ALLOW_NO_CONFIGorSKIPset on a git commandIt checks every part of a compound command, and inside
sh -c/bash -c. It parses the command withshlex, so text that only mentions a flag (a commit message,echo,grep) isn't blocked.agents.nix: new optionhomeSpec.agents.gitHookGuard.enable(defaulttrue). When on, it adds the hook to~/.claude/settings.json(hooks.PreToolUse).tests/flake-module.nix:checks.agents-git-hook-guard: 13 blocked and 9 allowed commands, plus non-JSON inputagents-wiringnow asserts the PreToolUse hook is present.README.md: documents the option.Bumps
skills(the new ground rule, Git hooks in the org standard; never skip them skills#25) andorg-pkgs(git hooks, Add git hooks to the org devenv shell pkgs#45) withsync-locks.Opts modules in to the org git hooks:
devenv.yamlfollowsorg-pkgs/git-hooks, and.pre-commit-config.yamlis gitignored.Why
The ground rules now say agents never skip git hooks. This makes it hold for claude. The owner can still skip a hook from their own shell, or with claude's
!prefix, which runs outside the agent's tool calls.Only claude gets the guard for now. pi, kimi and opencode would each need their own hook format; that can be a follow-up.
Checks
fmt: clean.check: all checks passed, incl. the newagents-git-hook-guard. One existing non-fatal eval warning (stdenv.isDarwindeprecated).Blocked: this git command uses git commit -n, which skips the git hooks. … If a skip is really needed, ask the owner to run the command.(exit 2)fmtgit hook (Passed).Merge order
pkgs#45 and skills#25 (both merged), then this, then home (bumps
modules,skillsandorg-pkgs, opts in, adds theclan vars checkpre-push hook). Reaches machines only after a deploy from home.🤖 Generated with Claude Code