Kipt

Your prompts and skills, one keystroke away.

Explore

setup-pre-commit skill: add Husky, lint-staged and Prettier with one prompt

The setup-pre-commit skill has your agent add Husky hooks with lint-staged, Prettier, type checks and tests to a JavaScript repo. How to install and use it.

By the Kipt team · Updated 26 October 2026

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:

  1. Detect the package manager from package-lock.json, pnpm-lock.yaml, yarn.lock or bun.lockb, defaulting to npm.
  2. Install dev dependencies: husky, lint-staged and prettier.
  3. Initialize Husky with npx husky init.
  4. Write .husky/pre-commit to run lint-staged, then the typecheck and test scripts, using your package manager. Missing scripts are left out, and the agent tells you.
  5. Write .lintstagedrc so Prettier formats every staged file.
  6. Write .prettierrc with default settings, only if no Prettier config exists.
  7. Verify the files exist, the prepare script is "husky", and npx lint-staged runs.
  8. 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-based bun.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 lists bun.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-verify option to skip hooks," and for other commands you can use HUSKY=0.
  • Prettier only. No ESLint or other linter is added. Extend .lintstagedrc yourself 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

Questions

What does the setup-pre-commit skill do?

It has your coding agent add a Husky pre-commit hook to a JavaScript or TypeScript repo. The hook runs lint-staged with Prettier on staged files, then the project's typecheck and test scripts. The agent installs the packages, writes the config files, checks the setup and makes a commit.

How do I install the setup-pre-commit skill?

Run npx skills add https://github.com/mattpocock/skills --skill setup-pre-commit. The skill is in the repo's misc folder, which does not ship in the mattpocock-skills Claude Code plugin, so installing the plugin does not give you this skill.

Does setup-pre-commit work with pnpm, Yarn or Bun?

It tries to. The agent checks for package-lock.json, pnpm-lock.yaml, yarn.lock or bun.lockb and uses the matching package manager, defaulting to npm. Bun has used a text lockfile called bun.lock by default since v1.2, which the skill's list doesn't name, so tell the agent if you use Bun.

What if my repo has no typecheck or test script?

The SKILL.md tells the agent to leave those lines out of .husky/pre-commit and tell you. The hook then only runs lint-staged with Prettier until you add the scripts to package.json.

How do I skip the pre-commit hook for one commit?

Husky's docs say most Git commands accept -n or --no-verify to skip hooks, for example git commit -m "..." -n. For commands without that flag, prefix them with HUSKY=0 to disable hooks for that one command.

Is setup-pre-commit still maintained?

No. It lives in the repo's misc folder, and the repo marks every misc skill as frozen: they stay because they still work for some people, but bug reports, feature requests and pull requests against them are closed. Install it with skills.sh and edit your own copy if something needs fixing.

More in Skill directory

All guides

Keep your prompts and skills in one place, in your own GitHub. Install every skill with one command.

Get started

Kipt is an independent product, not affiliated with or endorsed by Anthropic, OpenAI, Cursor or GitHub. Claude, ChatGPT, Codex, Cursor and GitHub are trademarks of their owners.