Git Hooks Setup

Git Hooks Setup

Teaches an AI coding agent to set up Git hooks with Husky, pre-commit and custom scripts that enforce linting, tests, commit message rules and secret detection.

Skill files9 files

references/

scripts/

templates/

SKILL.md94 lines
1
---
2
name: git-hooks-setup
3
description: >
4
Implement Git hooks using Husky, pre-commit, and custom scripts. Enforce code
5
quality, linting, and testing before commits and pushes.
6
---
7
8
# Git Hooks Setup
9
10
## Table of Contents
11
12
- [Overview](#overview)
13
- [When to Use](#when-to-use)
14
- [Quick Start](#quick-start)
15
- [Reference Guides](#reference-guides)
16
- [Best Practices](#best-practices)
17
18
## Overview
19
20
Configure Git hooks to enforce code quality standards, run automated checks, and prevent problematic commits from being pushed to shared repositories.
21
22
## When to Use
23
24
- Pre-commit code quality checks
25
- Commit message validation
26
- Preventing secrets in commits
27
- Running tests before push
28
- Code formatting enforcement
29
- Linting configuration
30
- Team-wide standards enforcement
31
32
## Quick Start
33
34
Minimal working example:
35
36
```bash
37
#!/bin/bash
38
# setup-husky.sh
39
40
# Install Husky
41
npm install husky --save-dev
42
43
# Initialize Husky
44
npx husky install
45
46
# Create pre-commit hook
47
npx husky add .husky/pre-commit "npm run lint"
48
49
# Create commit-msg hook
50
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
51
52
# Create pre-push hook
53
npx husky add .husky/pre-push "npm run test"
54
55
# Create post-merge hook
56
npx husky add .husky/post-merge "npm install"
57
```
58
59
## Reference Guides
60
61
Detailed implementations in the `references/` directory:
62
63
| Guide | Contents |
64
|---|---|
65
| [Husky Installation and Configuration](references/husky-installation-and-configuration.md) | Husky Installation and Configuration |
66
| [Pre-commit Hook (Node.js)](references/pre-commit-hook-nodejs.md) | Pre-commit Hook (Node.js) |
67
| [Commit Message Validation](references/commit-message-validation.md) | Commit Message Validation |
68
| [Commitlint Configuration](references/commitlint-configuration.md) | Commitlint Configuration, Pre-push Hook (Comprehensive) |
69
| [Pre-commit Framework (Python)](references/pre-commit-framework-python.md) | Pre-commit Framework (Python) |
70
| [Secret Detection Hook](references/secret-detection-hook.md) | Secret Detection Hook, Husky in package.json |
71
72
## Best Practices
73
74
### ✅ DO
75
76
- Enforce pre-commit linting and formatting
77
- Validate commit message format
78
- Scan for secrets before commit
79
- Run tests on pre-push
80
- Skip hooks only with `--no-verify` (rarely)
81
- Document hook requirements in README
82
- Use consistent hook configuration
83
- Make hooks fast (< 5 seconds)
84
- Provide helpful error messages
85
- Allow developers to bypass with clear warnings
86
87
### ❌ DON'T
88
89
- Skip checks with `--no-verify`
90
- Store secrets in committed files
91
- Use inconsistent implementations
92
- Ignore hook errors
93
- Run full test suite on pre-commit
94

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…