Matt Pocock's pre-commit hook caps agent-written files at 5,000 tokens
mattpocockuk · x · 2026-10-18
TypeScript educator Matt Pocock shares what he calls the simplest investment he ever made in his codebase: a pre-commit hook that blocks any file over 5,000 tokens (estimated as bytes/4).
Key details:
- Runs only on staged files
- Ignores files not authored by agents, such as lockfiles or codegen output
- The error message includes explicit instructions on how to split the file
The goal is to keep AI coding agents from bloating files unchecked, catching oversized output automatically before commit.
More from coding & agent
- Agently demos macOS agent that runs email, invoicing and CRM workflows from one command — Scobleizer · 2026-10-18
- Author and reviewer were both agents — they went 50 rounds arguing — wateriscoding · 2026-10-18
- When Should a Research Agent Stop Searching? A Founder's Three-Part Stopping Rule — Pitiful-Minute-2818 · 2026-10-18
- Teach Your Coding Agent to Prove It's Done: WorkOS on Verification Loops, CLI Checks and LLM Judges — AI Engineer · 2026-10-18
- Claude-written test harness let 31KB fake archives land on a real backup server — Grimmoner · 2026-10-18
- Backups silently failed for 10 days: three monitoring blind spots lined up — Grimmoner · 2026-10-18