Prompt of the Day: A Pre-Commit Hook to Limit AI-Generated File Size
Prompt of the Day: A Pre-Commit Hook to Limit AI-Generated File Size
GotBurnout shares a simple Git hook that blocks commits when staged files exceed 5,000 tokens and prompts developers to split large files.
Prompt of the Day: A Pre-Commit Hook to Limit AI-Generated File Size
Create a pre-commit hook that prevents committing files larger than 5,000 tokens. Calculate token count using the formula: 1 token = 4 bytes.
Check only files added to the Git index (staged files). Ignore files not written by agents, such as lock files and automatically generated code.
If the limit is exceeded, output an error message with concrete instructions for splitting the file into multiple parts.
This is one of the simplest additions you can make to your codebase and a very useful guardrail.
Why it matters
AnalysisThe hook keeps AI-assisted codebases reviewable by preventing oversized generated files and encouraging modular, maintainable code.
Discuss in community
Share your questions and insights with developers