Skip to content
View original post on X: DavidX· 38/100AI score38/100

Ratchet files: a skill that shrinks oversized files gradually instead of rejecting commits

AISummary

The author built a skill called ratchet-files, an extension of Matt Pocock's pre-commit idea that blocks files over 5,000 tokens, where tokens are bytes divided by four. Instead of hard rejection, the skill prompts the agent to shrink each offending file a little with every commit until it falls under the limit, so the limit can be added to any repo without forcing a large refactor.

Post on XView on X
DavidVerified on X
@dzhng

Ok I loved this so much, that I made a skill for it:
https://github.com/dzhng/skills/tree/main/skills/engineering/ratchet-files

My take: instead of a hard rejection, it actually ratchets, meaning that it'll prompt the agent to make any offending files smaller with every commit, until it's below the size limit

This way you can add to any repo without suddenly forcing a huge refactor

Matt Pocock@mattpocockuk
Prompt of the day: Create a pre-commit hook that prevents files over 5,000 tokens. Tokens = bytes/4. Run only on staged files. Ignore files which are not authored by agents, like lockfiles or codegen. Provide explicit instructions on how to split files in the error message. The simplest investment I ever made in my codebase. So good.
View quoted post on X

Source: David · x.comPublished · added here