
Ratchet Files
Ratchet source file size so every file stays small enough for an agent to read whole...
Install
npx skills add dzhng/skills --skill ratchet-files -g -a claude-code -y- Repository
- dzhng/skills1.4k
- Category
- AI and agents
- Updated
- 3d ago
- License
- MIT
- Context cost
- Mediumabout 1,883 tokens
- Runs scripts
- Yes, review before use
What it does
Ratchet source file size so every file stays small enough for an agent to read whole: find every file over a token budget, split oversized files by concept, and set up the pre-commit ratchet that stops them from growing. Use when a commit is blocked because a file is over the size budget, when asked to find or split oversized/long/god files, when a file you need to change is too large to read in one pass, or when asked to add a file-size limit or hook to a repository or repair commit-hook coverage across worktrees.
Ratchet Files
A source file is over budget when it is past what an agent can read in one
pass (8,000 tokens, counted as bytes / 4, unless the repository sets
another). scripts/check-file-size.mjs owns
what counts as source, the budget, the ratchet, and the split rules; run it
with --help before anything else.
Splitting
- Run the script with
--allfrom the repository root, passing the repository's--max-tokensif its hook sets one. Its list is the backlog. - Pick the files to split: the one blocking the work in front of you, or with no blocker, the largest ones a change is about to touch.
- Split each one by the rules the script prints. A seam is a concept the file already owns, not a line count; when refactor-clean is installed, use it to find them.
- Prove the split changed no behaviour with the repository's own checks, and commit it alone, before the change that needed the room.
A file whose every split would cost more than it saves (one table or state
machine that only reads whole) may opt out instead. Put
@ratchet-files-ignore in a comment within its first 10 lines, in the
file's own comment syntax, followed by why splitting fails:
// @ratchet-files-ignore: one opcode table; split, each half reads without the other.
The check then skips the file entirely, even as it grows, so opt out only
after looking for a seam and finding none worth its cost, never to get past a
refusal. Tell the user each file you opt out and why. --all counts
opted-out files so they stay visible.
Done when every file you picked is under budget in its own commit, the
behaviour checks pass, and --all no longer lists those files.
Setting up the ratchet
Never install the hook without the user's explicit yes, even when they asked to set up the repository. Installing it freezes every file already over budget, so audit first and leave the repository untouched while you do:

