Skip to content

Add logger coverage lint and Claude Code PostToolUse hook#2560

Merged
hiroshinishio merged 1 commit intomainfrom
wes
Apr 20, 2026
Merged

Add logger coverage lint and Claude Code PostToolUse hook#2560
hiroshinishio merged 1 commit intomainfrom
wes

Conversation

@hiroshinishio
Copy link
Copy Markdown
Collaborator

@hiroshinishio hiroshinishio commented Apr 20, 2026

Summary

  • Add scripts/lint/check_logger_coverage.py (AST-based) enforcing CLAUDE.md logger rules: every return/continue/break in a function needs a preceding logger.xxx(...) call, and every if/elif/else branch body starts with one.
  • Wire the check into scripts/git/pre_commit_hook.sh so staged .py files are blocked at commit time, skipping tests/scripts/schemas/venvs.
  • Add a Claude Code PostToolUse hook (Edit|Write|MultiEdit) at .claude/hooks/check-logger-coverage.sh that runs the same check and returns decision:block with violation details so Claude fixes before continuing, not in a later commit.

Social Media Post (GitAuto)

Logger coverage is now enforced automatically

  • New lint script checks that every return/continue/break has a preceding logger call and every if/elif/else branch starts with one
  • Wired into pre-commit so violations block the commit with the exact lines to fix
  • Claude Code now gets the same check as a PostToolUse hook, blocking the agent on any edited file until logs are added

Social Media Post (Wes)

Kept writing "add a logger before that return" in reviews. Moved it into a pre-commit script and a Claude Code PostToolUse hook that blocks the edit right when it happens, with the line numbers in the block reason. Same rule, one place, no more nagging.

@hiroshinishio hiroshinishio self-assigned this Apr 20, 2026
@hiroshinishio hiroshinishio merged commit f13cb3f into main Apr 20, 2026
1 check passed
@hiroshinishio hiroshinishio deleted the wes branch April 20, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant