setup-pre-commit

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

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

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 typecheck and tests before every commit. This Skill automates the entire setup in the current repository. ## Core Features & Use Cases - Husky Initialization: Installs Husky as a devDependency, runs npx husky init, and creates the .husky/pre-commit hook file. - lint-staged + Prettier: Configures .lintstagedrc to run prettier --ignore-unknown --write on all staged files, and creates 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 just scaffolded a new TypeScript project and want every commit to be auto-formatted, type-checked, and tested. Invoke this Skill and it installs the dependencies, writes the hook, and commits the setup through the new hooks as a smoke test. ## Quick Start Set up Husky pre-commit hooks with lint-staged, Prettier, typecheck, 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 Node.js project?▼

Install husky, lint-staged, and prettier as devDependencies, then run npx husky init to create the .husky directory. Write a .husky/pre-commit file that runs lint-staged, typecheck, and test scripts, and Husky executes it on every commit.

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

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

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 adapt the hook commands accordingly, replacing npm with the detected tool in the pre-commit script.

Why does my Husky hook not run after setup?▼

Common causes include a missing prepare script in package.json (it must be "husky"), a non-executable .husky/pre-commit file, or hooks installed before Git was initialized. Re-run npx husky init and verify the file permissions.

What if my project 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, otherwise every commit will fail with a missing-script error.