Setup pre commit
Set up Husky pre-commit hooks with lint-staged (Biome), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/linting/typechecking/testing.From its SKILL.md
npx -y skills add mauriciovieira/skills --skill setup-pre-commitAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
- runs commandsInstructs the agent to run 5 commands, including `npx husky init` and 4 more.
SKILL.md
3.1 KB, 832 tokens by cl100k_base, as published. Nobody here has run it
Setup Pre-Commit Hooks
What This Sets Up
- Husky pre-commit hook
- lint-staged running Biome on all staged files
- Biome config (if missing) — formatter + linter, replaces Prettier + ESLint
- typecheck and test scripts in the pre-commit hook
Steps
1. Detect package manager
Check for package-lock.json (npm), pnpm-lock.yaml (pnpm), yarn.lock (yarn), bun.lockb (bun). Use whichever is present. Default to npm if unclear.
2. Install dependencies
Install as devDependencies:
husky lint-staged @biomejs/biome
3. Initialize Husky
npx husky init
This creates .husky/ dir and adds prepare: "husky" to package.json.
4. Create .husky/pre-commit
Write this file (no shebang needed for Husky v9+):
npx lint-staged
npm run typecheck
npm run test
Adapt: Replace npm with detected package manager. If repo has no typecheck or test script in package.json, omit those lines and tell the user.
5. Create .lintstagedrc
{
"*": "biome check --write --no-errors-on-unmatched"
}
biome check formats and lints. --write applies safe fixes; --no-errors-on-unmatched stops Biome erroring when a staged file isn't a type it handles (images, etc.).
6. Create biome.json (if missing)
Only create if no Biome config exists (biome.json or biome.jsonc). Use these defaults:
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 80
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"trailingCommas": "es5",
"semicolons": "always",
"arrowParentheses": "always"
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
Pin the $schema version to the installed Biome version (check npx biome --version) so the config matches the binary.
7. Verify
-
.husky/pre-commitexists and is executable -
.lintstagedrcexists -
preparescript in package.json is"husky" -
biome.jsonconfig exists - Run
npx lint-stagedto verify it works
8. Commit
Stage all changed/created files and commit with message: Add pre-commit hooks (husky + lint-staged + biome)
This will run through the new pre-commit hooks — a good smoke test that everything works.
Notes
- Husky v9+ doesn't need shebangs in hook files
biome checkdoes formatting and linting in one pass — no separate Prettier/ESLint steps--no-errors-on-unmatchedskips files Biome can't handle (images, etc.) instead of failing the commit- The pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests
What ships with it: 1 file
99 B alongside SKILL.md
agents/
- openai.yaml99 B