setup-pre-commit

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

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/QT-7274/dotfiles --skill setup-pre-commit-qt-7274
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/QT-7274/dotfiles/tree/main/setup-pre-commit
Command: npx skills add https://github.com/QT-7274/dotfiles --skill setup-pre-commit-qt-7274

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Manually configuring Git pre-commit hooks involves juggling Husky initialization, lint-staged rules, Prettier config, and package manager differences. This Skill automates the entire setup so every commit is automatically formatted, type-checked, and tested. ## Core Features & Use Cases - Automated Husky Setup: Installs Husky, lint-staged, and Prettier as devDependencies and initializes the .husky/ directory with a prepare script. - Package Manager Detection: Detects npm, pnpm, yarn, or bun from lockfiles and adapts all commands accordingly. - Quality Gate Hook: Creates a pre-commit hook that runs lint-staged (Prettier on staged files), then typecheck and test scripts when they exist. - Use Case: You just scaffolded a new TypeScript project and want consistent formatting and test enforcement on every commit. Run this Skill to get a working pre-commit pipeline in one pass, verified by an actual commit. ## Quick Start Set up Husky pre-commit hooks with lint-staged and Prettier 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 Node.js project?▼

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

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

Create a .lintstagedrc file mapping file patterns to commands, such as {"*": "prettier --ignore-unknown --write"}. The --ignore-unknown flag skips files Prettier cannot parse, like images.

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

Yes, Husky works with any package manager. Detect the package manager from lockfiles (pnpm-lock.yaml, yarn.lock, bun.lockb) and substitute the appropriate command in the hook file instead of npm.

Why does my Husky hook fail if typecheck or test scripts are missing?▼

The pre-commit hook fails when package.json lacks the referenced scripts. Omit the typecheck or test lines from .husky/pre-commit if those scripts do not exist, and add them later once defined.

Do Husky v9 hooks need a shebang line?▼

No, Husky v9 and later do not require shebang lines in hook files. Write the commands directly in .husky/pre-commit, one per line.