setup-pre-commit

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

1|Updated Mar 2, 2026
One-click install
npx skills add https://github.com/mst-software-vn/mst-checkscam --skill setup-pre-commit-mst-software-vn
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/mst-software-vn/mst-checkscam/tree/main/.claude/skills/setup-pre-commit
Command: npx skills add https://github.com/mst-software-vn/mst-checkscam --skill setup-pre-commit-mst-software-vn

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Setting up pre-commit hooks manually involves juggling Husky initialization, lint-staged configuration, Prettier defaults, and package manager differences, which is error-prone and easy to skip. This Skill automates the entire setup so every commit is automatically formatted, type-checked, and tested. ## Core Features & Use Cases - Automated Husky Setup: Detects your package manager (npm, pnpm, yarn, bun), installs husky, lint-staged, and prettier, then initializes the .husky directory. - Pre-Commit Pipeline: Creates a pre-commit hook that runs lint-staged (Prettier on staged files), followed by typecheck and test scripts when they exist in package.json. - Sensible Defaults: Generates .lintstagedrc and .prettierrc configs with standard settings only when they don't already exist, then verifies and commits the setup as a smoke test. - Use Case: You just scaffolded a new TypeScript project and want consistent code formatting enforced on every commit without manually researching Husky v9 configuration. ## Quick Start Set up pre-commit hooks with Husky, 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 with lint-staged?▼

Install husky, lint-staged, and prettier as devDependencies, run npx husky init, then create a .husky/pre-commit file that runs npx lint-staged. Add a .lintstagedrc mapping file patterns to prettier --write commands.

How to run Prettier only on staged files before commit?▼

Use lint-staged with a configuration like {"*": "prettier --ignore-unknown --write"} in .lintstagedrc. The pre-commit hook runs npx lint-staged, which applies Prettier only to files staged in Git, keeping commits fast.

Does Husky v9 need a shebang in hook files?▼

No, Husky v9 and later do not require shebang lines in hook files like .husky/pre-commit. You can write plain commands such as npx lint-staged directly in the file.

Can I use Husky with pnpm, yarn, or bun instead of npm?▼

Yes, Husky works with any package manager. Detect the lockfile (pnpm-lock.yaml, yarn.lock, bun.lockb) to choose the right install command, and adjust the hook commands to match the detected package manager.

What happens if my project has no typecheck or test script?▼

The pre-commit hook should omit the typecheck and test lines if those scripts are missing from package.json, otherwise every commit would fail. Only lint-staged with Prettier runs in that case.