Skip to content

feat(hook): pre-commit interception of vendor file bloat with auto-tidy #24

Closed

Description

@SmartBrandStrategies

Problem

AI agents write rules and context into vendor config files (CLAUDE.md, .cursorrules, agents.md, GEMINI.md) during normal operation. Even with thin pointers in place, agents treat these files as writable scratchpads. The content accumulates silently because nothing in the commit pipeline catches it.

The pre-commit hook currently gates on TypeScript checks and ADF evidence ceilings, but does not detect or correct vendor file bloat.

Proposed Solution

Extend the pre-commit hook to detect and auto-correct vendor file bloat:

  1. Detect: When a vendor config file is in the git staging area, check if it contains content beyond the thin pointer
  2. Auto-tidy: If bloat is detected, run charter adf tidy on the staged vendor files to extract, classify, and route content to .adf modules
  3. Re-stage: Stage the tidied vendor files (restored to thin pointers) and the modified .adf module files
  4. Continue: The commit proceeds with content in the right place — the agent never knows its writes were redirected

Hook Behavior

[pre-commit] Running TypeScript check...
[pre-commit] Running ADF evidence check...
[pre-commit] Checking vendor config files...
[pre-commit] CLAUDE.md has 8 items beyond thin pointer — auto-tidying...
[pre-commit] Routed: core.adf (5), frontend.adf (3). Pointer restored.
[pre-commit] Re-staged: CLAUDE.md, .ai/core.adf, .ai/frontend.adf

Opt-out

  • --no-tidy flag on charter hook install --pre-commit to skip vendor file interception
  • Respects CHARTER_SKIP_TIDY=1 env var for emergency bypass

Acceptance Criteria

  • Pre-commit hook detects staged vendor files with content beyond thin pointer
  • Auto-runs charter adf tidy on bloated files
  • Re-stages modified files (vendor + .adf modules) so the commit includes the corrections
  • Reports what was moved in pre-commit output
  • Opt-out via install flag and env var
  • No-op when vendor files are clean or not staged
  • Works with both npx charter (consuming repos) and pnpm exec charter (this repo)

Dependencies

Activity

  1. added this to the v0.7.0 milestone on Mar 4, 2026
  2. SmartBrandStrategies commented on Mar 4, 2026

    @SmartBrandStrategies
    ContributorAuthor

    Shipped in da8f197. Pre-commit hook now auto-tidies staged vendor files. Bypass with CHARTER_SKIP_TIDY=1. Both .githooks/pre-commit and charter hook install --pre-commit updated. Next: #26 (doctor bloat detection).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions