setup-pre-commit

setup-pre-commit is a command for Claude Code from refo/claude-dev-helpers. It costs 42 tokens per session (1,294 once invoked), scanned B, original, MIT.

A setup for pre-commit hooks, which are automatic checks that run when you create a Git commit. It detects the project's programming tools and configures formatting, linting, type checks, and tests.

In plain words
What is it for?
Use it to add or configure commit-time quality checks for a project's chosen language and tools, including checks on changed files and a suitable set of tests.
Why use it?
It catches common code problems before they enter the project history. It also aims to keep the checks fast enough that developers do not skip them.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the dev-helpers plugin — 13 commands, 1 hook shipped together

Good fit Use it to add or configure commit-time quality checks for a project's chosen language and tools, including checks on changed files and a suitable set of tests.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/refo/claude-dev-helpers/setup-pre-commit
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.

Clone the repo
git clone --depth 1 https://github.com/refo/claude-dev-helpers

Made for: Claude Code.

Or install dev-helpers, the plugin that ships this one along with the rest of its 13 commands, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for setup-pre-commit

README.md
[![agentmods](https://agentmods.dev/badge/commands/refo/claude-dev-helpers/setup-pre-commit/github.svg)](https://agentmods.dev/commands/refo/claude-dev-helpers/setup-pre-commit)
Your own site
<a href="https://agentmods.dev/commands/refo/claude-dev-helpers/setup-pre-commit"><img src="https://agentmods.dev/badge/commands/refo/claude-dev-helpers/setup-pre-commit/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for setup-pre-commit

Your own site · 80×15
<a href="https://agentmods.dev/commands/refo/claude-dev-helpers/setup-pre-commit"><img src="https://agentmods.dev/badge/commands/refo/claude-dev-helpers/setup-pre-commit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,294 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00042 $0.01294
Opus 5.5 $0.00017 $0.00518
Sonnet 5.5 $0.00008 $0.00259
Haiku 4.5 $0.00004 $0.00129

Measured 1mo ago against content hash deebbb848ec0, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

setup-pre-commit scanned grade B with 1 finding 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 1mo 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

- Project helpers config (if present): !`cat .claude/helpers.json 2>/dev/null || echo "no helpers.json — detect stack from project files"`
plugins/dev-helpers/commands/setup-pre-commit.md · 87 lines

How it starts

The opening of the file, as written. The whole thing — 87 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Setup Pre-Commit

Context

  • Project helpers config (if present): !cat .claude/helpers.json 2>/dev/null || echo "no helpers.json — detect stack from project files"
  • Lockfiles and manifests: !ls -1 package.json bun.lock bun.lockb pnpm-lock.yaml yarn.lock package-lock.json pyproject.toml uv.lock poetry.lock requirements.txt go.mod Cargo.toml Gemfile mix.exs composer.json 2>/dev/null || true
  • Existing config files: !ls -1 biome.json .eslintrc* .prettierrc* ruff.toml .pre-commit-config.yaml lefthook.yml lefthook.yaml .husky 2>/dev/null || true

Goal

Install a pre-commit hook that runs (in this order):

  1. Format + lint on staged files
  2. Typecheck (if the language has one)
  3. Tests (fast subset if possible, otherwise full suite)

The goal is to catch bad commits before they happen, without slowing down git commit so much that the user starts using --no-verify.

Process

1. Detect the stack and pick the right tools

Read helpers.json first. If present, use the values from tooling.preCommitFramework, tooling.linter, commands.test, commands.typecheck, commands.lint, commands.format. Skip detection.

Otherwise, detect from the project files shown in Context above and pick the conventional stack:

Detected Pre-commit framework Linter / Formatter Typecheck Test
bun.lock(b) husky biome tsc --noEmit (via bun run typecheck) bun test
pnpm-lock.yaml husky + lint-staged biome or eslint+prettier tsc --noEmit pnpm test
yarn.lock / package-lock.json husky + lint-staged eslint + prettier (or biome) tsc --noEmit npm test / yarn test
pyproject.toml + uv.lock pre-commit framework ruff (lint + format) mypy or pyright (if configured) pytest
pyproject.toml + poetry.lock pre-commit framework ruff or black + flake8 mypy or pyright pytest
go.mod lefthook (or native git hooks) gofmt, go vet, golangci-lint go build ./... go test ./...
Cargo.toml lefthook (or native git hooks) cargo fmt, cargo clippy cargo check cargo test
Gemfile overcommit or pre-commit rubocop (none — Ruby) bundle exec rspec
mix.exs native git hooks mix format, credo mix dialyzer (if installed) mix test

Read the full file on GitHub · 87 lines

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. 1mo ago First seen · 87 lines · 42 tokens per session scan B deebbb848ec0

Subscribe to this mod's changes

setup-pre-commit is a command published in the GitHub repository refo/claude-dev-helpers (2 stars, last pushed 3mo ago), licensed MIT. It adds 42 tokens to every session and 1,294 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.