setup-pre-commit

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

10|3|Updated Jul 18, 2019
One-click install
npx skills add https://github.com/tanqimin/MyFavsORM --skill setup-pre-commit-tanqimin
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/tanqimin/MyFavsORM/tree/main/.agents/skills/setup-pre-commit
Command: npx skills add https://github.com/tanqimin/MyFavsORM --skill setup-pre-commit-tanqimin

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Manually wiring up Git pre-commit hooks is error-prone and often skipped, letting unformatted or broken code slip into the repository. This Skill automates the entire setup of commit-time quality gates in a JavaScript/TypeScript project. ## 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 .lintstagedrc to auto-format staged files with Prettier, and creates 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 Node.js project and want every commit to be automatically formatted and verified. Run this Skill to install Husky, wire up lint-staged, and commit the working configuration in one pass. ## 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, then run npx husky init to create the .husky directory. Add a .husky/pre-commit file that runs lint-staged, typecheck, and test scripts.

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

Use lint-staged with a .lintstagedrc containing "*": "prettier --ignore-unknown --write". This formats only staged files during the pre-commit hook, keeping commits fast and skipping files Prettier cannot parse.

Does Husky work with pnpm, yarn, or bun?▼

Yes, Husky works with any package manager. Detect the package manager from lockfiles like pnpm-lock.yaml, yarn.lock, or bun.lockb, and adapt the hook commands to use that package manager instead of npm.

Why does my Husky pre-commit hook not run after setup?▼

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

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.