setup-pre-commit

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents inconsistent code style and accidental broken commits by enforcing formatting and lightweight validation at commit time, so issues are caught locally before they reach CI or the main branch.

Core Features & Use Cases

  • Husky pre-commit hook that runs configured checks on every commit to enforce commit-time policies.
  • lint-staged with Prettier to format only staged files for fast, deterministic formatting.
  • Typecheck and test integration to optionally run full type checking and test suites during commit when corresponding scripts exist in package.json.
  • Use Case: A repository maintainer wants to ensure every commit is formatted and passes basic checks locally to reduce CI failures and code-review friction.

Quick Start

Set up Husky pre-commit hooks with lint-staged and Prettier in this repository and run typecheck and tests if those scripts exist.

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 Prettier and lint-staged?

To set up Husky pre-commit hooks with Prettier and lint-staged, you need to initialize Husky, create a .husky/pre-commit hook, and configure lint-staged to format staged files automatically before commits.

Can I run TypeScript type checks and tests in a Husky pre-commit hook?

Yes, you can run TypeScript type checks and tests in a Husky pre-commit hook by adapting the hook commands based on existing typecheck and test scripts defined in your project's package.json file.

Does Husky pre-commit formatting work with pnpm and bun package managers?

Husky pre-commit formatting works with pnpm and bun by detecting the package manager through lockfiles, installing necessary devDependencies, and adapting the lint-staged configuration accordingly.

What is the best way to format only staged files with Prettier before committing?

The best way to format only staged files with Prettier is using lint-staged alongside a Husky pre-commit hook, ensuring fast, deterministic formatting that catches style issues locally before pushing code.

Why should I use lint-staged and Husky to prevent bad commits in a Node.js repository?

Using lint-staged and Husky prevents bad commits in a Node.js repository by enforcing local formatting and lightweight validation at commit time, which reduces CI failures and minimizes code review friction.