setup-pre-commit

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill removes the guesswork and manual setup of commit-time quality gates by configuring automated pre-commit hooks that run formatting, type checks, and tests consistently.

Core Features & Use Cases

  • Husky pre-commit hook setup: Initializes Husky and creates a .husky/pre-commit file that runs your commit-time checks.
  • lint-staged + Prettier formatting: Configures lint-staged to format only staged files with Prettier using sensible defaults.
  • Typecheck and test integration: Adds npm run typecheck and npm run test to the hook when those scripts exist, ensuring the repo stays green.

Use case: when joining an engineering team or starting a new repo, you want every developer to automatically apply formatting and catch type/test failures before code lands.

Quick Start

Ask the agent to set up Husky pre-commit hooks with lint-staged (Prettier), and to add typecheck and test commands if the repo defines those scripts.

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, the skill automatically detects your package manager, initializes Husky, wires the `.husky/pre-commit` file, and generates the necessary lint-staged and Prettier configuration files to format staged files.

Can I automatically run typecheck and test scripts on each commit?

Yes, you can automatically run typecheck and test scripts on each commit. The setup detects if `npm run typecheck` and `npm run test` scripts exist in your repository and integrates them into the pre-commit hook to ensure your code stays green.

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

The best way to format only staged files before committing is by using lint-staged with Prettier. This skill configures lint-staged with sensible defaults to automatically apply formatting exclusively to your staged changes during the pre-commit hook execution.

Does the pre-commit hook setup work with different JavaScript package managers?

Yes, the pre-commit hook setup works with different JavaScript package managers. The skill explicitly detects the package manager used in your JavaScript or TypeScript repository and adapts the generated Husky and lint-staged commands accordingly.

Why do I need lint-staged when using Husky for pre-commit checks?

You need lint-staged when using Husky for pre-commit checks to ensure fast execution. While Husky triggers the git hook, lint-staged specifically targets staged files, running Prettier formatting and checks only on modified code rather than the entire repository.

What are the limitations of using pre-commit hooks for test automation?

A limitation of using pre-commit hooks for test automation is that the hook only executes `npm run test` if a test script is already defined in your repository, meaning you must manually establish your testing framework before this skill can integrate it.