Source: mattpocock/skills · Maintainer: community: Matt Pocock · License: MIT · Checked: 26 October 2026
What is the setup-pre-commit skill?
The setup-pre-commit skill has your coding agent add pre-commit hooks to a JavaScript or TypeScript repo: Husky runs lint-staged with Prettier on your staged files, then your typecheck and test scripts, every time you commit. It is a one-time setup skill that ends with a commit.
It comes from mattpocock/skills, Matt Pocock's collection. The SKILL.md description reads: "Set up Husky pre-commit hooks with lint-staged (Prettier), 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/typechecking/testing."
As of 26 October 2026, its skills.sh page listed about 494,800 installs (snapshot, 26 October 2026).
It sits in the repo's misc/ folder, which the misc README describes as "Tools I keep around but rarely use, not promoted in the plugin." A note in the repo says misc skills are frozen and "Bug reports, feature requests and PRs against them are closed."
What does it do?
The folder holds SKILL.md and agents/openai.yaml (Codex display name "Setup Pre-Commit"). The SKILL.md gives the agent eight steps:
- Detect the package manager from
package-lock.json,pnpm-lock.yaml,yarn.lockorbun.lockb, defaulting to npm. - Install dev dependencies:
husky,lint-stagedandprettier. - Initialize Husky with
npx husky init. - Write
.husky/pre-committo run lint-staged, then the typecheck and test scripts, using your package manager. Missing scripts are left out, and the agent tells you. - Write
.lintstagedrcso Prettier formats every staged file. - Write
.prettierrcwith default settings, only if no Prettier config exists. - Verify the files exist, the
preparescript is"husky", andnpx lint-stagedruns. - Commit with the message "Add pre-commit hooks (husky + lint-staged + prettier)", which runs the new hook as a smoke test.
The hook and lint-staged config it writes:
npx lint-staged
npm run typecheck
npm run test
{
"*": "prettier --ignore-unknown --write"
}
The pieces behave as their own docs describe. Husky's get started guide says husky init "creates a pre-commit script in .husky/ and updates the prepare script in package.json." The lint-staged README describes the tool as "Run tasks like formatters and linters against staged git files," and says "Lint-staged will automatically add any modifications to the commit as long as there are no errors," so Prettier's fixes land in the same commit. Prettier's CLI docs say --ignore-unknown makes it "ignore unknown files matched by patterns," which is why the "*" glob doesn't fail on images.
The default .prettierrc uses two-space indents, an 80-character print width, double quotes, semicolons, es5 trailing commas and always arrow parens.
How do you install it?
The README's plugin route (claude plugin install mattpocock-skills@claude-plugins-official) does not include this skill, because the repo's instructions keep misc/ skills out of the plugin. Install it on its own with the command shown on skills.sh:
npx skills add https://github.com/mattpocock/skills --skill setup-pre-commit
The skills CLI installs to the current project by default; add -g to make it available across projects. Per the Claude Code skills docs, project skills live in .claude/skills/<skill-name>/SKILL.md and personal skills in ~/.claude/skills/<skill-name>/SKILL.md. Codex and Cursor read the same SKILL.md format; see Codex skills and Cursor skills. Nothing in the steps is specific to one agent.
You need Node.js, a package.json and a git repo. The skill installs the rest.
How do you use it?
The skill is model-invoked (no disable-model-invocation line), so the agent can pick it up when you ask for pre-commit hooks, or you can type /setup-pre-commit in Claude Code.
Example prompts (suggestions, not quotes from the repo):
Set up pre-commit hooks with Husky and lint-staged in this repo./setup-pre-commit We use pnpm. Keep our existing Prettier config.Add commit-time formatting and type checking, but skip the test step for now./setup-pre-commit This is a Bun project with a bun.lock file.
Start from a clean working tree. Step 8 of the SKILL.md reads: "Stage all changed/created files and commit with message: Add pre-commit hooks (husky + lint-staged + prettier)". It doesn't limit staging to the files the skill wrote, so read literally, other uncommitted changes in your working tree could be staged into the same commit.
When it finishes, you can check the result yourself against the skill's own step 7: .husky/pre-commit exists and is executable, .lintstagedrc exists, the prepare script in package.json is "husky", and a Prettier config is present. The final commit is the real test, since it runs the new hook on the files the skill just wrote. The lint-staged README adds a reminder that matters for teams: "Don't forget to commit changes to package.json and .husky to share this setup with your team!" The skill's commit step covers that.
Tips and limits
From the SKILL.md, the linked docs and the repo's issues, not from testing:
- Bun detection lags. The skill looks for
bun.lockb. Bun's lockfile docs say "Bun v1.2 changed the default lockfile format to the text-basedbun.lock." Issue #14 flagged this and was closed in April 2026 without a change, with the triage reply calling it wontfix. The current SKILL.md still listsbun.lockb, so name your package manager in the prompt. - Full typecheck and tests on every commit. lint-staged only touches staged files, but the typecheck and test lines run on the whole project. On a large repo that makes commits slow. Ask the agent to drop or narrow those lines if so.
- Skipping hooks. Husky's how-to says "Most Git commands include a
-n/--no-verifyoption to skip hooks," and for other commands you can useHUSKY=0. - Prettier only. No ESLint or other linter is added. Extend
.lintstagedrcyourself if you want one. - Frozen. Fixes won't come upstream. Edit your copy.
As of 26 October 2026, its skills.sh audits (Gen Agent Trust Hub, Socket and Snyk) all showed Pass, dated 15 September 2026. Gen Agent Trust Hub rated it safe while noting that it runs shell commands (npm install, npx husky init) and reads package.json. Under the MIT License you can copy and change it as long as you keep the copyright notice.
Save it in your Kipt library
In Kipt, open Skills and paste the skill's GitHub folder link into the import box. Kipt reads the SKILL.md and its agents/openai.yaml; for a repo with many skills it shows a list to pick from, so you can take git-guardrails-claude-code in the same pass. You can also drop the folder or a .zip. Your skills live in your own private GitHub repo and install into Claude Code or Codex with one command:
npx skills add https://github.com/<you>/<repo>.git --all -g
Kipt is not affiliated with Matt Pocock or mattpocock/skills.
Similar skills
- Git guardrails skill: the other frozen misc skill from the same repo, which blocks destructive git commands in Claude Code.
- GitHub Actions templates skill: run the same checks in CI, where nobody can skip them with
--no-verify. - Code review and quality skill: review changes after the automated checks pass.
- Claude Code hooks: run formatters from Claude Code itself, after each edit, instead of at commit time.