setup-pre-commit

Configure Husky pre-commit hooks with lint-staged and Prettier.

Updated Feb 28, 2026
One-click install
npx skills add https://github.com/raphaelmans/agent-skills --skill setup-pre-commit-raphaelmans
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/raphaelmans/agent-skills/tree/main/setup-pre-commit
Command: npx skills add https://github.com/raphaelmans/agent-skills --skill setup-pre-commit-raphaelmans

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers often commit unformatted or failing code, which leads to inconsistent code quality and wasted time. This Skill automatically configures pre-commit hooks to run formatting, linting, and optional type-checking and tests before each commit, ensuring code quality at the point of change.

Core Features & Use Cases

  • Adds Husky pre-commit hook
  • Runs lint-staged to format staged files with Prettier
  • Creates or updates Prettier config when missing
  • Integrates optional typecheck and test scripts if present in package.json
  • Verifies setup and provides a smoke test

Quick Start

Run this skill to automatically configure pre-commit hooks in your 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 set up Husky pre-commit hooks to run Prettier formatting?

To set up Husky pre-commit hooks with Prettier, this automation configures lint-staged to format staged files and creates a ready-to-use .husky directory along with a .lintstagedrc file.

Can I use pre-commit hooks with pnpm, yarn, or bun instead of npm?

Yes, you can use pre-commit hooks with pnpm, yarn, or bun. The setup automatically detects your active package manager and configures the hooks accordingly, provided a valid package.json exists.

How do I automatically run typecheck and tests before each commit?

To run typecheck and tests before each commit, the setup integrates existing scripts named typecheck or test from your package.json into the pre-commit hook execution flow.

What is the best way to prevent committing unformatted or failing code?

The best way to prevent committing unformatted code is using pre-commit hooks. This configuration runs Prettier formatting, linting, and optional tests directly at the point of change to ensure code quality.

Do I need a Prettier config file before automating pre-commit formatting?

No, you do not need an existing Prettier config. The setup automatically creates a .prettierrc file if one is missing, ensuring formatting rules are applied immediately during the pre-commit hook execution.