pre-commit

A pre-commit checklist for a Go project that checks the branch, updates the unreleased changelog, formats code, and tidies dependencies.

In plain words
What is it for?
Use it before committing feature or bug work to compare with the remote master branch, update CHANGELOG.md, run Go formatting, and review go.mod or go.sum changes.
Why use it?
It catches branch, formatting, changelog, and dependency issues before changes are committed. It also flags unexpected edits caused by dependency cleanup.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/nanotaboada/go-samples-gin-restful/pre-commit
Clone the repo
git clone --depth 1 https://github.com/nanotaboada/go-samples-gin-restful

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 750 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00750
Opus 5 $0.00000 $0.00375
Sonnet 5 $0.00000 $0.00150
Haiku 4.5 $0.00000 $0.00075

Measured 2d ago against content hash cc664a57749e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pre-commit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/pre-commit.md · 35 lines

What it actually says

Before running the checklist, run git fetch origin. If the current branch is behind origin/master, stop and rebase before proceeding.

Run the pre-commit checklist for this project:

  1. Update CHANGELOG.md [Unreleased] section — read the current CHANGELOG.md, inspect git diff to understand what changed, then write the appropriate entry under the correct subsection (Added / Changed / Fixed / Removed), referencing the issue number. If the [Unreleased] section already contains an entry that covers these changes (e.g. added during release branch preparation via /pre-release), skip this step. Also skip this step for tooling/maintenance changes with no backing GitHub issue — feature and bug work should already have an issue per this project's SDD workflow, so this exception does not apply to them.

  2. Run go fmt ./...

  3. Note whether go.mod/go.sum already have uncommitted changes before running go mod tidy (git diff --stat -- go.mod go.sum). Run go mod tidy, then compare again — if tidy introduced additional changes beyond that baseline, stop and report it — propose committing the tidy result first and wait for my explicit confirmation before doing so.

  4. Run go vet ./... — must pass.

  5. Run go build -v ./... — must succeed.

  6. Ask me: were any Swagger annotations modified? If yes, run swag init.

  7. Run go test -v ./... -coverpkg=github.com/nanotaboada/go-samples-gin-restful/service,github.com/nanotaboada/go-samples-gin-restful/controller,github.com/nanotaboada/go-samples-gin-restful/route -covermode=atomic -coverprofile=coverage.out — all tests must pass, target 80%+ coverage for service, controller, route packages.

  8. If Docker is running, run docker compose build — must succeed with no errors. Skip this step with a note if Docker Desktop is not running.

  9. If coderabbit CLI is installed and coderabbit review --help reports --agent support, run coderabbit review --type uncommitted --agent:

    • If actionable/serious findings are reported, stop and address them before proposing the commit.
    • If only nitpick-level findings, report them and continue to the commit proposal.
    • If coderabbit is not installed, or the installed version does not support --agent, skip this step with a note.

Run step 1 (CHANGELOG update), then run steps 2–3 sequentially (stop at step 3 if go.mod or go.sum changed), then ask about step 6 and run swag init first if needed, then run steps 4, 5, and 7 in parallel, run step 8 (docker build), then run step 9 (CodeRabbit review) if available, report the results clearly, then propose a branch name and commit message for my approval using the format type(scope): description (#issue) (max 80 chars; types: feat fix chore docs test refactor ci perf) with the required Co-Authored-By: Claude Sonnet 5 <[email protected]> line. Do not create the branch or commit until I explicitly confirm.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 35 lines · 0 tokens per session scan A cc664a57749e

Subscribe to this mod's changes

pre-commit is a command published in the GitHub repository nanotaboada/go-samples-gin-restful (2 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 750 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.