Learn-skills.dev lefthook
Write, debug, and explain Lefthook configuration for Git hooks. Use this skill when the user mentions `lefthook`, `lefthook.yml`, `lefthook install`, `pre-commit`, `pre-push`, staged-file or push-file filtering, `jobs`, `commands`, `scripts`, local overrides, or troubleshooting hook execution and recursive hook behavior.
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/aaronflorey/agent-skills/lefthook" ~/.claude/skills/neversight-learn-skills-dev-lefthook && rm -rf "$T"
manifest:
data/skills-md/aaronflorey/agent-skills/lefthook/SKILL.mdsource content
Lefthook
Use this skill to configure fast, maintainable Git hooks with Lefthook.
Start Here
- Match install instructions to the project ecosystem: npm, Go, Ruby, Python, Homebrew, or standalone binary.
- Prefer
for new configs;jobs
andcommands
are still valid and common.scripts - Keep hooks fast and file-scoped with
,{staged_files}
,{push_files}
,glob
, andfile_types
.root - Run
for syntax checks andlefthook validate
when debugging merged config.lefthook dump - Remember:
is usually one-time setup; config changes are read on each hook execution.lefthook install
Fast Routing
| Need | Read |
|---|---|
| Install and official docs map | |
| CLI, config model, templates, merge order | |
| Common real-world patterns | |
| Why a hook is skipped or behaving oddly | |
| Ready-to-copy configs | , , , |
| Bad patterns and fixes | |
Recommended Workflow
- Inspect existing package scripts, linters, test commands, and current Git hook tooling.
- Choose the smallest useful hook surface: usually
,pre-commit
, andcommit-msg
.pre-push - Pick
,jobs
, orcommands
based on whether you need grouping, named merges, or external executables.scripts - Scope work to changed files unless the check truly needs the whole repository.
- Add
,lefthook-local.yml
, orextends
only when you need local overrides or shared policy.remotes
Core Rules
- Prefer deterministic, non-interactive hooks unless the workflow explicitly requires prompts.
- Use
only forstage_fixed: true
fixers that modify staged files.pre-commit - Remember that
is evaluated from the Git repo root, even whenglob
changes the working directory.root - Use
for tools that would otherwise recurse back into Git hooks.LEFTHOOK=0 - Use
to debug a hook directly before testing the full Git flow.lefthook run <hook>