
Setup Pre-Commit Hooks
Adds Husky and lint-staged pre-commit hooks that format, typecheck and test code before each commit.
- Repository
- mattpocock/skills
- Stars
- 309,658
- Licence
- MIT
- Files
- 2 files
What it does
When installed, the agent can configure a JavaScript or TypeScript project so that every git commit is automatically checked. It installs Husky (a tool that runs scripts at git events), lint-staged (which runs formatters only on staged files) and Prettier (a code formatter), then writes a pre-commit hook that runs formatting, a typecheck script and a test script. The agent detects which package manager the repo uses (npm, pnpm, yarn or bun) and adapts the commands, and it commits the result as a smoke test.
Great for
- Developers starting a JavaScript or TypeScript project who want consistent formatting and checks on every commit
- Teams standardising commit-time quality gates across a repo that lacks Husky setup
- Maintainers who already have typecheck and test scripts in package.json
Skip it if
- Repos without package.json or a Node.js toolchain, where the setup steps do not apply
- Projects that already have a configured hook system or Prettier config, since the skill may conflict with or overwrite existing setup and commits made through it run the full test suite, which can be slow
- Non-technical users who would not be able to review the changes or recover if a commit is blocked or misconfigured
Try asking
- “Set up Husky and lint-staged with Prettier in this repo”
- “Add a pre-commit hook that runs typecheck and tests before each commit”
- “Configure lint-staged so only staged files get formatted on commit”
Install in 3 steps
- 1
Download the skill
The ZIP contains the 2 original files, the MIT licence and an attribution note.
setup-pre-commit.zip - 2
Add it to your agent
Claude Code (all projects)
mkdir -p ~/.claude/skills && unzip setup-pre-commit.zip -d ~/.claude/skills/Claude Code / Agent SDK (this project only)
mkdir -p .claude/skills && unzip setup-pre-commit.zip -d .claude/skills/Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.
- 3
Ask for the task
No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.
Get better results
- Review the generated .husky/pre-commit and .lintstagedrc before the agent commits, and check that the repo has typecheck and test scripts first
- Ask the agent to skip the automatic commit step if you want to inspect changes yourself
- Note that the skill's commit step will trigger the new hooks, so make sure the tests pass beforehand
What's inside
- agents/openai.yaml
- SKILL.md
Redistributed unmodified from mattpocock/skills under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.