Repository navigation
Add git hooks to the org devenv shell - #45
Merged
Merged
Conversation
The org shell now installs a pre-commit hook (cachix/git-hooks.nix via devenv, run by prek) that runs `nix fmt -- --ci`, so unformatted code is caught at commit instead of in CI. devenv reads inputs only from a repo's own devenv.yaml, not from the imported org-pkgs/devenv, so pkgs pins git-hooks in flake.lock and each repo opts in with `git-hooks.follows: org-pkgs/git-hooks`. Until it does, the hooks stay off and the shell prints a note (an enabled hook with no input would fail devenv). lock-sync now also checks git-hooks, and sync-locks re-pins pkgs' own devenv.yaml. Worktrees share the clone's hooks but each reads its own generated .pre-commit-config.yaml, so `worktree new` enters the shell once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andrewthomaslee
enabled auto-merge (squash)
November 26, 2026 11:15
andrewthomaslee
added a commit
to external-systems/skills
that referenced
this pull request
Nov 26, 2026
Ground rules: agents never skip git hooks (--no-verify, -n, core.hooksPath, PREK_ALLOW_NO_CONFIG) unless the owner says so, and enter the devenv shell in a new worktree before its first commit (the hook config is per worktree). The flake standard reference documents the org shell's git hooks (external-systems/pkgs#45): the opt-in (follows org-pkgs/git-hooks, the .gitignore line, the bump order), repo hooks and worktrees. This repo opts in: org-pkgs bumped with sync-locks, devenv.yaml follows org-pkgs/git-hooks, .pre-commit-config.yaml ignored. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
andrewthomaslee
added a commit
to external-systems/modules
that referenced
this pull request
Nov 26, 2026
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
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
devenv/devenv.nix: the org shell installs apre-commithook,fmt, that runsnix fmt -- --ci. It's on only when the repo'sdevenv.yamlhas agit-hooksinput. Without the input, entering the shell prints a one-line note to stderr instead.flake.nix/flake.lock: newgit-hooksinput (cachix/git-hooks.nix; nixpkgs follows, flake-compat dropped). It's lazy: no flake evaluation fetches it.devenv.yaml/devenv.lock(pkgs' own shell): git-hooks is pinned to theflake.lockrev, the same way nixpkgs is.flakeModules/dev.nix:checks.lock-syncalso fails whendevenv.lock's git-hooks differs from whatflake.lockresolves (throughorg-pkgsin consumers, directly in pkgs).sync-locksre-pins pkgs' owndevenv.yaml.resolvenow returns null for a missing input instead of throwing.devenv/worktree.sh:worktree newenters the devenv shell once, so the new worktree has its hook config before the first commit.templates/default/devenv.yaml,.gitignores: new repos followorg-pkgs/git-hooksand ignore.pre-commit-config.yaml.flake-standard.mdhas a new "Git hooks" section (opting in, repo hooks, worktrees). The README mentions it too.Why
Unformatted code is caught at commit instead of in CI. A repo can also add its own fast hooks, e.g. home's
clan vars checkon pre-push.What I tested
I used a throwaway local clone of skills with
org-pkgsset to this branch's worktree.org-pkgs/devenv/devenv.yamldevenv.yamlonly. That's why each repo needs thefollowslinegit-hooks.follows: org-pkgs/git-hooksdevenv.lockgit-hooks = pkgs'flake.lockrev (5c6bf7c).nix--fail-on-change). treefmt fixes the file;git addand commit again passes. About 2sgit commit --no-verify.gitignorelacks.pre-commit-config.yamlgit add -Acommits the nix-store symlink. That's why the.gitignoreline is part of opting inconfig file not found(the hooks are shared, the config is per worktree). Afterdevenv shell -- true, it commits.worktree newnow does thisPREK_ALLOW_NO_CONFIG=1works once; rebasing ontomainfixes itdevenv.yamlset to an older rev)lock-syncfails and names it;sync-locksrestores it, thenlock-syncpassesChecks
fmt: clean.check: all checks passed.fmt … Passed).Reviewer notes
nix flake update org-pkgs+sync-locks, thefollowsline, and the.gitignoreline.🤖 Generated with Claude Code