setup-pre-commit

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

88|9|Updated Jul 16, 2020
One-click install
npx skills add https://github.com/docs-plus/docs.plus --skill setup-pre-commit-docs-plus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/docs-plus/docs.plus/tree/main/.agents/skills/setup-pre-commit
Command: npx skills add https://github.com/docs-plus/docs.plus --skill setup-pre-commit-docs-plus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the risk of inconsistent code formatting, undetected type errors, and broken tests being committed to a repository, which reduces code review friction and prevents avoidable CI pipeline failures.

Core Features & Use Cases

  • Husky Pre-Commit Hook Integration: Automatically triggers validation checks every time a developer commits code, requiring no manual action from team members.
  • lint-staged + Prettier Configuration: Runs Prettier formatting only on staged files for fast, consistent code style enforcement across the entire team.
  • Type Check and Test Gating: Blocks commits that fail type checking or test suites, catching bugs and regressions before they enter the shared codebase.
  • Use Case: For a team building a JavaScript or TypeScript application, this Skill removes the need for developers to manually run formatting and tests before every commit, cutting down review cycles and eliminating broken code from being merged.

Quick Start

Use the setup-pre-commit skill to add automated pre-commit formatting, type checking, and test gating to your current JavaScript or TypeScript repository.

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 formatting and type checking in a JavaScript repository?

Automate pre-commit validation by configuring Husky hooks with lint-staged and Prettier to run formatting, type checks, and test suites automatically before code is committed, ensuring consistent code style without manual intervention.

How does lint-staged with Prettier improve git hooks workflow?

lint-staged with Prettier improves git hooks by running code formatting only on staged files, which enforces consistent style across the team quickly and prevents unformatted code from entering version control.

Can I use Husky pre-commit hooks to block broken tests in TypeScript projects?

Yes, Husky pre-commit hooks can gate commits in TypeScript projects by executing test suites and type checking, automatically blocking the commit if tests fail or type errors are detected to prevent regressions.

What is the best way to enforce code quality standards before committing?

The best way to enforce code quality before committing is to set up automated pre-commit hooks using Husky, lint-staged, and Prettier to validate formatting, types, and tests, removing reliance on manual developer checks.

Do I need to manually run Prettier and tests if I have git hooks configured?

No, configuring Husky git hooks with lint-staged removes the need to manually run Prettier and tests, as the pre-commit hook automatically executes these validation steps on staged files prior to the actual commit.