setup-pre-commit

Configure Husky and lint-staged pre-commit hooks for JavaScript and TypeScript repositories.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires husky, lint-staged, prettier.

What problem does it solve?

This skill eliminates manual code quality checks by automating the enforcement of formatting, type safety, and testing before every commit.

Core Features & Use Cases

  • Automated Formatting: Automatically runs Prettier on staged files to ensure consistent code style.
  • Pre-commit Validation: Integrates type checking and test execution into the Git commit lifecycle to prevent broken code from entering the repository.
  • Use Case: Use this when setting up a new project or onboarding a team to ensure that every commit adheres to the repository's quality standards without requiring manual intervention.

Quick Start

Run the setup-pre-commit skill in the root of your repository to initialize Husky, lint-staged, and standard quality checks.

Frequently Asked Questions about setup-pre-commit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate code formatting and testing before a Git commit?

You can automate code formatting and testing by configuring pre-commit hooks with Husky and lint-staged. This setup runs Prettier formatting, type checking, and test execution on staged files automatically, enforcing repository-level quality control without manual intervention.

How do I set up Husky and lint-staged to run Prettier on staged files?

To set up Husky and lint-staged for Prettier, initialize the pre-commit configuration in your repository root. This integrates automated formatting into the Git commit lifecycle, ensuring consistent code style across your JavaScript or TypeScript project.

Can I use Husky pre-commit hooks for type checking in a TypeScript repository?

Yes, Husky pre-commit hooks support type checking in TypeScript repositories. By integrating lint-staged, the hook automatically validates type safety and executes tests before allowing a commit, preventing broken code from entering the repository.

What is the best way to enforce consistent code quality in a JavaScript repository?

The best way to enforce consistent code quality in a JavaScript repository is automating developer tooling with pre-commit hooks. Using Husky and lint-staged ensures every commit adheres to formatting and testing standards without requiring manual checks.

Do I need lint-staged to run Prettier formatting in a Git pre-commit hook?

Yes, you need lint-staged to efficiently run Prettier formatting in a Git pre-commit hook. Lint-staged targets only staged files, ensuring the Husky hook executes formatting and type checking quickly without scanning the entire repository.