PlugWiki

setup-pre-commit Skill (mattpocock): Husky Hooks Setup

Sets up Husky pre-commit hooks with lint-staged, Prettier, type checking and tests in the current repo.

Installs
514.2K
on skills.sh
Stars
309.2K
on GitHub
Files
1
besides SKILL.md
Updated
Nov 2026
last repo commit

setup-pre-commit makes the agent add a Husky pre-commit hook that runs lint-staged (Prettier on staged files), then your typecheck and test scripts. It detects npm, pnpm, yarn or bun from the lockfile, installs husky, lint-staged and prettier as devDependencies, and creates .husky/pre-commit, .lintstagedrc and a .prettierrc if none exists.

It starts when you ask for pre-commit hooks, Husky, lint-staged or commit-time formatting and testing. If the repo has no typecheck or test script, it leaves those lines out and tells you. Its last step stages the changed files and makes a commit, which runs the new hooks as a smoke test.

Good for

  • JavaScript and TypeScript developers who want formatting and checks on every commit
  • Teams adding Husky to a repo for the first time
  • Solo developers who want Prettier to run on staged files automatically

Install setup-pre-commit

Claude Code

  1. 1

    Copy this prompt.

    Install the setup-pre-commit skill in Claude Code. Run this command:
    
    npx skills add https://github.com/mattpocock/skills --skill setup-pre-commit
    
    Then check that it loaded and tell me how to use it.
  2. 2

    Paste it into Claude Code. It shows the change and asks before running it.

Requires Node.js.

From its listing on skills.sh. Source.

What's in the skill

When it loads

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.

Sections in SKILL.md

  1. What This Sets Up
  2. Steps
  3. 1. Detect package manager
  4. 2. Install dependencies
  5. 3. Initialize Husky
  6. 4. Create .husky/pre-commit
  7. 5. Create .lintstagedrc
  8. 6. Create .prettierrc (if missing)
  9. 7. Verify
  10. 8. Commit
  11. Notes

Key facts

Installs on skills.sh
514,159 (Nov 2, 2026)
License
MIT
Last repo commit
Nov 1, 2026

What it includes

  • Reads the lockfile: npm, pnpm, yarn or bun

    Defaults to npm if the lockfile is unclear.

    Read · Detect package manager

  • Adds husky, lint-staged and prettier as devDependencies

    Uses the package manager it detected.

    Runs code · Install dependencies

  • Runs npx husky init

    Creates the .husky/ folder and adds a prepare script to package.json.

    Runs code · Initialize Husky

  • Runs lint-staged, then typecheck, then test

    Uses your package manager. Leaves out typecheck or test if no such script exists, and tells you.

    Files · Create .husky/pre-commit

  • Runs prettier --ignore-unknown --write on all staged files

    Prettier skips files it cannot parse, such as images.

    Files · Create .lintstagedrc

  • Adds default Prettier settings only if none exist

    Defaults: 2-space indent, 80 columns, double quotes, semicolons, es5 trailing commas.

    Files · Create .prettierrc

  • Checks the files, runs npx lint-staged, commits

    Commit message: "Add pre-commit hooks (husky + lint-staged + prettier)".

    Runs code · Verify and commit

From the official docs

Permissions

Medium risk

It installs packages, edits package.json and makes a git commit on its own. Start from a clean working tree so the commit holds only the hook setup.

What it can do

  • Read your data
  • Create and change things
  • Delete things
  • Read-only mode

Watch out for

  • It stages and commits changed files for you

    The last step stages all changed or created files and commits. Commit or stash unrelated work first.

  • It installs packages and runs npx

    It adds three devDependencies and runs npx husky init. Check the package.json diff before you push.

Technical details
Talks toPackage registry, to install husky, lint-staged and prettier
Scopes
  • Edits package.json and installs dependencies

  • Creates .husky/, .lintstagedrc and .prettierrc

  • Makes a git commit

Questions

What does setup-pre-commit set up?

Husky pre-commit hook, lint-staged running Prettier on staged files, a Prettier config if you lack one, and your typecheck and test scripts in the hook.

How do I install it?

Follow the install box at the top of the page. Then ask Claude to set up pre-commit hooks in your repo.

Which package managers does it support?

npm, pnpm, yarn and bun. It picks one from package-lock.json, pnpm-lock.yaml, yarn.lock or bun.lockb, and defaults to npm.

What if I have no typecheck or test script?

It leaves those lines out of the hook and tells you.

Will it commit for me?

Yes. The last step stages all changed or created files and commits with the message "Add pre-commit hooks (husky + lint-staged + prettier)". Stash unrelated changes first.

Does it need an API key?

SKILL.md asks for none. It runs npm-style installs and npx husky init in your repo.

Is it safe?

It edits package.json, installs three packages and makes a commit, all in your repo. Run it on a clean branch and review the diff before you push.

Information

updated Nov 2, 2026

Folder
skills/misc/setup-pre-commit

mattpocock/skillsskills.sh

Sources

Docs, issue trackers and discussions this page is built from.

Show all 2
  1. setup-pre-commit SKILL.md · github.com
  2. skills.sh listing · skills.sh

Updated Nov 2, 2026.