setup-pre-commit

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

Updated May 7, 2026
One-click install
npx skills add https://github.com/hgxszhj/mattpocock_skills --skill setup-pre-commit-hgxszhj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/hgxszhj/mattpocock_skills/tree/main/skills/misc/setup-pre-commit
Command: npx skills add https://github.com/hgxszhj/mattpocock_skills --skill setup-pre-commit-hgxszhj

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates the setup of pre-commit tooling to enforce code quality, formatting, and tests before commits, reducing manual overhead and human error.

Core Features & Use Cases

  • Detect package managers (npm, yarn, pnpm, bun) and install required devDependencies such as husky, lint-staged, and prettier.
  • Initialize Husky and create a pre-commit hook at .husky/pre-commit that runs lint-staged and optional typecheck/test scripts.
  • Create or adapt .lintstagedrc and .prettierrc configurations when missing to enforce formatting and staged-file checks.
  • Integrate with existing package.json scripts (e.g., typecheck, test) if present, or skip these steps when not available.
  • Verify setup and provide a quick smoke test to confirm the pre-commit workflow runs locally.

Quick Start

Install the skill and run its guidance to configure pre-commit hooks for your repository.

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 Husky pre-commit hooks with lint-staged and Prettier?

Pre-commit hooks enforce code quality by running lint-staged and Prettier on staged files before a commit is finalized, preventing unformatted or error-prone code from entering the repository and reducing manual review overhead.

Does Husky pre-commit setup work with pnpm and bun package managers?

Yes, the automated pre-commit setup detects your package manager across npm, yarn, pnpm, and bun environments, installing the required devDependencies and adapting the Husky and lint-staged configuration for your specific workflow.

How do I integrate existing typecheck and test scripts into a pre-commit hook?

You can integrate existing package.json scripts by allowing the pre-commit setup to detect your typecheck or test scripts, automatically referencing them in the .husky/pre-commit file so they execute during the commit process.

What happens if my repository is missing .prettierrc and .lintstagedrc configurations?

If .prettierrc and .lintstagedrc configurations are missing, the setup will automatically create or adapt these files to enforce default formatting rules and staged-file checks, ensuring the pre-commit workflow functions correctly without manual configuration.