setup-pre-commit

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Manually wiring up pre-commit hooks is error-prone and inconsistent across projects. This Skill automates the full setup of Husky, lint-staged, and Prettier so every commit is automatically formatted, type-checked, and tested before it lands. ## Core Features & Use Cases - Automated Hook Setup: Installs and initializes Husky, creates the .husky/pre-commit hook, and wires the prepare script in package.json. - Staged-File Formatting: Configures lint-staged to run Prettier only on staged files, keeping commits fast. - Quality Gates: Adds typecheck and test commands to the pre-commit hook, adapting to the detected package manager (npm, pnpm, yarn, or bun). - Use Case: You just scaffolded a new TypeScript project and want every commit auto-formatted and verified. Run this Skill to get a working pre-commit pipeline in one pass, including a smoke-test commit. ## 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 with lint-staged?▼

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

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

Use lint-staged with a .lintstagedrc config like {"*": "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 lock files (pnpm-lock.yaml, yarn.lock, bun.lockb) and adapt the hook commands accordingly, replacing npm with the detected tool.

Why does my Husky hook not run after setup?▼

Common causes are a missing prepare script in package.json (should be "husky") or a non-executable .husky/pre-commit file. Husky v9+ hooks do not need a shebang line, but the file must exist and Git hooks must be installed via the prepare script.

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.