setup-pre-commit

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

Updated Sep 19, 2026
One-click install
npx skills add https://github.com/Ab0umar/selrs.cc.BU --skill setup-pre-commit-ab0umar
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/Ab0umar/selrs.cc.BU/tree/main/.agents/skills/setup-pre-commit
Command: npx skills add https://github.com/Ab0umar/selrs.cc.BU --skill setup-pre-commit-ab0umar

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Setting up commit-time quality checks manually involves juggling Husky initialization, lint-staged configuration, Prettier defaults, and package.json scripts, which is error-prone and easy to skip. This Skill automates the entire setup so every commit is formatted, type-checked, and tested before it lands. ## Core Features & Use Cases - Husky Hook Setup: Initializes Husky v9+ and creates a .husky/pre-commit hook that runs lint-staged, typecheck, and tests. - lint-staged + Prettier Configuration: Creates .lintstagedrc to run Prettier on staged files and generates a .prettierrc with sensible defaults 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 consistent formatting and type safety enforced on every commit. Invoke this Skill to install and wire up the full pre-commit pipeline, then verify it with a smoke-test commit. ## Quick Start Set up pre-commit hooks with Husky, 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 in a Node.js project?▼

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. Husky v9+ hook files do not need a shebang line.

How to run Prettier only 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 the lockfile (pnpm-lock.yaml, yarn.lock, bun.lockb, or package-lock.json) and substitute the matching command in the pre-commit hook and install steps.

What if my package.json 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 with a missing-script error.

Why is my Husky pre-commit hook not running?▼

Verify that .husky/pre-commit exists and is executable, that package.json contains a prepare script set to "husky", and that husky init was run after installation. Running npx lint-staged manually confirms the staged-file pipeline works.