lefthook
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
More from aaronflorey/agent-skills
amber-lang
Write, debug, and explain Amber code, the `amber` language that compiles `.ab` files to Bash. Use this skill when the user asks to write an Amber script, convert Bash to Amber, compile Amber to Bash, debug Amber syntax or type errors, or asks about Amber 0.5.1-alpha syntax, functions, types, error handling, the standard library, or the `amber` CLI.
26go-cobra
Write, scaffold, and debug Go CLI applications with `github.com/spf13/cobra`. Use this skill whenever the user mentions Cobra, `cobra.Command`, a Go command-line app, subcommands, persistent or local flags, required flags, argument validation, shell completions, generated docs, or wants to build or refactor a cobra-based CLI.
24laravel-actions
Write, scaffold, explain, and refactor code using the `lorisleiva/laravel-actions` package. Use this skill whenever the user mentions Laravel Actions, `AsAction`, `php artisan make:action`, action classes, converting a controller, job, listener, or command into an action, dispatching an action as a job, using an action as a controller or listener, or adding validation, authorization, testing, or mocking around an action.
24num30-config
Write, debug, and explain Go configuration code using `github.com/num30/config`. Use this skill when the user mentions `num30/config`, wants config structs, file plus env plus CLI flag loading, validation, config watching, precedence rules, or asks how to integrate the num30/config package into a Go application.
22pelican-panel-plugins
Write, scaffold, explain, and debug plugins for the Pelican gaming panel. Use this skill whenever the user mentions Pelican plugins, extending Pelican, FilamentPHP resources or pages for Pelican, plugin service providers, custom permissions, plugin settings, routes, models, widgets, or asks how to add new functionality to the Pelican panel.
21go-viper
Write, debug, and explain Go configuration code with `github.com/spf13/viper`. Use this skill whenever the user mentions Viper, `viper`, config structs, reading config from files plus env vars plus flags, Cobra or `pflag` integration, unmarshaling into structs, env key replacers, config precedence, config watching, or a clean Viper bootstrap.
20