pre-commit-setup
Skill1 starsChanged 4 months agoMITView on GitHub
Set up cross-language pre-commit hooks for any git repository — auto-formatting, linting, type-checking, secret scanning, large-file detection, and Conventional Commit message checks. Detects which languages the repo uses (Node.js / TypeScript, Python, PHP, Java, Go, Rust, Ruby, Shell, generic) and wires the right hooks via the universal pre-commit framework, with an optional Husky + lint-staged + Prettier track for pure-Node repos. Use whenever the user wants to add pre-commit hooks, set up husky, install pre-commit, configure lint-staged, run formatting/linting/typecheck/tests on commit, scan for secrets at commit time, enforce conventional commits, or hits you with phrases like 'set up pre-commit', 'add husky', 'wire up commit hooks', 'block secrets at commit', 'make my repo lint on commit', or 'configure git hooks'.
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- bcmyguest/personal-skillstheir own version, first seen Jul 16, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- bcmyguest/personal-skills★ 0same name
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 repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-auditSkill
- autodreamSkill
- deep-discoverySkill
- generic-by-designSkill
- gitops-cd-developerSkill
- gitops-pipeline-developerSkill
- golang-script-developerSkill
- humanizerSkill
- information-architectureSkill
- interactive-deck-builderSkill
- javascript-script-developerSkill
- linux-script-developerSkill
- makefile-script-developerSkill
- plan-interviewSkill
- python-script-developerSkill
- qaSkill
- skill-builderSkill
- teacher-modeSkill
- terraform-module-developerSkill
- typescript-script-developerSkill
- ui-deslopSkill
- xquik-x-dataSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
24 rules. About 0 are common, 11 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 43
After this runs, a fresh git commit in the repo must:
- Distinctive: line 47
Run type checks (where the language supports them).
- Very specific: line 56
Detect languages: Run bash scripts/detect-languages.sh or do the equivalent: check for package.json, pyproject.toml / requirements.txt / …
- Very specific: line 64
Install: Run pre-commit install (writes .git/hooks/pre-commit) and pre-commit install --hook-type commit-msg (for the commit-msg hook).
- Very specific: line 65
Smoke test: Run pre-commit run --all-files once.
- Distinctive: line 86
Detect first, configure second: Do not paste a Python-only or Node-only template into a polyglot repo.
- Very specific: line 89
Pin hook versions: Use rev: v1.2.3 not rev: main in .pre-commit-config.yaml.
- Very specific: line 95
Do not bypass with
--no-verifyto "fix" failing hooks: If hooks fail, fix the cause. - Very specific: line 102
Default to the pre-commit framework.
- Very specific: line 104
Add universal hooks: whitespace, EOF, large files, merge-conflict markers, JSON/YAML/TOML validation, secret scanner.
- Distinctive: line 105
Add commit-msg hook for Conventional Commits when appropriate (see gotchas).
- Very specific: line 107
Run pre-commit run --all-files once to surface and auto-fix the existing-file format drift.
- Distinctive: line 108
Commit the new config with a Conventional message.
- Distinctive: line 113
Do not paste a single-language template into a polyglot repo.
- Distinctive: line 114
Do not use Husky in a polyglot repo.
- Distinctive: line 115
Do not run full test suites in pre-commit (move to pre-push or CI).
- Very specific: line 116
Do not add gitleaks and detect-secrets together — pick one.
- Very specific: line 117
Do not use floating refs (rev: main, rev: HEAD) in .pre-commit-config.yaml.
- Distinctive: line 118
Do not silently overwrite an existing pre-commit config without showing the user the diff.
- Distinctive: line 119
Do not enforce Conventional Commits on a repo that doesn't use them, unless the user asked.
- Very specific: line 120
Do not bypass failing hooks with --no-verify to "make it pass".
- Distinctive: line 121
Do not add tooling for languages the repo doesn't use.
- Very specific: line 122
Do not introduce a Python dependency (pre-commit) into a Node-only repo if the user wants Husky — respect the explicit ask.
- Very specific: line 123
Do not commit a .pre-commit-config.yaml without first running it once and verifying it's clean.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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 setup
Wire pre-commit hooks into any git repo. Default to the universal pre-commit framework (works for any language); use Husky + lint-staged for pure-Node repos when the user explicitly asks. Always cover formatting, linting, type-checking (where applicable), secret scanning, and Conventional Commits.
When to use
- The user asked to set up pre-commit hooks, install husky, configure lint-staged, or wire up commit-time checks.
- A new repo is being bootstrapped and you're standardizing the dev experience.
- An existing repo has commit-time issues (secrets leaked, lint fails after merge, large files committed) and the user wants prevention.
- A monorepo or polyglot repo needs a single pre-commit configuration that covers multiple languages.
Skip this skill for: repos that already have a working pre-commit configuration the user is happy with (touch only with explicit ask), build-time CI checks (those belong in CI, not pre-commit), or pre-push hooks (different lifecycle).
Required outcome
After this runs, a fresh git commit in the repo must:
- Auto-format staged files (Prettier / Black / gofmt / etc., per language).
- Lint staged files (ESLint / Ruff / PHPStan / Checkstyle / golangci-lint / etc.).
- Run type checks (where the language supports them).
- Scan for secrets and large files.
- Validate the commit message format (Conventional Commits).
- Block the commit on any failure with a readable error.
- Be fast — the full pre-commit run should be under ~10 seconds for typical changes.
Workflow
- Verify a git repo.
git rev-parse --is-inside-work-tree. If not, ask whether togit initor stop. - Detect languages. Run
bash scripts/detect-languages.shor do the equivalent: check forpackage.json,pyproject.toml/requirements.txt/setup.py,composer.json,pom.xml/build.gradle*,go.mod,Cargo.toml,Gemfile,*.shfiles. Multiple matches → multi-language. - Pick the framework:
- Default → universal
pre-commitframework (pre-commit.com). Works for any language, has thousands of hook integrations. Loadreferences/pre-commit-framework.md. - Pure-Node repo + user explicitly asked for Husky → Husky + lint-staged + Prettier track. Load
references/husky-track.md. - Polyglot repo → always pre-commit framework. Husky doesn't handle non-JS files cleanly.
- Default → universal
- Pick the hooks per detected language. Load
references/language-hooks.mdand copy the matching block(s) into.pre-commit-config.yaml. Cover formatter, linter, and type-checker per language. - Add universal hooks. Load
references/universal-hooks.md. Always include trailing-whitespace, end-of-file-fixer, check-merge-conflict, check-added-large-files, check-yaml/json/toml (when present), and a secret scanner (gitleaksordetect-secrets). - Add commit-msg hook. Load
references/commit-msg.md. Wirecommitlint(Node) orcommitizen(cross-language) for Conventional Commits. - Install. Run
pre-commit install(writes.git/hooks/pre-commit) andpre-commit install --hook-type commit-msg(for the commit-msg hook). For Husky,npx husky init. - Smoke test. Run
pre-commit run --all-filesonce. Expect the first run to fix formatting on existing files; that's normal. Re-run to confirm it's clean. - Commit. Stage the new config files and commit with a Conventional message:
chore: add pre-commit hooks (formatter, linter, secrets, conventional commits). The commit itself is the final smoke test.
Available resources
references/pre-commit-framework.md— universalpre-commitframework: install,.pre-commit-config.yamlsyntax, common hooks, troubleshooting.references/husky-track.md— Node-only Husky + lint-staged + Prettier setup, plus the optional heavyweight variant that runs typecheck + tests on every commit.references/language-hooks.md— recommended formatter / linter / type-checker hooks per language: Node.js, Python, PHP, Java, Go, Rust, Ruby, Shell. Copy-paste blocks.references/universal-hooks.md— language-agnostic hooks: whitespace, EOF, large files, merge-conflict markers, JSON/YAML/TOML validation, secret scanners.references/commit-msg.md— Conventional Commits enforcement viacommitlintorcommitizen.assets/templates/pre-commit-config-multi-language.yaml— kitchen-sink config covering all languages this skill knows about.assets/templates/pre-commit-config-minimal.yaml— universal hooks only (whitespace, EOF, secrets, conventional commits) for unknown-language repos.assets/templates/husky-pre-commit— Husky v9 pre-commit script for Node repos.assets/templates/lintstagedrc.json— lint-staged config for the Husky track.assets/templates/prettierrc.json— Prettier defaults.assets/examples/full-example.md— worked setup on a polyglot repo.scripts/detect-languages.sh— detect what languages a repo uses; run before picking hooks.
Top gotchas (always inline — do not skip)
- Polyglot repo → use
pre-commit, not Husky. Husky + lint-staged works well for pure-JS, but fights non-JS files and doesn't have ecosystem coverage for Python / Java / PHP / Go. Thepre-commitframework is the universal answer. - Detect first, configure second. Do not paste a Python-only or Node-only template into a polyglot repo. Run the detection step or you'll ship hooks that fail loudly on every commit.
pre-commitis a Python tool, not a JS tool. It runs hooks for any language, but it itself installs viapip install pre-commit(orpipx, orbrew install pre-commit). Don't confuse it with Husky.- The first
pre-commit run --all-fileswill modify existing files. Formatters fix existing whitespace, EOF, formatting. That's expected — commit the auto-fixes, then re-run. The user should know this before you run it. - Pin hook versions. Use
rev: v1.2.3notrev: mainin.pre-commit-config.yaml.pre-commit autoupdateis the maintenance command for bumping. Floating refs break repos when upstream changes. - Don't run full test suites in pre-commit. Tests take too long; pre-commit should be < 10s. Tests belong in pre-push or CI. The heavyweight Husky variant runs
npm run testin pre-commit; that's a trade-off the user should opt into, not a default. - Type-checking is repo-scoped, not file-scoped. ESLint runs per-file, but
tsc,mypy, and most type checkers need the whole project. Run them outsidelint-staged's file-scoping (top-level command), or accept that incremental mode misses some errors. gitleaksanddetect-secretsare not interchangeable.detect-secretsrequires a baseline file (.secrets.baseline) and only flags new secrets vs the baseline.gitleaksflags any secret matching its rules. Pick one and document the workflow — don't add both.- Conventional Commits enforcement is opinionated. Some teams want it, some hate it. Default to enforcing it only when the user asked for it or when the repo already uses it (check existing commit messages with
git log --oneline -20). - Hooks must work on Windows / WSL / macOS / Linux. The
pre-commitframework handles this; raw shell hooks in Husky don't. If you're writing a custom hook, use a portable shebang and POSIX shell, or pin it to one OS in the docs. - Do not bypass with
--no-verifyto "fix" failing hooks. If hooks fail, fix the cause. The only legitimate--no-verifyis for emergency hotfixes the user explicitly chooses. - The hook config file is the source of truth.
.pre-commit-config.yaml(or Husky's.husky/pre-commit) is what the team commits and reviews. Don't sneak hooks into local-only Git config.
What you DO
- Confirm it's a git repo before doing anything (
git rev-parse --is-inside-work-tree). - Detect languages via
scripts/detect-languages.shor equivalent. - Default to the
pre-commitframework. Use Husky only when the repo is pure-Node and the user asked for Husky by name. - Pick formatter + linter + (where applicable) type-checker for each detected language.
- Add universal hooks: whitespace, EOF, large files, merge-conflict markers, JSON/YAML/TOML validation, secret scanner.
- Add commit-msg hook for Conventional Commits when appropriate (see gotchas).
- Pin all hook versions (
rev: v1.2.3, nevermain). - Run
pre-commit run --all-filesonce to surface and auto-fix the existing-file format drift. - Commit the new config with a Conventional message; that's the final smoke test.
- Tell the user what's now blocked at commit and how to bypass for emergencies (
--no-verify).
What you do NOT do
- Do not paste a single-language template into a polyglot repo.
- Do not use Husky in a polyglot repo.
- Do not run full test suites in pre-commit (move to pre-push or CI).
- Do not add
gitleaksanddetect-secretstogether — pick one. - Do not use floating refs (
rev: main,rev: HEAD) in.pre-commit-config.yaml. - Do not silently overwrite an existing pre-commit config without showing the user the diff.
- Do not enforce Conventional Commits on a repo that doesn't use them, unless the user asked.
- Do not bypass failing hooks with
--no-verifyto "make it pass". Fix the underlying cause. - Do not add tooling for languages the repo doesn't use.
- Do not introduce a Python dependency (
pre-commit) into a Node-only repo if the user wants Husky — respect the explicit ask. - Do not commit a
.pre-commit-config.yamlwithout first running it once and verifying it's clean.
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.

