setup-pre-commit

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

1|Updated Jul 13, 2026
One-click install
npx skills add https://github.com/dineshrevunuru/SuperSkills --skill setup-pre-commit-dineshrevunuru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/dineshrevunuru/SuperSkills/tree/main/setup-pre-commit
Command: npx skills add https://github.com/dineshrevunuru/SuperSkills --skill setup-pre-commit-dineshrevunuru

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Unformatted or broken code reaches a repository's history because formatting and checks rely on developers remembering to run them. This Skill installs a Husky pre-commit gate that enforces Prettier, ESLint, typecheck, and fast staged-scoped tests automatically on every commit. ## Core Features & Use Cases - Two installation modes: Minimal mode runs lint-staged with Prettier on staged files only; full mode adds typecheck and fast staged-scoped tests (e.g. vitest related --run) for client production repos. - Staged-files-only speed discipline: Keeps the gate sub-second by scoping all checks to staged files and moving slow suites like Playwright e2e to pre-push or CI, preventing --no-verify bypass habits. - Config detection and preservation: Detects package manager from lockfiles, preserves existing Prettier and Husky configurations, and audits existing hooks instead of reinstalling. - Use Case: A client Next.js/TypeScript repo with no protection keeps getting unformatted diffs and type errors on main; the Skill installs a full-mode gate that formats staged files, typechecks, and runs only affected unit tests in under a second. ## Quick Start Set up Husky pre-commit hooks with lint-staged and Prettier on this repo, using full mode with typecheck and staged-scoped tests if the scripts exist.

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 write a .husky/pre-commit file containing npx lint-staged. Add a .lintstagedrc mapping file globs to prettier --write and eslint --fix commands.

What should run in pre-commit vs CI?

Pre-commit should run Prettier and ESLint on staged files only, plus a fast typecheck and staged-scoped unit tests like vitest related --run. Full test suites and Playwright e2e belong in pre-push or CI because slow hooks get bypassed with --no-verify.

Does Husky work with pnpm, yarn, or bun?

Yes, Husky works with any package manager. Detect the manager from the lockfile (pnpm-lock.yaml, yarn.lock, bun.lockb, or package-lock.json) and use that manager's commands for installing dependencies and running scripts.

Why do developers bypass pre-commit hooks with --no-verify?

Hooks get bypassed when they take too long, typically because they format the entire repo or run full test suites on every commit. Keeping checks scoped to staged files makes the gate sub-second so bypassing never becomes a habit.

Should I add pre-commit hooks to a prototype project?

No, prototypes and throwaway demos should not get pre-commit gates since hardcoded values and quick hacks are acceptable there. Install the gate only on maintained or client-facing repositories where a bad commit has real cost.