setup-pre-commit

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

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/kashman001/ai-workspace-template --skill setup-pre-commit-kashman001
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-pre-commit
Source: https://github.com/kashman001/ai-workspace-template/tree/main/skills/setup-pre-commit
Command: npx skills add https://github.com/kashman001/ai-workspace-template --skill setup-pre-commit-kashman001

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Setting up commit-time quality checks in a JavaScript or TypeScript repo involves wiring together Husky, lint-staged, and Prettier with the right config files and package manager commands, which is repetitive and easy to misconfigure. ## 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 Config: Creates .lintstagedrc to format staged files and a default .prettierrc if none exists. - Package Manager Detection: Detects npm, pnpm, yarn, or bun from lockfiles and adapts all commands accordingly. - Use Case: You start a new TypeScript project and want every commit automatically formatted, type-checked, and tested. Run this Skill to install the dependencies, write the hook and config files, and verify everything 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. Write a .husky/pre-commit file that runs lint-staged, typecheck, and test scripts, and add a .lintstagedrc for staged-file formatting.

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

Use lint-staged with a .lintstagedrc containing {"*": "prettier --ignore-unknown --write"}. The pre-commit hook runs npx lint-staged, which applies Prettier only to files staged in Git, keeping commits fast.

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

Yes, Husky works with any package manager. Detect the package manager from lockfiles (pnpm-lock.yaml, yarn.lock, bun.lockb) and adapt the hook commands accordingly, replacing npm with the detected tool in the pre-commit script.

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 and is executable.

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 with a missing-script error.