pre-commit-conventions
Skill7 starsChanged 2 days agoMITView on GitHub
pre-commit configuration and hook choice. TRIGGER when: creating or editing `.pre-commit-config.yaml`; adding, replacing or bumping a hook; a hook only ships a `docker` variant; setting up linting for a repo with YAML (`.yamllint.yaml`); wiring a test suite (`pytest`, `cargo test`, …) into a commit gate; user asks why a hook is slow or needs Docker. SKIP when: not touching pre-commit configuration.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- leroyguillaume/claudeword for word, first seen Nov 29, 2026
Other versions1 project uses a version of this.
Word for word · 1
- leroyguillaume/claude★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository54 other files it gives its agents.
- adr-conventionsSkill
- api-conventionsSkill
- architecture-conventionsSkill
- argocd-conventionsSkill
- ci-conventionsSkill
- config-conventionsSkill
- contributing-conventionsSkill
- councilSkill
- cryptography-conventionsSkill
- dependency-update-conventionsSkill
- diagram-conventionsSkill
- docker-conventionsSkill
- documentation-conventionsSkill
- frontend-conventionsSkill
- github-actions-conventionsSkill
- github-issue-conventionsSkill
- github-pr-conventionsSkill
- github-repo-settingsSkill
- gitlab-ci-conventionsSkill
- helm-conventionsSkill
- herdr-core-delegationSkill
- herdr-delegationSkill
- herdr-tui-delegationSkill
- kopf-conventionsSkill
- kubernetes-operator-conventionsSkill
- logging-conventionsSkill
- logo-conventionsSkill
- mise-conventionsSkill
- ollama-conventionsSkill
- openssf-conventionsSkill
- pr-conventionsSkill
- project-metadata-conventionsSkill
- python-async-conventionsSkill
- python-conventionsSkill
- readme-conventionsSkill
- release-script-conventionsSkill
- release-supply-chain-conventionsSkill
- renovate-ci-conventionsSkill
- rest-conventionsSkill
- rust-build-conventionsSkill
- rust-conventionsSkill
- rust-http-conventionsSkill
- security-policy-conventionsSkill
- signal-handling-conventionsSkill
- sql-conventionsSkill
- starlight-conventionsSkill
- systemd-conventionsSkill
- system-user-conventionsSkill
- task-conventionsSkill
- terraform-conventionsSkill
- topic-splittingSkill
- ui-copy-conventionsSkill
- web-layout-conventionsSkill
- yaml-conventionsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 49
Always run the tool directly.
- Very specific: line 203
It is not file-scoped: Every test hook ends up pass_filenames: false, so a one-word README fix pays for the whole suite.
- Distinctive: line 215
If a repo already has a test hook, remove it and add the CI job in the same change — dropping the hook without wiring the suite into CI is …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
pre-commit conventions
Baseline hooks
Every repo gets these from pre-commit/pre-commit-hooks, whatever its
stack:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: <latest tag SHA> # frozen: <latest tag>
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args:
- --allow-multiple-documents
exclude: ^charts/[^/]+/templates/
- id: check-added-large-files
exclude: ^(.*/)?(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lock|uv\.lock|Cargo\.lock|poetry\.lock)$
- id: check-merge-conflict
- id: detect-private-keyThe exclude on check-added-large-files keeps lockfiles out of the size
check: they are legitimately large and must stay versioned, and widening
--maxkb for everything would be worse. Keep only the patterns of the
lockfiles the repo has (bun.lockb for Bun < 1.2).
On top of them: the yamllint and commit-msg hooks below, and the hooks the
matching skill lists for every technology present in the repo.
Never use Docker-backed hooks
No hook may use language: docker or language: docker_image. Docker
hooks pull an image, need a running daemon, break on machines/CI runners
without Docker, are slow on macOS, and mangle file paths through bind mounts.
Always run the tool directly. In order of preference:
- An upstream hook with a native language (
python,golang,rust,node,system, …). Many repos publish both variants under different ids — pick the non-Docker one. - A
repo: localhook withlanguage: system, calling the binary fromPATH.
One deliberate exception to that order: Biome runs as a local system hook
(frontend-conventions). The upstream biomejs/pre-commit hook installs its
own Biome through additional_dependencies, a second version to keep in step
with the one in the lockfile.
Known repos that ship both variants
| Tool | ❌ Docker id | ✅ Use instead |
hadolint (hadolint/hadolint) | hadolint-docker | hadolint (language: system) |
shellcheck (koalaman/shellcheck-precommit) | shellcheck — Docker only, whole repo unusable | shellcheck-py/shellcheck-py |
Canonical shellcheck hook
koalaman/shellcheck-precommit exposes only a docker_image hook, so drop
the repo entirely and use shellcheck-py, a pip wheel bundling the binary:
native, nothing to preinstall, and the version is pinned in the config.
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: <latest tag SHA> # frozen: <latest tag>
hooks:
- id: shellcheckA local language: system hook calling a shellcheck from PATH is the
fallback for a runner that cannot install the wheel; the binary is then a
prerequisite (contributing-conventions) and CI installs it before
pre-commit.
Always include yamllint
Every repo containing YAML gets a yamllint hook, alongside a
.yamllint.yaml at the root. check-yaml only proves a file parses; it says
nothing about how it is written, which leaves yaml-conventions resting on
whoever happens to be reviewing.
- repo: https://github.com/adrienverge/yamllint
rev: <latest tag SHA> # frozen: <latest tag>
hooks:
- id: yamllint
# Warning-level rules (document-start among them) are printed and then
# ignored without this — the hook passes anyway.
args:
- --strict
# A Helm template is Go templating, not YAML, until it is rendered.
exclude: ^charts/[^/]+/templates/The hook is language: python upstream, so no Docker and nothing to
preinstall. Start from extends: default and state only the deviations — most
repos already satisfy the default ruleset, and dropping it to enable two rules
throws away indentation, key-duplicates and document-start for nothing:
extends: default
rules:
# yaml-conventions: no `---` opening a file. Add a per-rule `ignore:` for any
# genuinely multi-document file — the separators between documents are
# required syntax and the rule cannot tell them from a stylistic opener.
document-start:
present: false
# yaml-conventions: block style only. `non-empty` still allows `{}` / `[]`.
braces:
forbid: non-empty
brackets:
forbid: non-empty
# Disable rather than tune: a digest-pinned image reference alone is ~150
# characters, and a helm-docs annotation is one line per key by construction.
line-length: disable
# A GitHub workflow's trigger key is a bare `on:`, which YAML 1.1 reads as a
# boolean: checking keys fails every workflow. Values are still checked.
truthy:
allowed-values:
- 'true'
- 'false'
check-keys: false
# The default of 2 rejects `uses: org/action@<sha> # v4.2.0`, the
# single-space pin comment most tools and hand edits produce.
comments:
min-spaces-from-content: 1Three traps worth knowing:
- Without
--strict, yamllint exits 0 on warnings.document-startis a warning by default, so the finding is printed and the hook goes green. --strictturns the default ruleset's warnings into failures, sotruthy(keys checked) andcomments(two spaces before an inline comment) fail GitHub workflows unless they are tuned as above.- A rule that fires on a file it cannot be satisfied on (
document-starton a multi-document manifest) needs a per-ruleignore:, not a global one — a top-levelignore:drops the file from every rule.
Always reject co-authors in commit messages
Every repo gets a commit-msg hook that fails on any Co-Authored-By:
trailer or any Generated with … line, whoever or whatever they name. A
commit has one author; a line that slips through lands in a client's history
for good. The hook makes the rule mechanical instead of a matter of attention.
default_install_hook_types:
- pre-commit
- commit-msg
repos:
- repo: local
hooks:
- id: no-co-authors
name: no co-authors in commit message
entry: '^\s*co-authored-by:|\bgenerated with\b'
language: pygrep
args:
- --ignore-case
stages:
- commit-msgTraps:
default_install_hook_typesis mandatory. A plainpre-commit installonly installs thepre-commithook type; without this key thecommit-msghook is declared and never runs. In a repo that already had pre-commit installed, re-runpre-commit installonce.\bin front ofgeneratedis deliberate: without it, a legitimatedocs regenerated with helm-docswould be rejected.- Never use
--no-verifyto get a commit through this hook. A failure means the message is wrong: rewrite it. pre-commit run --all-files(and so CI) skipscommit-msghooks — the hook guards local commits only.
Never run tests from a hook
No hook runs a test suite. Not cargo test, not pytest, not vitest,
not go test, not npm test — whatever the language, whatever the id it is
given. pre-commit is a lint gate: fast, deterministic, file-scoped checks
that a developer can afford on every single commit.
A test suite is none of those things:
- It is slow, and it only gets slower. A gate that costs thirty seconds is
a gate people start bypassing with
--no-verify— and a gate that gets bypassed protects nothing, including the linters that were fine. - It is not file-scoped. Every test hook ends up
pass_filenames: false, so a one-word README fix pays for the whole suite. - It needs an environment the hook cannot promise — a database, a fixture server, a built front end, network access. When that environment is missing locally the hook fails on code that is perfectly good.
- CI already runs it, and runs it better — on a clean checkout, in parallel, with the services it needs.
So: the test suite belongs in CI, in the quality workflow next to
pre-commit run --all-files (see ci-conventions), as its own
job. Not in .pre-commit-config.yaml.
If a repo already has a test hook, remove it and add the CI job in the same change — dropping the hook without wiring the suite into CI is how a suite stops being run at all.
Type checking is not a test: tsc --noEmit, mypy and clippy are static
analysis, they stay in pre-commit.
Other rules
- Pin every
revto a full commit SHA, with the tag as a comment; nevermaster/main, never a bare tag: a tag can be moved, and hooks run in CI (ci-conventions).pre-commit autoupdate --freezewrites it as# frozen: <tag>, and Renovate'spre-commitmanager, once enabled, bumps the SHA and the comment together (dependency-update-conventions). - A
rev, image tag or tool version written into a file is resolved when you write it, never from memory. Look up the upstream's latest release (gh release view -R <owner>/<repo> --json tagName, or the registry) and write that; then take the commit it points to for arev(gh api repos/<owner>/<repo>/commits/<tag> --jq .sha). Snippets in skills show a placeholder (<latest tag>) for that reason. - Local hooks always set
language: systemplus eithertypes:/files:orpass_filenames: false— an unfiltered local hook runs on every file in the repo. The exception is a pure regex check, which useslanguage: pygrep; acommit-msg-only hook needs no filter, it is only ever handed the message file. - YAML block style only in
.pre-commit-config.yaml: writetypes:/args:as a list of-items, never[shell]/[--fix]. Seeyaml-conventions. - Group all
repo: localhooks under a single- repo: localentry.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

