setup-pre-commit

Automate pre-commit hook setup with Husky and lint-staged.

1|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/paialex/ai-skills-bank --skill setup-pre-commit-paialex
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/paialex/ai-skills-bank/tree/main/mattpocock_skills/misc/setup-pre-commit
Command: npx skills add https://github.com/paialex/ai-skills-bank --skill setup-pre-commit-paialex

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automates the setup of pre-commit hooks to enforce code quality and consistency across commits.

Core Features & Use Cases

  • Automatically detects the package manager (npm, pnpm, yarn, bun) and configures Husky and lint-staged accordingly.
  • Installs necessary dev dependencies (husky, lint-staged, prettier) and initializes Husky in the repository.
  • Creates a pre-commit script that runs lint-staged, and conditionally runs typecheck and test scripts if they exist in package.json.
  • Generates a minimal, shareable configuration (lint-staged, prettier) and documents the process for easy reuse.

Quick Start

Configure your repository to enable pre-commit checks and commit-time formatting.

Frequently Asked Questions about setup-pre-commit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up pre-commit hooks with Husky and lint-staged?▼

Pre-commit hooks with Husky and lint-staged are set up by automatically detecting your package manager, installing dev dependencies, initializing Husky, and creating a pre-commit script that runs Prettier formatting and conditional typecheck or test scripts.

Can I configure pre-commit hooks for pnpm or yarn instead of npm?▼

Pre-commit hooks can be configured for pnpm, yarn, or bun instead of npm because the setup process automatically detects the active package manager and adjusts the Husky and lint-staged installation commands accordingly.

What do pre-commit hooks enforce when running lint-staged?▼

Pre-commit hooks running lint-staged enforce code quality and consistency by applying Prettier formatting to staged files and conditionally executing typecheck and test scripts if they are defined in package.json.

Do I need to manually install dependencies before initializing Husky?▼

You do not need to manually install dependencies before initializing Husky because the setup automates the installation of required dev dependencies like husky, lint-staged, and prettier, then initializes the Husky environment directly.

What's the best way to automate code formatting checks before a git commit?▼

Automating code formatting checks before a git commit is best achieved by using Husky to trigger a pre-commit script that executes lint-staged, which runs Prettier and any existing typecheck or test scripts on staged files only.

Why does my pre-commit hook skip the typecheck script?▼

Your pre-commit hook skips the typecheck script because it is conditionally configured to only run typecheck and test scripts if those specific commands already exist within your project's package.json file.