Guide · Agent skill
How to use the Setup Pre-Commit Hooks agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The setup-pre-commit skill is a set of instructions that lets an AI coding agent configure a JavaScript or TypeScript git repository so that every commit is checked automatically. It installs Husky, lint-staged and Prettier, then writes a pre-commit hook that runs formatting, a typecheck script and a test script. This guide explains what the skill does, how to install it, how to ask for it, and what to check before you rely on it.
Quick start
- 1Check your requirements. Confirm the project is a git repository with a package.json and a Node.js toolchain. The skill installs its tools as devDependencies using your package manager.
- 2Download and unzip the skill. Download the ZIP from this page and unzip it so the setup-pre-commit folder sits in ~/.claude/skills/ or the project's .claude/skills/.
- 3Ask the agent in plain language. Request pre-commit hooks, Husky, lint-staged or commit-time checks in your repo.
- 4Let the agent detect and install. The agent checks for package-lock.json, pnpm-lock.yaml, yarn.lock or bun.lockb and installs husky, lint-staged and prettier.
- 5Review the generated files. Check .husky/pre-commit, .lintstagedrc, .prettierrc and the prepare script in package.json.
- 6Verify and commit. The agent runs npx lint-staged to check the setup, then commits the changes, which runs the new hooks as a smoke test.
What the setup-pre-commit skill makes the agent do
An agent skill is a folder with a SKILL.md file that tells an AI agent how to handle a specific kind of task. When this skill is active and you ask for commit-time checks, the agent follows its written steps in your current repository.
The skill sets up four things: a Husky pre-commit hook, lint-staged running Prettier on all staged files, a Prettier config if one is missing, and typecheck and test scripts called from the pre-commit hook. Husky is a tool that runs scripts at git events, lint-staged runs commands only on files that are staged for a commit, and Prettier is a code formatter.
- Detects the package manager from its lock file: npm, pnpm, yarn or bun. It defaults to npm if unclear.
- Installs husky, lint-staged and prettier as devDependencies.
- Runs npx husky init, which creates a .husky/ directory and adds a prepare script set to husky in package.json.
- Writes .husky/pre-commit, .lintstagedrc and, only if none exists, .prettierrc.
- Verifies the setup and commits the changes as a smoke test.
Install the skill from the ZIP
Download the ZIP for this skill from this page and unzip it. Put the resulting skill folder in one of two places, depending on how you want to use it.
For a personal setup available to all your projects, place it in ~/.claude/skills/. For a skill that only applies to one project, place it in that project's .claude/skills/ folder.
If you use the Claude apps instead, you can upload the skill under Settings → Capabilities → Skills.
- Personal (all projects): ~/.claude/skills/
- Single project: .claude/skills/ inside the repository
Trigger the skill with a natural request
You do not need a special command. The skill describes when it applies, so ask the agent in plain language. Requests that match its description include adding pre-commit hooks, setting up Husky, configuring lint-staged, or adding commit-time formatting, typechecking or testing.
Be specific about your repo when it matters. Saying which package manager you use, or that the project already has typecheck and test scripts, helps the agent adapt the commands.
- "Add pre-commit hooks to this repo."
- "Set up Husky and lint-staged with Prettier."
- "Configure lint-staged so staged files get formatted on commit."
- "Add typecheck and tests to the commit hook."
What to check before and after the agent runs
Run the skill in a git repository that has a package.json. Before running it, commit or stash your current work so the automatic commit at the end only contains the setup changes. Review the diff afterwards.
The skill's steps say to omit the typecheck or test lines if package.json has no matching script, and to tell you when that happens. Check that the hook matches your project.
- Confirm the lock file matches the package manager the agent chose.
- Check that .husky/pre-commit calls the right package manager and scripts.
- Look at .lintstagedrc and .prettierrc to confirm they fit your team's style.
- Make sure the final commit message is Add pre-commit hooks (husky + lint-staged + prettier) and that the commit succeeded.
npx lint-stagedWhat people use it for
- Starting a new TypeScript project with consistent Prettier formatting on every commit.
- Adding commit-time typechecking and tests to a team repo that has no Husky setup.
- Standardising formatting across a repo where contributors use different editors.
- Adding a pre-commit hook to a project that already has typecheck and test scripts in package.json.
Frequently asked questions
Is the setup-pre-commit skill free?
The skill is published under the MIT licence, which is stated on this page. Check the licence file in the repository for the full terms.
What do I need to use the setup-pre-commit skill?
You need Node.js, a package manager (npm, pnpm, yarn or bun), a git repository, and an agent that supports skills. Husky, lint-staged and Prettier are installed by the skill as devDependencies.
Where do I put the setup-pre-commit skill folder?
Put it in ~/.claude/skills/ to use it across projects, or in a project's .claude/skills/ folder to use it in one repo. In the Claude apps you can upload it under Settings → Capabilities → Skills.
Does the skill work with pnpm, yarn or bun?
Yes. The skill checks for pnpm-lock.yaml, yarn.lock and bun.lockb and uses the matching package manager. If none is found it defaults to npm.
What happens if my project has no typecheck or test script?
The skill's instructions say to leave out the typecheck or test line from the pre-commit hook and to tell you. Check the generated .husky/pre-commit file to confirm what was written.
Can the skill overwrite my existing setup?
It can conflict with an existing hook system or Prettier config. The skill only creates .prettierrc if no Prettier config exists, but it does write .husky/pre-commit and .lintstagedrc, so back up or commit your work first and review the diff.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
This skill suits developers starting a JavaScript or TypeScript project, or teams adding commit-time checks to a repo without Husky. It is a poor fit for projects that already have hooks or Prettier configured, for repos without a Node.js toolchain, and for anyone who cannot review the changes or recover from a blocked commit, since commits run the full test suite and can be slow.
Download the skill