Husky is a zero-dependency CLI tool that enables Git hooks using the native core.hooksPath feature introduced in Git 2.9. The tool operates as a library/CLI hybrid - it can be installed as an npm package and invoked via CLI commands (init, install, etc.) or imported programmatically. The architecture is intentionally minimal: bin.js handles CLI entry points, index.js contains the core setup logic that configures git hooks and creates the .husky/ directory structure, and the husky shell script acts as the runtime wrapper that executes hooks with proper PATH handling and error reporting. The tool modifies git configuration (core.hooksPath) to point to .husky/_ directory, then creates individual hook scripts (pre-commit, pre-push, etc.) that delegate to the main husky runner. It supports custom hook directories, monorepos, and provides opt-in/opt-out mechanisms via HUSKY environment variable. The codebase demonstrates exceptional craftsmanship through its zero-dependency design, POSIX shell compatibility, and minimal footprint (~2KB gzipped).
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.
autopep8 is a production-grade Python code formatter that automatically modifies source code to conform to the PEP 8 style guide. It operates as both a CLI tool and a library, using pycodestyle to detect violations and applying targeted fixes for most reported error codes (E1xx, E2xx, E3xx, E4xx, E5xx, E7xx, E9xx, and W6xx). The tool supports incremental formatting, aggressive mode, configuration file inheritance (pyproject.toml, setup.cfg, tox.ini, .pep8, .flake8), and integration with pre-commit hooks and editors like Vim. The entire logic is contained in a single monolithic module (autopep8.py), which includes a complex line-wrapping system for long lines, a reindentation engine, and token-based heuristics. The test suite is exceptionally thorough, with fixture-based regression tests and an 'acid test' framework that validates correctness on arbitrary Python files (including live PyPI packages). While the single-file architecture limits modularity, the internal components are well-factored and demonstrate strong engineering practice.
TruffleHog is a comprehensive, actively maintained secret scanning tool written in Go. It detects exposed credentials, API keys, tokens, and other sensitive information across a wide range of sources including Git repositories, cloud storage (S3, GCS), Docker images, CI/CD systems (Jenkins, Travis CI, CircleCI), and many third-party services. The architecture is modular: a core engine orchestrates scanning from various sources, a large library of over 700 detectors (each implementing a standard interface) identifies secrets using regex patterns and Aho-Corasick pre-filtering, and optional HTTP-based verification confirms whether discovered secrets are still valid. The tool also includes a terminal UI (Bubble Tea), a permissions analyzer for deeper credential assessment, and output formats like JSON, SARIF, and GitHub Actions annotations. External dependencies include cloud SDKs, database drivers, and numerous third-party API clients, but the core scanning logic is self-contained and well-structured.
Yelp/detect-secrets is a production-grade Python library and CLI tool for detecting secrets, API keys, tokens, and other sensitive strings in source code. It operates primarily through a baseline file (`.secrets.baseline`) that records discovered secrets, enabling incremental scanning, pre-commit hook integration, and audit workflows. The tool uses a plugin-driven architecture with over 25 built-in detectors (regex-, entropy-, and keyword-based), plus configurable filters (heuristic, allowlist, word list, gibberish) to reduce false positives. Key operational flows include scanning a codebase to create or update a baseline, running as a pre-commit hook to block new secrets, and an interactive audit mode for labeling secrets as true or false positives. The architecture is modular with clear separation of concerns: plugins define detection logic, filters post-process results, settings manage global configuration, and transformers handle non-standard file formats (YAML, INI). The library also supports network verification for some secret types, automatic baseline upgrades across format versions, and custom plugin/filter injection. It is actively maintained with CI across Python 3.9-3.13 and three operating systems.
The `pre-commit` npm package automatically installs and manages git pre-commit hooks for Node.js projects. When installed as a devDependency, its `install.js` script locates the project's `.git` directory (including submodules and linked worktrees) and writes a shell wrapper into `.git/hooks/pre-commit`. Upon commit, that wrapper executes a crafted bash script (`hook`) that resolves the `pre-commit` package path via Node's `require.resolve` (supporting Yarn Plug'n'Play), then runs `index.js`. The `Hook` class in `index.js` reads the project's `package.json`, normalizes the `pre-commit`/`precommit` configuration into an ordered list of npm scripts, and executes them sequentially using `cross-spawn`. If any script fails with a non-zero exit code, the commit is aborted with a clear error message. The tool gracefully handles missing packages (exits 0 to avoid blocking commits), environment quirks (emacs/magit's `GIT_LITERAL_PATHSPECS`, SourceTree's path issues), and provides backup/restore of existing hooks. This is a single-purpose utility library with a clean Node.js core and a well-tested bash wrapper.
proselint is a linter for English prose that checks style, usage, and common writing errors based on authoritative references like Garner's Modern American Usage. It operates as a Python library with a command-line interface (CLI) and a FastAPI web service. The architecture is a monolith: text input is tokenized and matched against a registry of checks (existence, preferred forms, consistency, etc.) using a pluggable regex engine (RE2 or Python re). Results are output as structured JSON or formatted text. The project also includes editor plugins (Sublime Text, CodeMirror), a pre-commit hook, and a Jekyll-based documentation site. While the core linting logic is well-architected with a clean check type system and configurable thresholds, the repository carries significant technical debt from vendored third-party code (an old CodeMirror distribution) and several unmaintained editor plugins. The codebase is actively maintained with CI/CD across platforms and Python versions, but the outdated dependencies and legacy components introduce medium technical drift.
This repository is a curated collection of Git hook examples, organized by hook type (pre-commit, commit-msg, pre-push, etc.). Each hook type directory contains a README explaining the hook's purpose and one or more example shell scripts that demonstrate how to implement the hook for common tasks such as linting, branch protection, and commit message validation. The repository does not contain a runnable application but serves as a reference for developers looking to implement Git hooks in their projects. The example scripts are self-contained, written in POSIX shell or Bash, and rely only on standard Unix tools and Git commands, making them easy to adapt to various projects. While the hooks are simple, they illustrate practical patterns for enforcing code quality, preventing dangerous operations, and integrating with issue trackers. The repository is maintained with occasional updates, and the examples are relevant to current Git usage. The scripts are designed to be copied directly into a project's .git/hooks directory with minimal modification, often requiring only customization of variables like branch names or regex patterns.