setup-pre-commit

Automate Husky pre-commit hook setup with lint-staged and Prettier.

Updated Mar 23, 2026
One-click install
npx skills add https://github.com/fray-cloud/coin --skill setup-pre-commit-fray-cloud
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/fray-cloud/coin/tree/main/.agents/skills/setup-pre-commit
Command: npx skills add https://github.com/fray-cloud/coin --skill setup-pre-commit-fray-cloud

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers waste time debugging breaking commits due to inconsistent formatting and missing checks. This skill sets up Husky pre-commit hooks with lint-staged, Prettier, and tests to ensure code quality before every commit.

Core Features & Use Cases

  • Automated pre-commit checks: Run lint-staged, format with Prettier, and execute type checks and tests during commit.
  • Husky initialization: Automatically creates the .husky directory and hooks configuration.
  • Config auto-detection: Detects package manager (npm, pnpm, yarn, bun) and adjusts commands accordingly.
  • Use Case: A team wants to prevent formatting and test failures from reaching the main branch by enforcing checks at commit time.

Quick Start

Run the setup to wire Husky pre-commit hooks into 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 with lint-staged and Prettier?

To set up Husky pre-commit hooks, you need to initialize the hooks directory, configure lint-staged to run Prettier formatting, and execute type checks and tests automatically before every commit.

What are pre-commit hooks used for in a git repository?

Pre-commit hooks are used to enforce code quality by running automated checks like formatting, type checking, and tests before a commit is finalized, preventing breaking changes from reaching the main branch.

Does the Husky pre-commit setup work with pnpm or yarn?

Yes, the Husky pre-commit setup works with pnpm and yarn by automatically detecting the active package manager and adjusting the configuration commands accordingly.

What's the best way to enforce code formatting before a git commit?

The best way to enforce code formatting before a git commit is to configure lint-staged with Prettier inside a Husky pre-commit hook to automatically format staged files and run tests.

Can I run type checks and tests automatically during a git commit?

Yes, you can run type checks and tests automatically during a git commit by initializing Husky and adding the respective typecheck and test commands to the pre-commit hook configuration.

Why do I need lint-staged in my pre-commit hook setup?

You need lint-staged in your pre-commit hook setup to run scripts like Prettier formatting and type checking only on staged files, ensuring fast execution and clean commits without formatting failures.