setup-pre-commit

Configure Husky pre-commit hooks with lint-staged and Prettier for JavaScript/TypeScript projects.

1|Updated Apr 22, 2026
One-click install
npx skills add https://github.com/Herxinsasa/Skills-Collector --skill setup-pre-commit-herxinsasa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/Herxinsasa/Skills-Collector/tree/main/mattpocock-skills/skills/misc/setup-pre-commit
Command: npx skills add https://github.com/Herxinsasa/Skills-Collector --skill setup-pre-commit-herxinsasa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manually configuring pre-commit hooks with Husky, lint-staged and Prettier is time-consuming and prone to configuration errors, especially for teams that need to enforce consistent code formatting and quality checks across all commits.

Core Features & Use Cases

  • Automated Husky Initialization: Automatically sets up the Husky git hook framework and configures the pre-commit hook to run lint-staged, type checking and test suites.
  • Lint-staged & Prettier Integration: Configures lint-staged to run Prettier on all staged files, skipping unparseable files like images, and creates a default Prettier config if none exists.
  • Use Case: For a JavaScript/TypeScript development team, use this Skill to enforce consistent code formatting and run basic quality checks before any code is committed, reducing code review overhead and preventing broken code from entering the shared repository.

Quick Start

Use the setup-pre-commit skill to configure Husky pre-commit hooks with lint-staged, Prettier formatting, type checking and test runs for the current 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 with lint-staged and Prettier?

This skill automates Husky pre-commit hook setup by initializing the framework and configuring lint-staged with Prettier to format staged files, run type checking, and execute tests before code is committed.

Can I automatically run TypeScript type checking and tests in pre-commit hooks?

Yes, this pre-commit hook setup conditionally executes typecheck and test scripts by detecting existing configurations in your package.json, ensuring automated quality validation before code enters version control.

Does this Husky and lint-staged setup work for JavaScript and TypeScript projects?

Yes, this pre-commit hook setup targets JavaScript and TypeScript projects, applying Prettier formatting to staged files while skipping unparseable files like images to maintain clean code quality workflows.

What is the best way to enforce consistent code formatting before code is committed?

Using Husky pre-commit hooks with lint-staged and Prettier is the best way to enforce consistent code formatting, automatically formatting staged files and running quality checks to prevent broken code from entering the repository.

Do I need an existing Prettier config to use this pre-commit hook setup?

No existing Prettier config is required because this pre-commit hook setup automatically creates a default Prettier configuration file if none is detected in your project during the lint-staged initialization process.