setup-pre-commit

Configure Husky, lint-staged, and Prettier pre-commit checks.

195|16|Updated Feb 18, 2025
One-click install
npx skills add https://github.com/InditexTech/weavejs --skill setup-pre-commit-inditextech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/InditexTech/weavejs/tree/main/code/.agents/skills/setup-pre-commit
Command: npx skills add https://github.com/InditexTech/weavejs --skill setup-pre-commit-inditextech

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This setup guides teams to add pre-commit hooks that ensure code quality before commits by automating Husky initialization, lint-staged integration, Prettier configuration, and optional type checking and tests.

Core Features & Use Cases

  • Husky pre-commit hook that runs on commits
  • lint-staged integration to format staged files with Prettier
  • Prettier configuration applied when missing
  • optional validation via typecheck and test scripts in the pre-commit flow

Quick Start

Run the guided steps to initialize Husky, install lint-staged and Prettier, and configure the pre-commit hook in your project.

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, this configuration installs Husky, lint-staged, and Prettier as dev dependencies, then initializes Husky and creates a pre-commit script that runs formatting and validation on staged files.

Can I run typecheck and tests automatically before a git commit?

Yes, you can run typecheck and tests automatically before a commit by wiring those scripts into the Husky pre-commit hook alongside lint-staged, ensuring code validation occurs locally before changes are submitted.

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

Yes, the pre-commit setup works across various languages and project setups by automatically detecting your active package manager to install dev dependencies and initialize Husky correctly for your environment.

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

The best way to format only staged files is using lint-staged integration, which configures Prettier to target and format exclusively the files you have staged, preventing untouched code from being affected.

Why do I need lint-staged if I already have Prettier configured?

You need lint-staged alongside Prettier because lint-staged restricts formatting and validation checks to only staged files, making pre-commit hooks fast and preventing unnecessary reformatting of the entire project codebase.

What happens if Prettier configuration is missing in my repository?

If Prettier configuration is missing in your repository, this setup applies a default Prettier configuration during the guided initialization process to ensure consistent code formatting standards are enforced.