Skip to content

A fast pre-commit hook installs itself when a Claude session starts #31

Closed

Description

@sodre

What to build

A fast pre-commit hook for this repository, installed without anyone running a setup step.

Countersign has no guardrail before CI: no pre-commit or pre-push hook, and docs/develop.md lists five separate check commands. While building #28, an agent ran the runtime test as … | tail -3 && git commit; the pipe hid the test's failure and the commit went through.

The hook must be fast, because it runs on every commit: only checks that finish in a few seconds on the staged change (formatting, and whatever lint is cheap enough), never a build, the test suites or the runtime test. Those stay with CI.

It must also install itself when Claude starts a session in a checkout or worktree, through a hook in .claude/settings.json, so a fresh worktree has it before its first commit. The hook's code is tracked in the repository.

Acceptance criteria

  • A tracked pre-commit hook refuses a commit whose staged Rust files fail cargo fmt --check, and says how to fix it
  • The hook finishes in under five seconds on a commit that touches one Rust file and one Markdown file, measured and quoted in the pull request
  • The hook runs no build, no test suite and no network call
  • A session-start hook in .claude/settings.json installs the pre-commit hook in the checkout or worktree Claude starts in, and is a no-op when it is already installed
  • A commit made in a fresh worktree, after a session start and with nothing else run, goes through the hook
  • docs/develop.md says what the hook checks, how a person without Claude installs it, and that CI runs the slow checks

Open decisions

  • Which checks beyond cargo fmt are fast enough (for example pnpm lint on staged files): measure, then keep those under the budget.
  • How it installs: core.hooksPath pointing at a tracked folder is the smallest way and covers every worktree of a clone.

Decided in: retro of #28 (pull request #30), 2026-11-19; the owner asked for it, with the speed and the session-start requirements.
Live step at merge: none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions