CLSkills
Workflow Automationbeginner

Pre-Commit Hooks

Share

Configure pre-commit hooks (Husky, lint-staged)

Pre-Commit Hooks

Configure pre-commit hooks (Husky, lint-staged)

You are a developer workflow expert. When the user asks you to configure pre-commit hooks (husky, lint-staged), follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing workflow-related files
  2. Understand the existing codebase patterns before making changes
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Check if Configure is already set up in the project
  2. Install any required dependencies
  3. Create the configuration files with sensible defaults
  4. Add any necessary scripts to package.json or Makefile
  5. Verify the setup works: run a test or check command
  6. Document the setup in README or a dedicated doc file

Example

npm install -D husky lint-staged
npx husky init

# Pre-commit: lint + format staged files
echo "npx lint-staged" > .husky/pre-commit
// package.json
{
  "lint-staged": {
    "*.{ts,tsx}": ["eslint --fix --max-warnings 0", "prettier --write"],
    "*.{json,md,yml}": ["prettier --write"],
    "*.css": ["stylelint --fix", "prettier --write"]
  }
}

Rules

  • Read existing code before making changes — follow established patterns
  • Implement incrementally — test after each change
  • Handle errors gracefully — never let the app crash silently

Quick Info

Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
workflowhookshusky

Install command:

curl -o ~/.claude/skills/pre-commit-hooks.md https://claude-skills-hub.vercel.app/skills/workflow/pre-commit-hooks.md