vitalikpestov/skills-catalog/ln-742-precommit-setup
Claude Code and agent skill by vitalikpestov/skills-catalog
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Configures Husky, lint-staged, commitlint, and Python pre-commit hooks. Use when adding Git hook automation to a project.
Install
npx vskill@latest install vitalikpestov/skills-catalog/ln-742-precommit-setupSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as vitalikpestov/skills-catalog/ln-742-precommit-setup.
Paths: File paths (references/,../ln-*) are relative to this skill directory.
ln-742-precommit-setup
Type: L3 Worker Category: 7XX Project Bootstrap
Sets up Git hooks for automated code quality enforcement before commits.
Purpose & Scope
Does:
- Installs hook management tools (Husky or pre-commit)
- Configures staged file linting (lint-staged or pre-commit hooks)
- Sets up commit message validation (commitlint)
- Verifies hooks trigger correctly
Does NOT:
- Configure linters themselves (ln-741 does this)
- Set up test infrastructure (ln-743 does this)
- Modify source code
Supported Stacks
| Technology | Hook Manager | Staged Linting | Commit Validation | |
|---|---|---|---|---|
| Node.js | Husky | lint-staged | commitlint | |
| Python | pre-commit | pre-commit hooks | pre-commit hook | |
| Mixed | Both (if needed) | Stack-specific | commitlint |
Phase 1: Check Existing Hooks
Before installing, check for existing hook configurations.
Files to Check:
| Tool | Indicators | |
|---|---|---|
| Husky | .husky/ directory, husky in package.json | |
| pre-commit | .pre-commit-config.yaml | |
| lint-staged | lint-staged in package.json or .lintstagedrc* | |
| commitlint | commitlint.config.*, .commitlintrc* |
Decision Logic:
- If hooks exist and working: SKIP (inform user)
- If partial setup: ASK user to complete or replace
- If no hooks: CREATE from templates
Phase 2: Install Hook Manager
Node.js Projects (Husky)
This creates:
.husky/directory.husky/pre-commithook file- Adds
preparescript to package.json
Python Projects (pre-commit)
This creates:
.git/hooks/pre-commit(managed by pre-commit)- Requires
.pre-commit-config.yamlfor configuration
Phase 3: Configure Staged Linting
Node.js (lint-staged)
Create configuration (.lintstagedrc.mjs or in package.json):
Key Rules:
- TypeScript files: ESLint + Prettier
- JSON/MD/CSS: Prettier only
- C# files: dotnet format (if mixed project)
CRITICAL FIX: For .NET files, use correct syntax:"*.cs": "dotnet format --include"is WRONGUse:"*.cs": "dotnet format whitespace --include"or run dotnet format separately
Python (pre-commit hooks)
Configuration in .pre-commit-config.yaml:
Phase 4: Configure Commit Message Validation
Node.js (commitlint)
Create commitlint.config.mjs with:
- Conventional Commits format
- Allowed types: feat, fix, docs, style, refactor, test, chore, ci
- Max header length: 100 characters
Update Husky hook
Add commit-msg hook:
Python (pre-commit hook for commit message)
Add to .pre-commit-config.yaml:
Phase 5: Test Hooks
Verify hooks work correctly.
Test 1: Lint-staged triggers
Test 2: Commit message validation
Cleanup:
Critical Rules
RULE 1: Husky requires Git repository (git initfirst).
RULE 2: lint-staged MUST have linters configured first (run ln-741 before ln-742).
RULE 3: Document--no-verifyescape hatch for emergency commits.
RULE 4: pre-commit hooks should auto-fix when possible (--fixflag).
Monitor (2.1.98+): When hook verification invokes lint/test commands expected >30s, use Monitor. Fallback: Bash(run_in_background=true).
Definition of Done
- [ ] Hook manager installed (Husky or pre-commit)
- [ ] Staged linting configured and working
- [ ] Commit message validation configured
- [ ] Test commit triggers hooks correctly
- [ ] User informed of:
- How hooks work
- How to skip hooks in emergency (
git commit --no-verify) - Commit message format required
Reference Files
| File | Purpose | |
|---|---|---|
| husky_precommit_template.sh | Husky pre-commit hook | |
| husky_commitmsg_template.sh | Husky commit-msg hook | |
| lintstaged_template.mjs | lint-staged configuration | |
| commitlint_template.mjs | commitlint configuration | |
| precommit_config_template.yaml | Python pre-commit config | |
| hooks_guide.md | Detailed hooks guide |
Error Handling
| Error | Cause | Resolution | |
|---|---|---|---|
| Husky not running | Missing prepare script | Run npx husky init again | |
| lint-staged fails | Missing linter | Run ln-741 first | |
| pre-commit not found | Not in PATH | pip install pre-commit | |
| Hooks not triggering | Git hooks disabled | Check .git/hooks/ permissions | |
| Windows path issues | Shell script format | Use cross-platform syntax |
Emergency Bypass
Document for users:
Version: 2.0.0 Last Updated: 2026-01-10
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking_AI-Automation/claude-code-skills-levnikolaevich/plugins/project-bootstrap/skills/ln-742-precommit-setup/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/vitalikpestov/skills-catalog/ln-742-precommit-setup)