setup-pre-commit

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

356|59|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/amazingloft999-droid/mattpocock-skills --skill setup-pre-commit-amazingloft999-droid
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/amazingloft999-droid/mattpocock-skills/tree/main/skills/misc/setup-pre-commit
Command: npx skills add https://github.com/amazingloft999-droid/mattpocock-skills --skill setup-pre-commit-amazingloft999-droid

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams enforce code quality by automatically configuring pre-commit hooks, linting, formatting, and optional checks in a repository.

Core Features & Use Cases

  • Husky pre-commit hook setup to run checks on staged changes
  • lint-staged integration to format or lint only staged files with Prettier
  • Automatic creation of a default Prettier configuration if missing
  • Optional integration of type checking and test scripts into the pre-commit flow
  • Works across npm, yarn, pnpm, and bun project setups

Quick Start

Install the pre-commit tooling by running the installer to add Husky, lint-staged, and Prettier to your project.

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 to run Prettier formatting?

To set up Husky pre-commit hooks with Prettier, you need to initialize Husky, create the pre-commit script, and configure lint-staged to format staged files. This automates formatting checks on every commit.

Can I configure lint-staged and Husky for a pnpm or bun project?

Yes, you can configure lint-staged and Husky across npm, yarn, pnpm, or bun setups. The setup process detects your package manager and adapts dependency installation and hook configuration accordingly.

What's the best way to enforce code quality checks on staged files before committing?

The best way to enforce code quality on staged files is by integrating Husky with lint-staged. This combination runs Prettier formatting and optional type checks only on staged changes, preventing bad code from entering your repository.

Do I need an existing Prettier configuration to automate pre-commit hook setup?

No, you do not need an existing Prettier configuration. The pre-commit setup process automatically creates a default Prettier configuration if one is missing in your repository.

How to add type checking and test scripts to a pre-commit hook?

To add type checking and test scripts to a pre-commit hook, you integrate them into the Husky pre-commit flow alongside lint-staged. This ensures verification steps run automatically on staged changes before committing.

Why does my lint-staged setup fail to run during the pre-commit hook?

If lint-staged fails during the pre-commit hook, it is often due to missing dependencies or incorrect Husky initialization. Ensure dependencies are installed and the pre-commit script is correctly created for your package manager.