setup-pre-commit

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

13|3|Updated May 12, 2026
One-click install
npx skills add https://github.com/kevinnft/ai-agent-skills --skill setup-pre-commit-kevinnft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/kevinnft/ai-agent-skills/tree/main/skills/mattpocock/misc/setup-pre-commit
Command: npx skills add https://github.com/kevinnft/ai-agent-skills --skill setup-pre-commit-kevinnft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automates the setup of Husky pre-commit hooks with lint-staged, Prettier, and optional type checking and tests to ensure consistent code quality from the first commit.

Core Features & Use Cases

  • Husky integration: adds and configures a pre-commit hook to run lint-staged on staged files.
  • Prettier & lint-staged: ensures code formatting is enforced before commits.
  • Optional checks: wires up typecheck and test scripts in package.json if present.
  • Use Case: in a JS/TS project, enable pre-commit checks to prevent committing unformatted or failing code.

Quick Start

Run this skill to automatically configure Husky, lint-staged, and Prettier in your repository and enable pre-commit 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 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 automate the configuration process to ensure code formatting is enforced before commits in your JavaScript or TypeScript project.

Can I run typecheck and tests automatically before committing code?▼

Yes, you can run typecheck and tests automatically before committing. The setup wires up typecheck and test scripts in your package.json if they already exist, executing them during the pre-commit hook.

What do I need to configure git hooks for formatting in a JS project?▼

You need a package manager lockfile (package-lock.json, yarn.lock, pnpm-lock.yaml, or bun.lockb) and permission to modify package.json and add Husky configuration to format code in a JS project.

What's the best way to enforce consistent code quality in a TypeScript repository?▼

The best way to enforce consistent code quality in a TypeScript repository is configuring pre-commit hooks using Husky and lint-staged to run Prettier, type checking, and tests on staged files.

Why does my pre-commit hook setup require a package manager lockfile?▼

Pre-commit hook setup requires a package manager lockfile to detect your project's package manager and correctly configure dependencies, ensuring Husky and lint-staged integrate properly with your existing environment.