setup-pre-commit

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

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/SevWren/Daily-Motivation-Brain-Helper --skill setup-pre-commit-sevwren
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/SevWren/Daily-Motivation-Brain-Helper/tree/main/CLAUDE/skills/misc/setup-pre-commit
Command: npx skills add https://github.com/SevWren/Daily-Motivation-Brain-Helper --skill setup-pre-commit-sevwren

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Manually wiring up pre-commit hooks is repetitive and error-prone: you must install Husky, configure lint-staged, create Prettier defaults, and remember to wire typecheck and test scripts into the hook. This Skill automates the entire setup in the current repository. ## Core Features & Use Cases - Package manager detection: Detects npm, pnpm, yarn, or bun from lockfiles and adapts all commands accordingly. - Complete hook setup: Installs husky, lint-staged, and prettier, initializes Husky, and writes the .husky/pre-commit hook running lint-staged, typecheck, and tests. - Sensible defaults: Creates .lintstagedrc and a .prettierrc (only if missing) with standard formatting rules, then verifies and commits the setup as a smoke test. - Use Case: You just scaffolded a new TypeScript project and want every commit auto-formatted and type-checked. Invoke this Skill and the hooks are installed, configured, and verified in one pass. ## 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 npx lint-staged. Add a .lintstagedrc mapping files to prettier --ignore-unknown --write.

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

Use lint-staged in the pre-commit hook with a .lintstagedrc containing { "*": "prettier --ignore-unknown --write" }. This formats only staged files, and --ignore-unknown skips files Prettier cannot parse.

Does Husky v9 need a shebang in hook files?▼

No, Husky v9 and later do not require shebang lines in hook files like .husky/pre-commit. You can write plain commands such as npx lint-staged directly in the file.

Can I use Husky with pnpm, yarn, or bun instead of npm?▼

Yes, the setup detects the package manager from lockfiles: pnpm-lock.yaml for pnpm, yarn.lock for yarn, and bun.lockb for bun. All hook commands are adapted to the detected manager, defaulting to npm.

What if my project has no typecheck or test script?▼

If package.json lacks a typecheck or test script, those lines are omitted from the pre-commit hook and you are informed. The hook then runs only lint-staged for staged-file formatting.