home / skills / ehtbanton / claudeskillsrepo / husky-hooks-generator

husky-hooks-generator skill

/husky-hooks-generator

This skill generates Husky Git hooks for pre-commit, pre-push, and commit-msg as shell scripts compatible with Husky 9.x.

npx playbooks add skill ehtbanton/claudeskillsrepo --skill husky-hooks-generator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
714 B
---
name: husky-hooks-generator
description: Generate Husky Git hooks for pre-commit, pre-push, and commit-msg automation. Triggers on "create husky hooks", "generate git hooks", "husky setup", "pre-commit hooks".
---

# Husky Hooks Generator

Generate Husky Git hooks for automating code quality checks on commits.

## Output Requirements

**File Output:** `.husky/pre-commit`, `.husky/commit-msg`, `.husky/pre-push`
**Format:** Shell scripts
**Standards:** Husky 9.x

## When Invoked

Immediately generate Husky hook files for the specified automation tasks.

## Example Invocations

**Prompt:** "Create husky hooks for lint and test"
**Output:** Complete `.husky/pre-commit` with lint-staged and test commands.

Overview

This skill generates Husky Git hook files for pre-commit, pre-push, and commit-msg automation using Husky 9.x conventions. It produces ready-to-use shell scripts at .husky/pre-commit, .husky/commit-msg, and .husky/pre-push to run linting, tests, commit message validation, or other tasks. Use it to quickly enforce project-level quality gates and developer workflows.

How this skill works

When triggered, the skill creates three shell script files under the .husky directory formatted for Husky 9.x. Each file contains the appropriate shebang and commands to run tools like lint-staged, test runners, and commit message linters; content is tailored to the requested automation (for example, lint + test on pre-commit). The generated hooks are ready to be committed and activated by Husky in the repository.

When to use it

  • Setting up a new repository and you need standard Git hooks for quality checks
  • Enforcing linting and tests automatically before commits or pushes
  • Validating commit message format with commit-msg hook
  • Automating CI-early checks locally to reduce failing builds
  • Quickly scaffolding Husky hooks for TypeScript/Node projects

Best practices

  • Keep hook scripts small and fast; prefer running lightweight checks locally and deferring heavier tasks to CI
  • Use lint-staged in pre-commit to run linters only on staged files for speed
  • Validate commit messages with a linter (e.g., commitlint) in commit-msg to enforce consistent history
  • Avoid blocking developer workflows with long-running tests in pre-push; run full test suites in CI
  • Make generated hooks idempotent and include clear comments so maintainers can adapt commands

Example use cases

  • Create .husky/pre-commit that runs lint-staged and npm test for TypeScript projects
  • Generate .husky/commit-msg to run commitlint --edit $1 and enforce Conventional Commits
  • Produce .husky/pre-push to run a fast subset of tests or a build verification before pushing
  • Scaffold hooks for new contributors so their commits meet repository standards immediately

FAQ

What files are generated?

The skill generates .husky/pre-commit, .husky/commit-msg, and .husky/pre-push shell scripts formatted for Husky 9.x.

Can I customize the commands inside hooks?

Yes. The generated scripts include commands you can edit to run your preferred linters, test commands, or commit validators.