Skip to content

enerrio/pre-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pre-Commit Demo

This repo is a companion piece to the blog post Why Pre-Commit Hooks Are Essential (Even If You Hate Them At First) on bearblog.

What's this project about?

A minimal Python project that demonstrates pre-commit hooks, including a custom hook that uses an LLM to review your changes.

Setup

This project uses uv for dependency management.

# Sync dependencies
uv sync

# Install pre-commit hooks (anthropic library will be auto-installed by pre-commit)
uv run pre-commit install

Custom hook: llm-check

A custom pre-commit hook that calls an LLM to look at your staged changes and give a pass/fail score. Lives in hooks/llm_check.py.

Set your API key to enable it:

export ANTHROPIC_API_KEY="your-key-here"

If the key is not set the hook will skip gracefully.

Config highlights

The .pre-commit-config.yaml demonstrates several useful patterns:

  • exclude on end-of-file-fixer - the fixed-width data file in data/ must not have a trailing newline added
  • args on mixed-line-ending - passes --fix=lf to enforce Unix-style line endings
  • repo: local - defines the llm-check hook as a local script rather than pulling from a remote repo

About

Companion piece to "Why Pre-Commit Hooks Are Essential (Even If You Hate Them At First)" blog post

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages