setup-pre-commit

Set up Husky pre-commit hooks with lint-staged, Prettier, type checking, and tests.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill removes the friction of setting up reliable commit-time quality checks, so teams can catch formatting, type, and test issues before code lands in version control.

Core Features & Use Cases

  • Husky pre-commit hooks: Installs and configures Git hooks for consistent local enforcement.
  • lint-staged formatting: Runs Prettier only on staged files to keep commits fast and focused.
  • Validation workflow: Adds type checking and tests to the pre-commit flow when the repository already supports them.
  • Use case: Ideal for a JavaScript or TypeScript project that needs automated formatting and validation before every commit.

Quick Start

Use this Skill to set up Husky, lint-staged, Prettier, and commit-time typecheck and test hooks 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, initialize Husky, install dependencies, and configure lint-staged to run Prettier on staged files. This ensures consistent formatting and validation before commits in JavaScript and TypeScript repositories.

Can I run type checking and tests in pre-commit hooks for JavaScript projects?

Yes, you can run type checking and tests in pre-commit hooks for JavaScript projects. The setup configures Husky to conditionally add typecheck and test validation scripts to the pre-commit flow if those scripts already exist in your package.json.

Does lint-staged formatting only run on staged files to speed up commits?

Yes, lint-staged formatting only runs on staged files to speed up commits. By targeting staged files specifically, the validation workflow keeps commit-time quality checks fast and focused rather than scanning the entire repository.

What's the best way to enforce consistent code formatting before commits in TypeScript?

The best way to enforce consistent formatting before commits in TypeScript is using Husky pre-commit hooks combined with lint-staged and Prettier. This automates formatting and validation locally before code lands in version control.

Do I need existing package.json scripts to add typecheck and test hooks?

Yes, you need existing package.json scripts to add typecheck and test hooks. The setup process detects your package manager and conditionally adds validation hook scripts based on the scripts already defined in your package.json.

Why use pre-commit hooks instead of just running Prettier manually?

You use pre-commit hooks instead of running Prettier manually to catch formatting, type, and test issues automatically before code lands in version control. This removes human friction and reliably enforces consistent local quality checks.