---
name: "husky-git-hooks-lint-staged"
description: "Automate linter and formatter execution on staged Git files using modern Husky 9 and lint-staged."
metadata:
  author: "typicode"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "install husky 9"
  - "configure lint-staged"
  - "pre-commit hook husky"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Husky 9 & lint-staged Fast Git Pre-Commit Workflows

Configures Husky 9: initializing .husky/ directory, writing lightweight shell hooks (.husky/pre-commit), integrating with lint-staged for partial file formatting, and preventing broken commits.

## When to Invoke
Invoke this skill whenever you need to:
- install husky 9
- configure lint-staged
- pre-commit hook husky

## Execution SOP & Rules
1. Run npx husky init to create .husky/pre-commit and package.json prepare script.
2. Add npx lint-staged to .husky/pre-commit.
3. Configure 'lint-staged': { '*.{ts,tsx}': ['eslint --fix', 'prettier --write'] } in package.json.
4. Verify commit workflow: git add file.ts && git commit triggers lint-staged automatically.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
