setup-pre-commit

Set up Husky pre-commit hooks with lint-staged and Prettier.

1|Updated May 7, 2026
One-click install
npx skills add https://github.com/Soham407/studio-kickstart --skill setup-pre-commit-soham407
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/Soham407/studio-kickstart/tree/main/architecture/matt-pocock-setup-pre-commit
Command: npx skills add https://github.com/Soham407/studio-kickstart --skill setup-pre-commit-soham407

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of preventing low-quality code from reaching your Git history by adding consistent commit-time formatting, type checking, and tests.

Core Features & Use Cases

  • Husky pre-commit hook: Installs a Git hook that runs automatically on each commit.
  • lint-staged with Prettier: Formats only the files staged for commit using Prettier via lint-staged.
  • Commit-time quality gates: Runs typecheck and test scripts during the pre-commit flow when those scripts exist.
  • Config bootstrapping: Creates .lintstagedrc and a default .prettierrc when missing, so formatting is immediately consistent.

Quick Start

Ask an AI to set up Husky and lint-staged so your repo runs Prettier on staged files and executes type checking and tests during pre-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 set up Husky pre-commit hooks to run Prettier on staged files?

To set up Husky pre-commit hooks with Prettier, install Husky and lint-staged as devDependencies, initialize Husky, and generate a `.husky/pre-commit` file alongside a `.lintstagedrc` config to format staged files automatically on commit.

What is the best way to prevent unformatted code from reaching my Git history?

Using a Husky pre-commit hook with lint-staged is an effective way to prevent unformatted code from entering Git history, running Prettier formatting and optional quality checks on staged files before the commit is finalized.

Can I run typecheck and test scripts during the pre-commit flow?

Yes, the pre-commit hook can execute typecheck and test scripts during the commit flow when those scripts already exist in your project, ensuring code quality and preventing regressions before changes are committed.

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

Yes, this pre-commit setup supports JavaScript and TypeScript repositories using npm, pnpm, yarn, or bun by detecting the active package manager before installing devDependencies and initializing the Husky Git hooks.

Do I need to manually create a `.prettierrc` or `.lintstagedrc` file before setup?

You do not need to manually create config files; the setup automatically bootstraps a default `.prettierrc` and generates `.lintstagedrc` if they are absent, ensuring formatting is immediately consistent across your repository.