Repo Pattern Guard
A pre-commit + CI tool that flags bad coding patterns before they become permanent training context for your coding agent.
Difficulty: weekend | Stack: Python, GitPython, Claude API (claude-haiku-4), pre-commit framework, GitHub Actions
Who this is for
Any developer using AI coding agents (Copilot, Cursor, Devin) on a shared repo — stops AI-introduced antipatterns from compounding across future AI-generated changes
Build steps
- Write a git diff parser that extracts only AI-attributed hunks (look for co-authored-by: GitHub Copilot or similar signals in commit messages)
- Send each hunk to claude-haiku with a system prompt defining your team’s antipattern list (e.g., missing error handling, hardcoded secrets, N+1 queries) and receive a structured JSON verdict
- Build a pre-commit hook that blocks commits scoring above a configurable risk threshold, printing a plain-English explanation of the detected pattern
- Add a GitHub Actions workflow that runs the same check on PRs and posts inline review comments with suggested rewrites
- Store flagged patterns in a local SQLite log so you can review which antipatterns your coding agent keeps reintroducing over time
Risks
- Haiku may produce too many false positives on legitimate patterns — requires careful prompt engineering and a project-specific allowlist
- Git blame heuristics for ‘AI-authored’ code are brittle; teams not using standardized commit trailers will need a different attribution strategy
- Pre-commit hooks that call external APIs add latency and will fail in offline or rate-limited environments, frustrating developers