setup-pre-commit

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

4|2|Updated Jun 20, 2026
One-click install
npx skills add https://github.com/saitarrun/devforge-ai --skill setup-pre-commit-saitarrun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/saitarrun/devforge-ai/tree/main/skills/precommit-hooks
Command: npx skills add https://github.com/saitarrun/devforge-ai --skill setup-pre-commit-saitarrun

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the risk of inconsistent code formatting, uncaught type errors, and failing tests being committed to a repository, which reduces avoidable CI failures and code review overhead for development teams.

Core Features & Use Cases

  • Automated Pre-Commit Validation: Runs Prettier formatting on staged files, plus type checking and test suites before any commit is finalized.
  • Zero-Config Defaults: Automatically creates Husky hook configurations, lint-staged settings, and default Prettier rules if they do not already exist in the project.
  • Use Case: Ideal for JavaScript and TypeScript projects where teams want to enforce consistent code style and catch errors early without manual pre-commit checks.

Quick Start

Use the setup-pre-commit skill to configure pre-commit hooks that run Prettier formatting, type checks, and tests on your repository's staged files before each commit.

Frequently Asked Questions about setup-pre-commit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate pre-commit hooks for Prettier formatting and type checks in JavaScript?

Automating pre-commit hooks for Prettier formatting and type checks involves configuring Husky and lint-staged to process staged files before commits are finalized, preventing inconsistent code formatting and uncaught type errors from entering version control.

What is the best way to enforce code quality on every commit in a TypeScript repository?

Enforcing code quality on every commit in a TypeScript repository is achieved by setting up Husky pre-commit hooks with lint-staged to automatically run Prettier formatting, type checking, and test suites against staged files.

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

Yes, this pre-commit setup works with pnpm, yarn, and bun package managers. It supports JavaScript and TypeScript repositories using these tools, provided existing typecheck and test scripts are defined in the project's package.json.

Can I use lint-staged with Husky to run tests on staged files without manual configuration?

You can use lint-staged with Husky to run tests on staged files without manual configuration by leveraging zero-config defaults that automatically create Husky hook configurations, lint-staged settings, and default Prettier rules if they do not already exist.

Why do I need pre-commit validation if I already have CI pipelines for code style and tests?

Pre-commit validation is needed alongside CI pipelines to catch inconsistent code formatting, type errors, and failing tests locally before they are pushed, reducing avoidable CI failures and minimizing code review overhead for development teams.