Skip to content

build(hooks): add installable pre-commit hook (gofmt + go vet + golangci-lint --fast-only)#513

Merged
ericfitz merged 5 commits into
mainfrom
feature/precommit-hook
Jul 1, 2026
Merged

build(hooks): add installable pre-commit hook (gofmt + go vet + golangci-lint --fast-only)#513
ericfitz merged 5 commits into
mainfrom
feature/precommit-hook

Conversation

@ericfitz

@ericfitz ericfitz commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a tracked, installable Git pre-commit hook that runs lightweight static analysis on staged Go files and blocks the commit on failure.

  • scripts/hooks/pre-commit — on staged Go files only, runs gofmtgo vetgolangci-lint run --fast-only (scoped to the staged files' package dirs), aggregates failures, and blocks the commit (exit 1) on any failure. No-op when no Go files are staged. Honors the existing .golangci.yml exclusions. Missing golangci-lint fails with an install hint (never silently skips). Bypass with git commit --no-verify.
  • scripts/hooks/post-commit — the existing version-bump hook, relocated verbatim from the untracked .git/hooks/post-commit so it survives the switch to core.hooksPath.
  • make install-hooks — points git config core.hooksPath at scripts/hooks; run once per clone. Output notes it supersedes any personal .git/hooks/.

Design & plan

  • Spec: docs/superpowers/specs/2026-07-01-precommit-hook-design.md
  • Plan: docs/superpowers/plans/2026-07-01-precommit-hook.md

Verification

  • make install-hooks sets core.hooksPathscripts/hooks; relocated post-commit is byte-for-byte identical to the original (version-bump behavior preserved, --amend --no-verify recursion guard intact).
  • Docs-only commit → no Go checks run. Misformatted staged Go file → commit aborted. --no-verifybypasses.
  • make lint passes (0 issues).

Reviewed task-by-task plus a whole-branch review (verdict: ready to merge; only non-blocking cosmetic findings).

🤖 Generated with Claude Code

ericfitz and others added 5 commits July 1, 2026 12:34
…ev target

Three independent developer-tooling designs from a brainstorming session:
- pre-commit hook (gofmt + go vet + golangci-lint --fast-only, blocking)
- CI security scanners (govulncheck blocking + standalone gosec informational)
- k3s dev deployment target (CLUSTER=k3s, self-contained remote cluster)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk9GxWS9EpazjbwBKfMpUX
…s, k3s dev target

One plan per spec:
- pre-commit hook (2 tasks)
- CI security scanners (4 tasks)
- k3s dev target (6 tasks + pre-flight); flags migration-Job -> startup-AutoMigrate deviation

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk9GxWS9EpazjbwBKfMpUX
@ericfitz ericfitz merged commit 1ad7887 into main Jul 1, 2026
9 checks passed
@ericfitz ericfitz deleted the feature/precommit-hook branch July 1, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant