setup-pre-commit

Automate Husky pre-commit hook setup with lint-staged, Prettier, typecheck, and tests.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

Core Features & Use Cases

  • Husky pre-commit hook to run checks on commit
  • lint-staged to format and stage code with Prettier
  • Prettier configuration setup if missing
  • typecheck and test script integration in package.json
  • Works across npm, pnpm, yarn, or bun projects; detects the package manager and adapts commands

Quick Start

Run the installer to add setup-pre-commit to your repository and follow prompts to configure Husky, lint-staged, and Prettier.

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, you can use an automated setup tool that creates the .husky/pre-commit hook, configures lint-staged, and generates a Prettier config file in your repository.

Can I configure pre-commit hooks to run type checking and tests automatically?

Yes, you can configure pre-commit hooks to run type checking and tests automatically by wiring typecheck and test scripts directly into your package.json, which are then triggered before each commit is finalized.

Does this pre-commit hook setup work with pnpm, yarn, or bun package managers?

This pre-commit hook setup works with npm, pnpm, yarn, or bun by automatically detecting the active package manager in your project and adapting the configuration commands accordingly.

What is the best way to automate code formatting on commit in a JavaScript project?

The best way to automate code formatting on commit in a JavaScript project is using lint-staged to run Prettier on staged files, ensuring only formatted code is committed without affecting the entire repository.

Do I need an existing Prettier configuration to add commit-time formatting?

No, you do not need an existing Prettier configuration to add commit-time formatting, because the setup process will automatically generate or update a Prettier config file if one is missing.