setup-pre-commit
Skill8 starsChanged 2 months agoMITView on GitHub
Configure pre-commit quality checks with Husky and lint-staged while preserving package manager conventions. Use when setting up git pre-commit hooks, automated formatters, staged linters, or typecheck gates — even if the user says \"add pre-commit hooks\". Do NOT use for continuous integration (CI) pipeline setup.
We split this skill into the rules it gives an agent
6 rules. 0 are common, 1 is distinctive, and 5 are very specific to this project.
0
Common
Most of the 106 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Staged-Only Formatting: Run Prettier strictly against staged files via lint-staged with --ignore-unknown --write to prevent un-staged code …
- Very specific: line 17
Preserve Existing Configurations: If .prettierrc or existing Husky hooks exist, merge scripts safely without overwriting user rules.
- Distinctive: line 18
Mandatory Smoke-Test Commit: Verify the entire hook pipeline by staging all configuration changes and executing a verified test commit.
- Very specific: line 46
Key Point: Check if prettier, lint-staged, or husky are already installed.
- Very specific: line 51
Key Point: Verify that "prepare": "husky" is added to package.json.
- Very specific: line 65
Key Point: Create .lintstagedrc with {"*": "prettier --ignore-unknown --write"}.
“Common” is measured: kept by at least 6 in 10 of the 106 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Setup Pre-Commit Hooks
Install and configure deterministic Git pre-commit quality gates using Husky, lint-staged, and Prettier, preserving existing repository package managers and build scripts.
Core Invariants
- Package Manager Fidelity: Detect and use the repository's native package manager (
bun,pnpm,yarn,npm); do NOT introduce conflicting lockfiles. - Staged-Only Formatting: Run Prettier strictly against staged files via
lint-stagedwith--ignore-unknown --writeto prevent un-staged code drift. - Repository-Wide Typecheck & Test: Execute full typecheck and unit test passes inside
.husky/pre-commitafterlint-stagedsucceeds. - Preserve Existing Configurations: If
.prettierrcor existing Husky hooks exist, merge scripts safely without overwriting user rules. - Mandatory Smoke-Test Commit: Verify the entire hook pipeline by staging all configuration changes and executing a verified test commit.
Architecture & Map of Content (MOC)
[ Git Commit Attempt ] ──► [ .husky/pre-commit Hook ]
│
┌───────────────────────────┼───────────────────────────┐
▼ ▼ ▼
[ lint-staged ] [ Typecheck Gate ] [ Unit Test Gate ]
- Prettier format - `npm run typecheck` - `npm run test`
- Staged files only - Full project types - Unit/Integration pass| Component | Responsibility | Configuration File |
| Husky Engine | Git hook manager v9+ | .husky/pre-commit |
| lint-staged | Run formatters exclusively on staged changes | .lintstagedrc |
| Prettier | Code style standardization | .prettierrc |
Step-by-Step Procedure (TWI)
Step 1: Detect Package Manager & Check Existing Setup
- Action: Detect the lockfile (
bun.lockb$\rightarrow$ bun,pnpm-lock.yaml$\rightarrow$ pnpm,yarn.lock$\rightarrow$ yarn, else npm). - Key Point: Check if
prettier,lint-staged, orhuskyare already installed. - Why: Reusing existing dependencies prevents package bloat and lockfile churn.
Step 2: Install DevDependencies & Initialize Husky
- Action: Install
husky,lint-staged, andprettieras devDependencies, then runnpx husky init. - Key Point: Verify that
"prepare": "husky"is added topackage.json. - Inline Checklist:
- Dependencies installed in
devDependencies .husky/directory createdpreparescript present inpackage.json
- Dependencies installed in
Step 3: Write .husky/pre-commit & .lintstagedrc
- Action: Configure
.husky/pre-commit:
(Adaptingnpx lint-staged npm run typecheck npm run testnpmto the detected package manager, and omittingtypecheck/testif scripts are absent). - Key Point: Create
.lintstagedrcwith{"*": "prettier --ignore-unknown --write"}. - Why:
prettier --ignore-unknownsafely ignores binaries and images while formatting all supported text formats.
Step 4: Smoke Test and Initial Commit
- Action: Stage all created hook files and run
git commit -m "Add pre-commit hooks (husky + lint-staged + prettier)". - Key Point: Confirm that the commit triggers the pre-commit hook and passes all stages.
- Why: Live commit execution proves that hooks are executable and correctly configured.
Anti-Rationalization Guardrails
| Tempting Rationalization | Binding Rule | Engineering Rationale |
| "Run prettier across the whole repository on every commit." | Run Prettier strictly on staged files via lint-staged. | Full-repo formatting on every commit slows developer workflows and pollutes diffs. |
| "Skip the typecheck and test steps in pre-commit to make it faster." | Include typecheck and fast tests in pre-commit. | Catching type errors locally before push prevents broken remote CI builds. |
| "Use npm commands in a pnpm or bun repository." | Strictly match detected package manager commands. | Mismatched package managers create duplicate lockfiles and broken installations. |
Other versions118 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 118
- mattpocock/skills★ 309ksame name
- vinvcn/mattpocock-skills-zh-CN★ 5.5ksame name
- devcxl/mattpocock-skills-zh★ 522same name
- amazingloft999-droid/mattpocock-skills★ 422same name
- InditexTech/weavejs★ 266same name
- loulanyue/skills★ 231same name
- tt-a1i/matt-skills-with-to-goal★ 192same name
- aurorasoft2/Matt_Pocock_Skills★ 133same name
- VisualxIntelligence/mattpocok-skills★ 55same name
- romiluz13/mifal★ 44same name
108 more not listed
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.
Used alongsideProjects with it also use edit-article, request-refactor-plan and 5 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
simo97Skilledit-article
The user will invoke this skill to help them edit an article.
Also in 38 projects that use this
simo97Skillrequest-refactor-plan
Use this skill when user wants to create a refactor plan.
Also in 38 projects that use this
RoentekSkillloop-me
Grill me about specs for the workflows I want to build, within this workspace.
Also in 48 projects that use this
ryotaroh180105Skillclaude-handoff
Hand the current conversation off to a fresh background agent that picks up the work immediately.
Also in 36 projects that use this
FabienDehopreSkilldecision-mapping
Turn a loose idea into a sequenced map of investigation tickets, then drive them to resolution one at a time.
Also in 6 projects that use this
- +2 more from simo97
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ai-data-remediationSkill
- ai-engineeringSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- engineering-workflow-guideSkill
- git-safety-guardrailsSkill
- goalSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- j-spaceSkill
- migrate-to-shoehornSkill
- ml-best-practicesSkill
- prototypeSkill
- researchSkill
- resolving-merge-conflictsSkill
- retroSkill
- scaffold-exercisesSkill
- setup-engineering-workflowsSkill
- setup-ts-deep-modulesSkill
- skill-conductorSkill
- tddSkill
- teachSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- wait-whatSkill
- wayfinderSkill
- wizardSkill
- workflow-designerSkill
- writing-beatsSkill
- writing-for-agentsSkill
- writing-fragmentsSkill
- writing-shapeSkill
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.

