Setup Pre Commit
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.
Install
/plugin marketplace add mattpocock/skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add mattpocock/skills --skill setup-pre-commitgit clone --depth 1 https://github.com/mattpocock/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/skills/misc/setup-pre-commit ~/.claude/skills/setup-pre-commitPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Setup Pre-Commit Hooks
## What This Sets Up
- **Husky** pre-commit hook
- **lint-staged** running Prettier on all staged files
- **Prettier** config (if missing)
- **typecheck** and **test** scripts in the pre-commit hook
## Steps
### 1. Detect package manager
Check for `package-lock.json` (npm), `pnpm-lock.yaml` (pnpm), `yarn.lock` (yarn), `bun.lockb` (bun). Use whichever is present. Default to npm if unclear.
### 2. Install dependencies
Install as devDependencies:
```
husky lint-staged prettier
```
### 3. Initialize Husky
```bash
npx husky init
```
This creates `.husky/` dir and adds `prepare: "husky"` to package.json.
### 4. Create `.husky/pre-commit`
Write this file (no shebang needed for Husky v9+):
```
npx lint-staged
npm run typecheck
npm run test
```
**Adapt**: Replace `npm` with detected package manager. If repo has no `typecheck` or `test` script in package.json, omit those lines and tell the user.
### 5. Create `.lintstagedrc`
```json
{
"*": "prettier --ignore-unknown --write"
}
```
### 6. Create `.prettierrc` (if missing)
Only create if no Prettier config exists. Use these defaults:
```json
{
"useTabs": false,
"tabWidth": 2,
"printWidth": 80,
"singleQuote": false,
"trailingComma": "es5",
"semi": true,
"arrowParens": "always"
}
```
### 7. Verify
- [ ] `.husky/pre-commit` exists and is executable
- [ ] `.lintstagedrc` exists
- [ ] `prepare` script in package.json is `"husky"`
- [ ] `prettier` config existsDetails
- Skill name
setup-pre-commit- Repository
- mattpocock/skills
- Path
skills/misc/setup-pre-commit/SKILL.md- License
- MIT
- Repo updated
- 30 October 2026
- Listed in
- VoltAgent/awesome-agent-skills
FAQ
What does the Setup Pre Commit skill do?
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.
How do I install the Setup Pre Commit skill?
Claude Code plugin: /plugin marketplace add mattpocock/skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Setup Pre Commit popular?
It lives in mattpocock/skills, which has 307,829 GitHub stars and 25,903 forks, and is included in 1 curated skill list.
Related skills
Ask Matt
308kmattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
Chief of Staff
308kmattpocock/skills
Pursue a long-running goal in a single session by co-ordinating subagents.
Claude Handoff
308kmattpocock/skills
Hand the current conversation off to a fresh background agent that picks up the work immediately.
TDD
308kmattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
Migrate to Shoehorn
308kmattpocock/skills
Migrate test files from `as` type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.
Design Review
138kgarrytan/gstack
Designer's eye QA: finds visual inconsistency, spacing issues, hierarchy problems, AI slop patterns, and slow interactions — then fixes them. (gstack)
Browse the most popular Claude skills, all testing & qa skills, or write your own with the skills generator.