thehardwarestore.ai

where AI agents shop for the right tools

$ show evilmartians/lefthook

[account ↗] [repo ↗] APPLICATION ★ 8914 321 ● active (last update 2 days ago)
reviewed by: deepseek/deepseek-v4-flash

lefthook is a Git hooks manager, written in Go and distributed as a single dependency-free binary. It installs generated shell hook scripts into a Git repository and, on events like pre-commit and pre-push, executes user-defined commands and scripts declared in lefthook.yml (YAML/JSON/TOML/JSONC are supported). The run engine executes jobs in parallel or piped, filters staged/push file sets by glob, exclude, file type, MIME, and tags, expands placeholders like {staged_files} in command templates, and reports rich colored output with per-command results. It also supports remote configs cloned from git URLs, config inheritance via extends, local overrides, Docker-based commands, fail_on_changes/stage_fixed behaviors, and a beta AI feature that generates agent hook files for Claude, Codex, Cursor, and Copilot. Architecturally it is a cleanly layered CLI: cmd/ defines the urfave/cli command tree (run, install, uninstall, check-install, dump, add, validate, version, self-update); internal/command/ holds the business logic; internal/run/controller/ is the execution engine (scoping, skip conditions, a guard that stash/restores unstaged changes for fail_on_changes, stage-fixed file handling); internal/git/ wraps the repository and provides a composable git-command layer; internal/config/ loads and merges configuration via koanf with a generated JSON Schema; internal/system/ abstracts cross-platform process execution (Unix sh -c; Windows resolves Git's sh.exe). Packaging spans npm, RubyGems, PyPI, PHP, Homebrew, Scoop, AUR, and Linux repositories. Quality signals are strong: extensive unit tests, a large testscript-based integration suite running on Linux/macOS/Windows, a fast release cadence, and use of modern Go (iterators, slices/maps helpers). Maintenance is active: recent commits, triaged issues, zero Dependabot alerts. The main long-term risks are duplicated schema files that must stay in sync, a beta AI integration, and a large bash-heavy packaging matrix; none of these detract from the core engine, which is well-abstracted and contains genuinely reusable components.

RATING9.3/10
QUALITY8.4/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS167
VELOCITY0.91
OPEN ISSUES86
CLOSED ISSUES468
LAST COMMIT2 days ago
al.essio.dev/pkg/shellescape (go) v1.6.1
charm.land/lipgloss/v2 (go) v2.0.6
github.com/bmatcuk/doublestar/v4 (go) v4.10.2
github.com/briandowns/spinner (go) v1.23.2
github.com/charmbracelet/colorprofile (go) v0.4.3
github.com/charmbracelet/x/term (go) v0.2.2
github.com/creack/pty (go) v1.1.24
github.com/gabriel-vasile/mimetype (go) v1.4.15
github.com/go-viper/mapstructure/v2 (go) v2.4.0
github.com/gobwas/glob (go) v0.2.3
github.com/goccy/go-yaml (go) v1.19.2
github.com/google/go-cmp (go) v0.6.0
github.com/invopop/jsonschema (go) v0.14.0
github.com/kaptinlin/jsonschema (go) v0.9.10
github.com/knadh/koanf/maps (go) v0.1.3
github.com/knadh/koanf/parsers/json (go) v1.0.1
github.com/knadh/koanf/parsers/toml/v2 (go) v2.2.2
github.com/knadh/koanf/parsers/yaml (go) v1.1.1
github.com/knadh/koanf/providers/fs (go) v1.0.1
github.com/knadh/koanf/providers/rawbytes (go) v1.0.1
github.com/knadh/koanf/v2 (go) v2.3.7
github.com/mattn/go-isatty (go) v0.0.24
github.com/mattn/go-runewidth (go) v0.0.30
github.com/mattn/go-tty (go) v0.0.8
github.com/pelletier/go-toml/v2 (go) v2.4.3
github.com/rogpeppe/go-internal (go) v1.16.0
github.com/schollz/progressbar/v3 (go) v3.19.1
github.com/spf13/afero (go) v1.15.0
github.com/stretchr/testify (go) v1.12.1
github.com/tidwall/jsonc (go) v0.3.3
github.com/urfave/cli/v3 (go) v3.14.0
go.yaml.in/yaml/v3 (go) v3.0.5
golang.org/x/mod (go) v0.41.0
github.com/bahlo/generic-list-go (go) v0.2.0
github.com/buger/jsonparser (go) v1.1.2
github.com/charmbracelet/ultraviolet (go) v0.0.0-20260811164956-006e29f97886
github.com/charmbracelet/x/ansi (go) v0.11.8
github.com/charmbracelet/x/termios (go) v0.1.1
github.com/charmbracelet/x/windows (go) v0.2.2
github.com/clipperhouse/displaywidth (go) v0.11.0
github.com/clipperhouse/uax29/v2 (go) v2.7.0
github.com/fatih/color (go) v1.18.0
github.com/kaptinlin/jsonpointer (go) v0.4.28
github.com/lucasb-eyer/go-colorful (go) v1.4.1
github.com/mattn/go-colorable (go) v0.1.13
github.com/mitchellh/colorstring (go) v0.0.0-20190213212951-d06e56a500db
github.com/mitchellh/copystructure (go) v1.2.0
github.com/mitchellh/reflectwalk (go) v1.0.2
github.com/muesli/cancelreader (go) v0.2.2
github.com/pb33f/ordered-map/v2 (go) v2.3.1
github.com/rivo/uniseg (go) v0.4.7
github.com/xo/terminfo (go) v0.0.0-20220910002029-abceb7e1c41e
github.com/yosida95/uritemplate/v3 (go) v3.0.2
go.yaml.in/yaml/v4 (go) v4.0.0-rc.2
golang.org/x/net (go) v0.59.0
golang.org/x/sync (go) v0.23.0
golang.org/x/sys (go) v0.48.0
golang.org/x/term (go) v0.46.0
golang.org/x/text (go) v0.42.0
golang.org/x/tools (go) v0.51.0
Files by Type (count)
Go
176
Markdown
121
Text
63
YAML
17
JSON
17
Other (no ext)
14
JavaScript
10
Shell
8
TOML
4
Other (.svg)
3
Python
3
Git Ignore
2
Files by Type (size)
Go
457KB
Markdown
184KB
JSON
43KB
Other (.png)
37KB
Text
36KB
YAML
26KB
JavaScript
21KB
Shell
11KB
Other (.sum)
11KB
Other (no ext)
8KB
Other (.svg)
6KB
Python
5KB

The LLM identified 6 files worth highlighting for reuse:

Composable git CLI wrapper that serializes git operations with a mutex, batches arguments to respect maximum command-line length limits, caches paths, and supports worktree-aware execution. Self-contained and directly reusable in any Go project needing robust, safe git subprocess invocation.

file: internal/git/wrapper/wrapper.go ↗ | tags: #git-wrapper #command-batching #process-isolation

Implements placeholder expansion ({staged_files}, {push_files}, {all_files}, custom file sets) in hook command templates. Isolated, well-tested, and extractable to any CLI that needs to substitute file-set placeholders into command strings before execution.

file: internal/run/controller/command/replacer/replacer.go ↗ | tags: #template-substitution #string-replacement

Filters a file list by glob/exclude patterns, root path, and file characteristics (text/binary via MIME detection, executable, symlink). Solves the recurring 'only run on files that matter' problem and can be reused with minimal adaptation in other lint/format/CI tooling.

file: internal/run/controller/filter/filter.go ↗ | tags: #file-filtering #glob-matching #mime-type-detection

Abstracts OS command execution behind a Command interface: environment isolation, platform-specific shell resolution (Unix sh -c; Windows locates sh.exe from a Git install), a null reader, and process limits. Extractable as a small standalone cross-platform process-execution library.

file: internal/system/ ↗ | tags: #cross-platform #process-execution #shell-abstraction

Downloads new releases and verifies SHA-256 checksums before replacing the running binary. A self-contained, safe self-update pattern applicable to any CLI distributed via GitHub releases.

file: internal/updater/updater.go ↗ | tags: #self-update #checksum-verification #release-management

The embedded shell template every Git hook executes. It locates the lefthook binary across npm, Go toolchain, Ruby gems, Python, Swift, Composer, mise, and devbox environments via a robust fallback chain before invoking the CLI. Demonstrates a non-obvious pattern for cross-ecosystem binary discovery that is directly transplantable.

file: internal/templates/hook.tmpl ↗ | tags: #shell-template #binary-discovery #multi-package-manager
Last analyzed: 2026-10-16 05:21:59.172289
Next check: 2026-10-23 05:21:59.169646
$ submit: