setup-pre-commit

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

2|Updated May 12, 2026
One-click install
npx skills add https://github.com/tajo9128/BioDockify-Pharma-AI --skill setup-pre-commit-tajo9128
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/tajo9128/BioDockify-Pharma-AI/tree/main/.agents/skills/setup-pre-commit
Command: npx skills add https://github.com/tajo9128/BioDockify-Pharma-AI --skill setup-pre-commit-tajo9128

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Manually wiring up pre-commit quality checks is error-prone and inconsistent across projects. This Skill automates the full setup of Husky pre-commit hooks so every commit is automatically formatted, type-checked, and tested before it lands in the repository. ## 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: Configures .lintstagedrc to run Prettier on all staged files and creates a sensible .prettierrc 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 every commit to be auto-formatted and type-checked. Run this Skill to install Husky, wire up lint-staged with Prettier, and verify the hook works 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, then run npx husky init to create the .husky directory. Add a .husky/pre-commit file that runs lint-staged, typecheck, and tests, and Husky will execute it on every commit.

How to run Prettier only on staged files before commit?

Use lint-staged with a .lintstagedrc config mapping files to prettier --ignore-unknown --write. lint-staged runs the command only on staged files, keeping pre-commit checks fast even in large repositories.

Does Husky work with pnpm, yarn, or bun?

Yes, Husky works with any package manager. The setup detects the package manager from lockfiles like pnpm-lock.yaml, yarn.lock, or bun.lockb and adapts the hook commands accordingly, defaulting to npm when unclear.

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

Common causes are a missing prepare script in package.json (it should be "husky"), a non-executable .husky/pre-commit file, or hooks not installed because npm install was not run after adding the prepare script.

What if my project has no typecheck or test script?

The pre-commit hook should omit those lines if the corresponding scripts do not exist in package.json. The setup checks for their presence and only includes commands that will actually run, then informs you of what was skipped.