Git pre-commit hook prevents AI coding agents from committing with stale documentation

✍️ OpenClawRadar📅 Published: March 30, 2026🔗 Source
Git pre-commit hook prevents AI coding agents from committing with stale documentation
Ad

Problem: AI coding agents commit code with outdated documentation

When working with AI coding assistants like Claude Code over multiple sessions, developers encounter a specific issue: the AI makes code changes (adding routes, refactoring components, renaming things) but doesn't update documentation files like ARCHITECTURE.md and README. This causes subsequent sessions to start with the AI reading documentation that describes code from weeks ago.

The consequences include:

  • Claude hallucinating function names that no longer exist
  • Referencing API endpoints that were renamed
  • Suggesting patterns that contradict the current architecture

Advisory warnings don't work because when Claude is committing, nobody sees stderr output.

Ad

Solution: A blocking pre-commit hook

The developer created a Git pre-commit hook with this workflow:

  • The hook knows which file changes should trigger documentation updates (configurable patterns per project)
  • When Claude Code commits, the hook detects it via environment variables
  • The hook skips trying to auto-fix documentation (which would cause a deadlock from spawning Claude from inside Claude)
  • Instead, it exits with code 1 and displays a clear message: "docs are stale, update these files, then retry"
  • Claude reads the error, updates the documentation, retries the commit, and the commit goes through

For human commits, the hook calls the Anthropic API directly and patches the relevant sections (taking approximately 20 seconds).

Every commit generates a session-context.md file with a summary of recent activity so the next session has continuity.

Implementation details

The tool is available as an npm package: @mossrussell/agent-guard

Key characteristics:

📖 Read the full source: r/ClaudeAI

Ad

👀 See Also

Claude Code Architecture Analysis from Leaked Source Maps
Tools

Claude Code Architecture Analysis from Leaked Source Maps

Analysis of Claude Code's 512,000-line TypeScript codebase reveals a Bun-based runtime with React/Ink CLI, 100+ commands, 38+ tools, and multi-agent coordination. The system uses Zod for validation, OpenTelemetry for telemetry, and includes context compression mechanisms.

OpenClawRadar
Commitment Issues: A Tool That Analyzes and 'Buries' Unfinished GitHub Repos
Tools

Commitment Issues: A Tool That Analyzes and 'Buries' Unfinished GitHub Repos

A developer built a tool called Commitment Issues that analyzes GitHub repositories to determine if they're abandoned, generates a 'death certificate,' and extracts the final commit message as 'last words.' The tool uses heuristics like commit frequency, last activity, and stars vs momentum, and was prototyped using Claude.

OpenClawRadar
Claude Code plugin analyzes any plugin and generates interactive wiki reports
Tools

Claude Code plugin analyzes any plugin and generates interactive wiki reports

A new Claude Code plugin called vision-powers analyzes any plugin path or GitHub URL and generates an interactive HTML wiki report with architecture diagrams, security audits, and skill breakdowns. Installation is via claude plugin add vision-powers@claude-code-zero.

OpenClawRadar
Brain-MCP Developer Documents Tools for Claude AI Instead of Humans
Tools

Brain-MCP Developer Documents Tools for Claude AI Instead of Humans

A developer maintaining the Brain-MCP server added a 'For AI Assistants' section to documentation with behavioral instructions, resulting in Claude using tools more intelligently and proactively injecting context when topics change.

OpenClawRadar