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

Local dashboard tracks Claude Code usage with token costs, tool calls, and session analytics
Tools

Local dashboard tracks Claude Code usage with token costs, tool calls, and session analytics

A developer built a local dashboard that reads Claude Code's JSONL session files to visualize token usage, estimated costs, tool call breakdowns, and session history. The tool runs entirely on your machine with an Express API and React dashboard.

OpenClawRadar
AutoClaw Local Runner Review: Easy Setup, Credit Costs, and Uninstall Issues
Tools

AutoClaw Local Runner Review: Easy Setup, Credit Costs, and Uninstall Issues

A user tested AutoClaw, a local runner for OpenClaw/AutoGLM from Zai_org, finding the setup smooth but encountering high credit consumption, task failures, and concerning persistence after uninstallation including registry entries and plaintext credentials.

OpenClawRadar
Drop-in OAuth Provider for Personal FastMCP Servers on All Claude Platforms
Tools

Drop-in OAuth Provider for Personal FastMCP Servers on All Claude Platforms

A developer created a single-file Python OAuth provider that enables personal FastMCP servers to work on Claude.ai web, mobile, and Desktop platforms without requiring external identity services like Auth0 or Google.

OpenClawRadar
Keyoku Plugin Replaces OpenClaw's Static Heartbeat with Memory-Driven Autonomy
Tools

Keyoku Plugin Replaces OpenClaw's Static Heartbeat with Memory-Driven Autonomy

Keyoku is a free OpenClaw plugin that changes the agent's heartbeat from reading a static HEARTBEAT.md file to scanning the agent's actual memory store for stalled work, dropped commitments, conflicting information, and quiet relationships. It uses a local Go engine with SQLite + HNSW and offers three autonomy levels: observe, suggest, and act.

OpenClawRadar