setup-pre-commit

Configure Husky and lint-staged pre-commit hooks for JavaScript/TypeScript repositories.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of catching formatting, type, and test failures before they reach the main codebase by automating consistent pre-commit verification.

Core Features & Use Cases

  • Husky pre-commit hook setup: Installs and initializes Husky so every commit runs checks automatically.
  • lint-staged + Prettier on staged files: Configures lint-staged to run Prettier only on what changed, keeping feedback quick and relevant.
  • Pre-commit typecheck and tests: Wires in repo-level scripts (typecheck/test) so basic quality gates run at commit time.
  • Use Case: When a team frequently forgets to format or occasionally introduces type/test regressions, this Skill ensures those issues are surfaced immediately during local commits.

Quick Start

Ask the AI to set up Husky pre-commit hooks in this repo using lint-staged with Prettier, and include typecheck and test runs if the 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 lint-staged and Prettier?

To set up Husky pre-commit hooks with lint-staged, install both packages alongside Prettier, initialize Husky, and generate a pre-commit hook that runs staged formatting plus repository typecheck and test scripts when present.

What is the best way to run Prettier only on staged files before committing?

Running Prettier only on staged files is handled by lint-staged. Configuring a `.lintstagedrc` file ensures Prettier targets only changed files, keeping pre-commit feedback quick and relevant without reformatting the entire repository.

Can I run typecheck and test scripts automatically before every commit?

Yes, you can run typecheck and test scripts automatically before every commit. The pre-commit hook wires in repository-level typecheck and test scripts so basic quality gates execute at commit time if those scripts are present.

Does this pre-commit setup work with different package managers?

Yes, the pre-commit setup works with different package managers. It detects the repository lockfile to standardize commit-time formatting, type checking, and test execution across common package-manager setups.

Do I need an existing .prettierrc file to configure pre-commit checks?

No, you do not need an existing .prettierrc file to configure pre-commit checks. A default .prettierrc file is generated only if one is missing, ensuring Prettier formatting rules are present before hooks run.

Why should I use lint-staged instead of running Prettier on the whole project?

You should use lint-staged instead of running Prettier on the whole project to keep feedback quick. lint-staged runs Prettier only on staged files, preventing slow pre-commit verification and avoiding unrelated formatting changes.