How evilmartians/lefthook works
Lefthook is a Go-based Git hooks manager: developers configure hook jobs, install Git hook scripts, and Git-triggered or manually requested hooks run filtered commands and report results. Configuration supports local and remote files; installation also includes AI-assistant-specific hooks, and self-update is a separate CLI capability. The graph follows the principal CLI-to-hook workflow and key internals. Unsampled subsystem links are omitted unless documented in the README or supported by the source index.
Main entry points: run.go Command handlers · install.go Hook installer · repo.go Git repository · controller.go Job controller
Components 20
CLI and commands
- Lefthook CLI
cmd/run.go - Command handlers
internal/command/run.go - Self updater
internal/updater/updater.go
Hook setup
- Hook installer
internal/command/install.go - AI hook setup
internal/command/install_ai.go - Git hook scripts
internal/templates/templates.go
Configuration
- Config loader
internal/config/loader.go - Hook and job config
internal/config/hook.go
Hook execution
- Hook run entry
internal/run/run.go - Job controller
internal/run/controller/controller.go - File filtering
internal/run/controller/filter/filter.go - Command builder
internal/run/controller/command/build_command.go - Process executor
internal/run/controller/exec/executor.go - Run results
internal/run/result/result.go
Git and system
- Git repository
internal/git/repo.go - Git operations
internal/git/wrapper/cmd.go
Other components
- Developer
- Git client
- GitHub releases
- User commands
Connections 22
- Developer → Lefthook CLI: invokes
- Lefthook CLI → Command handlers: dispatches
cmd/run.go - Command handlers → Config loader: loads config
internal/command/run.go - Command handlers → Git repository: uses repository
internal/command/run.go - Command handlers → Hook run entry: runs hook
internal/command/run.go - Command handlers → Hook installer: installs hooks
- Hook installer → Config loader: reads config
internal/command/install.go - Hook installer → Git repository: uses Git
internal/command/install.go - Hook installer → Git hook scripts: renders scripts
internal/command/install.go - Hook installer → AI hook setup: sets up AI hooks
- Git client → Git hook scripts: triggers hooks
- Config loader → Git repository: loads remote config
internal/config/loader.go - Command handlers → Hook and job config: builds jobs
internal/command/run.go - Hook run entry → Job controller: delegates
internal/run/run.go - Job controller → Process executor: creates executor
internal/run/controller/controller.go - Command builder → File filtering: uses filters
internal/run/controller/command/build_command.go - Job controller → Git repository: uses Git state
internal/run/controller/controller.go - Job controller → Run results: returns results
internal/run/controller/controller.go - Process executor → User commands: runs commands
- Developer → Self updater: requests update
- Self updater → GitHub releases: fetches release
internal/updater/updater.go - Git repository → Git operations: delegates Git
internal/git/repo.go