setup-pre-commit

Configure Husky pre-commit hooks with lint-staged and Prettier.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill removes the manual setup work required to keep commits clean, consistent, and validated before code reaches the repository.

Core Features & Use Cases

  • Husky pre-commit hooks: Runs checks automatically before every commit.
  • lint-staged formatting: Applies Prettier to staged files so only changed files are reformatted.
  • Typecheck and test gating: Adds repository-aware type checking and tests when those scripts exist.
  • Use case: Ideal when you want every commit to be formatted, validated, and less likely to break CI.

Quick Start

Ask the assistant to set up Husky pre-commit hooks with lint-staged, Prettier, and any available typecheck and test scripts in the current 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?

To set up Husky pre-commit hooks with lint-staged and Prettier, you configure package-manager-aware hook scripts that automatically format staged files and validate code before commits reach the repository. This automates formatting and linting without manual setup work.

Why use lint-staged for pre-commit formatting instead of formatting the whole project?

Using lint-staged for pre-commit formatting applies Prettier only to staged files. This ensures changed files are reformatted quickly without touching the rest of the codebase, keeping commits clean and consistent while reducing hook execution time.

Can I add typecheck and test scripts to pre-commit hooks without breaking existing configurations?

Yes, you can add typecheck and test scripts to pre-commit hooks without breaking existing configurations. The setup detects and preserves existing project scripts while adding repository-aware type checking and test execution only when those scripts already exist.

Does pre-commit hook setup support different package managers?

Pre-commit hook setup supports different package managers by configuring package-manager-aware hook scripts. This allows the automated formatting, staged-file linting, type checking, and test execution to integrate correctly regardless of your specific package management environment.

What is the best way to automate code formatting and linting before a Git commit?

The best way to automate code formatting and linting before a Git commit is using Husky to run lint-staged. This applies Prettier to staged files and runs type checks, ensuring every commit is formatted, validated, and less likely to break CI.