Setup Pre Commit skill for Claude

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

When Claude uses it

Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

Setup Pre Commit SKILL.md

The full skill file from mattpocock/skills (MIT).

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

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

{
  "*": "prettier --ignore-unknown --write"
}

6. Create .prettierrc (if missing)

Only create if no Prettier config exists. Use these defaults:

{
  "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 exists
  • Run npx lint-staged to verify it works

8. Commit

Stage all changed/created files and commit with message: Add pre-commit hooks (husky + lint-staged + prettier)

This will run through the new pre-commit hooks: a good smoke test that everything works.

Notes

  • Husky v9+ doesn't need shebangs in hook files
  • prettier --ignore-unknown skips files Prettier can't parse (images, etc.)
  • The pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests

How to install Setup Pre Commit

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit mattpocock/skills/skills/misc/setup-pre-commit#main ~/.claude/skills/setup-pre-commit

Codex

npx degit mattpocock/skills/skills/misc/setup-pre-commit#main ~/.codex/skills/setup-pre-commit

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+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 Setup Pre Commit in Claude Code?

Copy the skill folder into ~/.claude/skills/setup-pre-commit, for example with "npx degit mattpocock/skills/skills/misc/setup-pre-commit#main ~/.claude/skills/setup-pre-commit". Claude Code loads it automatically and uses it when a task matches.

+Does Setup Pre Commit work with ChatGPT or Codex?

Yes. Setup Pre Commit uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/setup-pre-commit. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is Setup Pre Commit free?

Setup Pre Commit is published on GitHub by mattpocock under the MIT license, which allows free use.

Related software development skills

  1. Code Review

    Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's…

    mattpocock/skills★ 327k
  2. Using Agent Skills

    Discovers and invokes agent skills. Use when starting a session, or when you need to decide which skill or workflow applies to the piece of…

    addyosmani/agent-skills★ 119k
  3. Build

    Fully automate a coding task with make-plan, do, and babysit.

    thedotmack/claude-mem★ 118k
  4. Setup Ts Deep Modules

    Wire dependency-cruiser into a TypeScript repo so each package is a deep module, with implementation hidden in subfolders and reachable…

    mattpocock/skills★ 327k
  5. Tdd

    Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants…

    mattpocock/skills★ 327k
  6. To Spec

    Turn the current conversation into a spec and publish it to the project issue tracker: no interview, just synthesis of what you've already…

    mattpocock/skills★ 327k
  7. Diagnosing Superpowers

    Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results,…

    obra/superpowers★ 319k
  8. Requesting Code Review

    Use when completing tasks, implementing major features, or before merging to verify work meets requirements

    obra/superpowers★ 319k
  9. Using Git Worktrees

    Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated…

    obra/superpowers★ 319k

See all software development skills →

More skills from mattpocock

  1. Software Factory

    Shared language for designing a software factory: the tasks it runs and the services it plugs into.

    mattpocock/skills★ 327k

All skills by mattpocock →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.