setup-pre-commit

Automate Husky pre-commit hook setup with lint-staged and Prettier for JavaScript/TypeScript projects.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Set up Husky pre-commit hooks with lint-staged and Prettier, and optionally wire in type checking and tests, in the current repository to enforce consistent code quality.

Core Features & Use Cases

  • Configures Husky pre-commit hooks and initializes a hook workflow.
  • Installs and configures lint-staged to run Prettier on all staged files.
  • Creates or updates Prettier configuration if missing.
  • Integrates type checking and tests into the pre-commit flow when scripts exist.
  • Detects the package manager (npm, yarn, pnpm, bun) and uses the appropriate commands.
  • Verifies setup and provides a smooth path to commit with guaranteed quality gates.

Quick Start

Run the installer to add pre-commit hooks (Husky, lint-staged, and Prettier) to your 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, run the installer to automatically detect your package manager, install dependencies, and wire hooks for commit-time code formatting and checks.

Can I use pre-commit hooks with different package managers like pnpm or yarn?

Yes, pre-commit hooks work with npm, yarn, pnpm, and bun. The setup automatically detects your project's package manager and uses the appropriate commands to install dependencies and configure Husky.

How do I run TypeScript type checking in a Husky pre-commit hook?

To run TypeScript type checking in a Husky pre-commit hook, the setup integrates type checking into the pre-commit flow automatically when it detects existing type check scripts in your project configuration.

What is the best way to format staged files before a git commit?

The best way to format staged files before a git commit is using lint-staged to run Prettier on all staged files. This configuration is automatically created or updated during the hook setup process to enforce consistent code quality.

Does Husky pre-commit setup include tests in the commit-time checks?

Yes, Husky pre-commit setup includes tests in the commit-time checks. It automatically integrates your existing test scripts into the pre-commit flow alongside Prettier formatting and type checking to guarantee quality gates.