setup-pre-commit

Automate Husky and lint-staged pre-commit hook setup with config files.

3|1|Updated Mar 23, 2026
One-click install
npx skills add https://github.com/malinskibeniamin/skills --skill setup-pre-commit-malinskibeniamin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/malinskibeniamin/skills/tree/main/setup-pre-commit
Command: npx skills add https://github.com/malinskibeniamin/skills --skill setup-pre-commit-malinskibeniamin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Sets up a reliable pre-commit workflow by installing and configuring Husky, lint-staged, Prettier, and typecheck, and by creating the necessary hooks and configs.

Core Features & Use Cases

  • Automates dependency installation and initialization of Husky
  • Configures lint-staged to run Prettier and typecheck on staged files
  • Creates .lintstagedrc and .prettierrc when absent
  • Verifies hook executability and presence of prepare script
  • Detects package manager from lockfile to support npm/yarn/pnpm

Quick Start

Configure pre-commit hooks in your repository by detecting the package manager, installing husky, lint-staged, and prettier, initializing Husky, and creating the pre-commit hook and config files.

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 pre-commit hooks with Husky and lint-staged?

Pre-commit hooks with Husky and lint-staged are set up by installing dev dependencies, initializing Husky, writing the pre-commit script, and generating configuration files like .lintstagedrc to enforce code quality on staged files automatically.

What does lint-staged run on staged files during a pre-commit hook?

Lint-staged runs Prettier and typecheck on staged files during a pre-commit hook. It uses the generated .lintstagedrc configuration to ensure code formatting and type validation are enforced before changes are committed.

Can I configure Husky pre-commit hooks for pnpm or yarn projects?

Yes, you can configure Husky pre-commit hooks for pnpm or yarn projects. The setup detects the package manager from the lockfile to install dependencies and initialize hooks correctly for npm, yarn, and pnpm environments.

How do I automate Prettier formatting in a Git pre-commit workflow?

To automate Prettier formatting in a Git pre-commit workflow, configure lint-staged to run Prettier on staged files. A .prettierrc configuration file is created if absent to ensure consistent code formatting across commits.

What's the best way to enforce typecheck and linting before committing code?

The best way to enforce typecheck and linting before committing code is using a pre-commit hook with Husky and lint-staged. This verifies hook executability and runs typecheck on staged files to prevent broken code from entering the repository.

Why does my pre-commit hook setup fail to verify hook executability?

Pre-commit hook setup fails to verify hook executability when the prepare script is missing or the hook file lacks execution permissions. The setup process checks for the presence of the prepare script and validates hook executability to ensure the workflow functions correctly.