setup-pre-commit

Configures Husky pre-commit hooks with lint-staged, Prettier, type checking, and tests.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires husky, lint-staged, prettier.

What problem does it solve? Manually wiring up commit-time quality checks is repetitive and error-prone: developers must install Husky, configure lint-staged, create Prettier configs, and remember to run type checks and tests before every commit. This Skill automates the entire setup so staged files are formatted and validated on every commit. ## Core Features & Use Cases - Husky Hook Setup: Installs Husky, initializes the .husky/ directory, and creates a pre-commit hook that runs lint-staged, typecheck, and tests. - lint-staged + Prettier Configuration: Creates .lintstagedrc to run Prettier on all staged files and generates a .prettierrc with sensible defaults if none exists. - Package Manager Detection: Detects npm, pnpm, yarn, or bun from lockfiles and adapts all commands accordingly. - Use Case: You inherit a JavaScript repo with no commit-time checks. Run this Skill to install Husky, wire lint-staged with Prettier, add typecheck and test steps to the pre-commit hook, and verify everything with a smoke-test commit. ## Quick Start Set up Husky pre-commit hooks with lint-staged, Prettier, type checking, and tests in this 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 in a JavaScript project?▼

Install husky, lint-staged, and prettier as devDependencies, then run npx husky init to create the .husky directory. Create a .husky/pre-commit file that runs npx lint-staged followed by your typecheck and test scripts.

How to run Prettier on staged files with lint-staged?▼

Create a .lintstagedrc file mapping "*" to "prettier --ignore-unknown --write" so every staged file is formatted on commit. The --ignore-unknown flag skips files Prettier cannot parse, such as images.

Does Husky work with pnpm, yarn, or bun?▼

Yes, Husky works with any package manager. Detect the package manager from lockfiles like pnpm-lock.yaml, yarn.lock, or bun.lockb, then replace npm with the detected tool in the pre-commit hook commands.

Why does my Husky hook not run after setup?▼

The hook may be missing execute permissions or the prepare script may not be set to "husky" in package.json. Verify .husky/pre-commit exists and is executable, then run npx lint-staged manually to confirm it works.

What if my package.json has no typecheck or test script?▼

Omit those lines from the .husky/pre-commit file and inform the user. The hook should only reference scripts that actually exist in package.json to avoid failing every commit.