Agent Skills
› NeverSight/learn-skills.dev
› lefthook
lefthook
GitHub用于编写、调试和解释 Lefthook Git hooks 配置。适用于涉及 lefthook.yml、pre-commit/pre-push 钩子、文件过滤、作业/命令配置、本地覆盖及故障排除的场景,帮助用户快速构建高效可维护的 Git 工作流。
Trigger Scenarios
用户提到 lefthook 或 lefthook.yml 配置
需要安装或初始化 lefthook
询问 pre-commit、pre-push 等钩子行为
涉及 staged_files 或 push_files 过滤逻辑
配置 jobs、commands 或 scripts
使用本地覆盖或递归钩子问题排查
Install
npx skills add NeverSight/learn-skills.dev --skill lefthook -g -y
SKILL.md
Frontmatter
{
"name": "lefthook",
"source": "https:\/\/lefthook.dev\/",
"license": "MIT",
"version": "1.0.0",
"description": "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."
}
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
jobsfor new configs;commandsandscriptsare still valid and common. - Keep hooks fast and file-scoped with
{staged_files},{push_files},glob,file_types, androot. - Run
lefthook validatefor syntax checks andlefthook dumpwhen debugging merged config. - Remember:
lefthook installis usually one-time setup; config changes are read on each hook execution.
Fast Routing
| Need | Read |
|---|---|
| Install and official docs map | references/official-docs.md |
| CLI, config model, templates, merge order | references/api-surface.md |
| Common real-world patterns | references/common-use-cases.md |
| Why a hook is skipped or behaving oddly | references/troubleshooting-workarounds.md |
| Ready-to-copy configs | examples/basic-lefthook.yml, examples/monorepo-jobs.yml, examples/commit-message.yml, examples/lefthook-local.yml |
| Bad patterns and fixes | examples/anti-patterns.md |
Recommended Workflow
- Inspect existing package scripts, linters, test commands, and current Git hook tooling.
- Choose the smallest useful hook surface: usually
pre-commit,commit-msg, andpre-push. - Pick
jobs,commands, orscriptsbased on whether you need grouping, named merges, or external executables. - Scope work to changed files unless the check truly needs the whole repository.
- Add
lefthook-local.yml,extends, orremotesonly when you need local overrides or shared policy.
Core Rules
- Prefer deterministic, non-interactive hooks unless the workflow explicitly requires prompts.
- Use
stage_fixed: trueonly forpre-commitfixers that modify staged files. - Remember that
globis evaluated from the Git repo root, even whenrootchanges the working directory. - Use
LEFTHOOK=0for tools that would otherwise recurse back into Git hooks. - Use
lefthook run <hook>to debug a hook directly before testing the full Git flow.
External Docs
Version History
- e0220ca Current 2026-07-05 22:10


