lingxling/awesome-skills-cn/git-hooks-automation
Claude Code and agent skill by lingxling/awesome-skills-cn
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Master Git hooks setup with Husky, lint-staged, pre-commit framework, and commitlint. Automate code quality gates, formatting, linting, and commit message enforcement before code reaches CI.
Install
npx vskill@latest install lingxling/awesome-skills-cn/git-hooks-automationSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as tmolavi/mcp-agent-skills-hub/git-hooks-automation.
Git Hooks Automation
Automate code quality enforcement at the Git level. Set up hooks that lint, format, test, and validate before commits and pushes ever reach your CI pipeline — catching issues in seconds instead of minutes.
When to Use This Skill
- User asks to "set up git hooks" or "add pre-commit hooks"
- Configuring Husky, lint-staged, or the pre-commit framework
- Enforcing commit message conventions (Conventional Commits, commitlint)
- Automating linting, formatting, or type-checking before commits
- Setting up pre-push hooks for test runners
- Migrating from Husky v4 to v9+ or adopting hooks from scratch
- User mentions "pre-commit", "commit-msg", "pre-push", "lint-staged", or "githooks"
Git Hooks Fundamentals
Git hooks are scripts that run automatically at specific points in the Git workflow. They live in .git/hooks/ and are not version-controlled by default — which is why tools like Husky exist.
Hook Types & When They Fire
| Hook | Fires When | Common Use | |
|---|---|---|---|
pre-commit | Before commit is created | Lint, format, type-check staged files | |
prepare-commit-msg | After default msg, before editor | Auto-populate commit templates | |
commit-msg | After user writes commit message | Enforce commit message format | |
post-commit | After commit is created | Notifications, logging | |
pre-push | Before push to remote | Run tests, check branch policies | |
pre-rebase | Before rebase starts | Prevent rebase on protected branches | |
post-merge | After merge completes | Install deps, run migrations | |
post-checkout | After checkout/switch | Install deps, rebuild assets |
Native Git Hooks (No Framework)
Problem: .git/hooks/ is local-only and not shared with the team. Use a framework instead.
Husky + lint-staged (Node.js Projects)
The modern standard for JavaScript/TypeScript projects. Husky manages Git hooks; lint-staged runs commands only on staged files for speed.
Quick Setup (Husky v9+)
Configure lint-staged in package.json
Add Commit Message Linting
Add Pre-Push Hook
Complete Husky Directory Structure
pre-commit Framework (Python / Polyglot)
Language-agnostic framework that works with any project. Hooks are defined in YAML and run in isolated environments.
Setup
Key Commands
Custom Hook Scripts (Any Language)
For projects not using Node or Python, write hooks directly in shell.
Portable Pre-Commit Hook
Share Custom Hooks via core.hooksPath
CI Integration
Hooks are a first line of defense, but CI is the source of truth.
Run pre-commit in CI (GitHub Actions)
Run lint-staged in CI (Validation Only)
Common Pitfalls & Fixes
Hooks Not Running
| Symptom | Cause | Fix | |
|---|---|---|---|
| Hooks silently skipped | Not installed in .git/hooks/ | Run npx husky init or pre-commit install | |
| "Permission denied" | Hook file not executable | chmod +x .husky/pre-commit | |
| Hooks run but wrong ones | Stale hooks from old setup | Delete .git/hooks/ contents, reinstall | |
| Works locally, fails in CI | Different Node/Python versions | Pin versions in CI config |
Performance Issues
Bypassing Hooks (When Needed)
Warning: Bypassing hooks should be rare. If your team frequently bypasses, the hooks are too slow or too strict — fix them.
Migration Guide
Husky v4 → v9 Migration
Adopting Hooks on an Existing Project
Key Principles
- Staged files only — Never lint the entire codebase on every commit
- Auto-fix when possible —
--fixflags reduce developer friction - Fast hooks — Pre-commit should complete in < 5 seconds
- Fail loud — Clear error messages with actionable fixes
- Team-shared — Use Husky or
core.hooksPathso hooks are version-controlled - CI as backup — Hooks are convenience; CI is the enforcer
- Gradual adoption — Start with formatting, add linting, then testing
Related Skills
@codebase-audit-pre-push- Deep audit before GitHub push@verification-before-completion- Verification before claiming work is done@bash-pro- Advanced shell scripting for custom hooks@github-actions-templates- CI/CD workflow templates
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingantigravity-awesome-skills/plugins/agentic-awesome-skills/skills/git-hooks-automation/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lingxling/awesome-skills-cn/git-hooks-automation)