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/falentio/cimi --skill setup-pre-commit-falentio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/falentio/cimi/tree/main/.agents/skills/skills/setup-pre-commit
Command: npx skills add https://github.com/falentio/cimi --skill setup-pre-commit-falentio

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Setting up commit-time quality checks requires manually wiring together Husky, lint-staged, and Prettier, which is error-prone and easy to misconfigure across different package managers. ## Core Features & Use Cases - Husky Hook Setup: Initializes Husky and creates a .husky/pre-commit hook that runs lint-staged, typecheck, and tests. - Package Manager Detection: Detects npm, pnpm, yarn, or bun from lockfiles and adapts all commands accordingly. - Config Generation: Creates .lintstagedrc and a default .prettierrc only when no Prettier config exists. - Use Case: You clone a JavaScript repo with no commit hooks and want staged files auto-formatted plus typecheck and tests enforced before every 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 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 followed by typecheck and test scripts. 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 mapping "*" to "prettier --ignore-unknown --write". The pre-commit hook runs npx lint-staged, which applies Prettier only to files staged in Git.

Does Husky work with pnpm, yarn, or bun?

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

Why does my Husky pre-commit hook not run?

Common causes include a missing prepare script set to "husky" in package.json, a non-executable .husky/pre-commit file, or Husky not being initialized. Run npx husky init and verify the hook file exists and is executable.

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 to avoid failing every commit.