setup-pre-commit

Set up Husky pre-commit hooks with lint-staged and Prettier for Node.js repositories.

1|Updated May 5, 2026
One-click install
npx skills add https://github.com/yashs33244/my-mac-claude --skill setup-pre-commit-yashs33244
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/yashs33244/my-mac-claude/tree/main/skills/mattpocock/misc/setup-pre-commit
Command: npx skills add https://github.com/yashs33244/my-mac-claude --skill setup-pre-commit-yashs33244

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of inconsistent formatting and broken builds slipping into commits by standardizing pre-commit quality checks for a Node-based repository.

Core Features & Use Cases

  • Husky pre-commit hook setup: Initializes Husky so checks run automatically on every commit.
  • lint-staged with Prettier: Formats only staged files to prevent style drift without slowing commits.
  • Commit-time typechecking and tests: Runs existing repo scripts (or skips them if they don’t exist) to catch regressions early.
  • Use Case: You want a new developer-friendly setup that enforces formatting, then validates TypeScript/typing and tests during commit.

Quick Start

Add Husky and lint-staged (Prettier) pre-commit checks for the current repo using the detected package manager, and run formatting, typecheck, and tests automatically on staged changes.

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 on staged files?

To set up Husky pre-commit hooks with Prettier formatting on staged files, you need to initialize Husky and configure lint-staged. This ensures checks run automatically on every commit, preventing style drift by formatting only the files you have staged.

What is the best way to automate type checking and tests during Git commits in a Node repository?

Automating type checking and tests during Git commits involves wiring a Husky pre-commit hook to run existing repository scripts. The setup detects available scripts and executes them at commit time, catching regressions early, or skips them if they don't exist.

How does lint-staged prevent pre-commit hooks from slowing down my Git commits?

lint-staged prevents pre-commit hooks from slowing down Git commits by running checks exclusively on staged files rather than the entire repository. This targeted Prettier formatting and validation significantly reduces execution time during the commit process.

Do I need to manually configure lint-staged and Husky config files for my Node repository?

You do not need to manually configure lint-staged and Husky config files. The setup process automatically generates the necessary .husky/pre-commit and lint-staged/prettier configuration files, detecting your active package manager to wire the hook correctly.

Can I use this pre-commit hook setup with different package managers in my Node repository?

Yes, you can use this pre-commit hook setup with different package managers in your Node repository. The configuration process detects the active package manager available in your environment to install dependencies and wire the Husky hook appropriately.

What happens to the pre-commit hook if typecheck or test scripts are missing from my repository?

If typecheck or test scripts are missing from your repository, the pre-commit hook simply skips them. The setup detects available scripts and only runs existing type checking and test commands, allowing the commit to proceed with formatting validation alone.