setup-pre-commit

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

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/Kunj-Sharma03/agent-contextify --skill setup-pre-commit-kunj-sharma03
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/Kunj-Sharma03/agent-contextify/tree/main/skills-main/skills/misc/setup-pre-commit
Command: npx skills add https://github.com/Kunj-Sharma03/agent-contextify --skill setup-pre-commit-kunj-sharma03

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. This Skill automates the entire setup of pre-commit hooks so every commit is automatically formatted, type-checked, and tested before it lands in the repository. ## Core Features & Use Cases - Husky Hook Setup: Initializes Husky and creates a .husky/pre-commit hook that runs lint-staged, typecheck, and tests. - lint-staged + Prettier: Configures lint-staged to run Prettier on all staged files, with a sensible default Prettier config created only 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 and verified. Run this Skill to install Husky, wire up lint-staged with Prettier, and add typecheck/test steps to the pre-commit hook in one pass. ## 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 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 files to prettier --ignore-unknown --write.

How to run Prettier on staged files before commit?

Use lint-staged with a .lintstagedrc containing {"*": "prettier --ignore-unknown --write"}. The --ignore-unknown flag skips files Prettier cannot parse, such as images, so the hook never fails on binary assets.

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 replace npm with the detected tool in the pre-commit hook commands.

Why does my Husky pre-commit hook not run?

Common causes are a missing prepare script in package.json (it must be "husky") or a non-executable .husky/pre-commit file. Husky v9+ does not require shebang lines in hook files.

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.