ratchet-files
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
Install / Use
npx skills add dzhng/skills --skill ratchet-filesInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of ratchet-files
ratchet-files scores 84/100 on our quality scale, 2964th of 4,592 Development & Engineering skills we index.
Its SKILL.md is 5.9 KB long, split into 3 sections with 1 code example: a thorough specification that gives an agent plenty to work with.
With 1,349 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 9 days ago, so ratchet-files is actively maintained.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
ratchet-files compared with similar skills
All 4 of these similar skills score higher than ratchet-files; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| ratchet-files (this skill)by dzhng | 84 | 1.3k | 9d ago | SKILL.md |
| taste-skillby Leonxlnx | 100 | 102.3k | today | CLAUDE.md |
| ai-job-searchby ai-job-search-dev | 100 | 65.4k | 4d ago | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 44.9k | 5d ago | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 33d ago | SKILL.md |
Frequently asked questions
- How do I install ratchet-files?
- Run
npx skills add dzhng/skills --skill ratchet-files. The install tabs above show the steps for each supported agent. - Which AI agents does ratchet-files work with?
- It is written for Zed, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is ratchet-files safe to use?
- It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is ratchet-files still maintained?
- The repository was last updated 9 days ago, so ratchet-files is actively maintained.
Skill content
View source on GitHubname: ratchet-files description: 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.
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:
- Copy the script to a scratch directory outside the repository, run
npm install --prefix <scratch> linguist-languagesthere, and runnode <scratch>/check-file-size.mjs --allfrom the repository root (Node 18.3 or later). The script finds the package beside itself when the repository lacks it. - Ask once, with everything the user is agreeing to: how many files the hook would freeze and which are largest, leaving out generated or vendored ones you will mark below (name those); the budget, 8,000 tokens unless they want another; and which pre-commit runner you will wire it into, including any you would add. In a repository without Node tooling, say the check adds it.
Once they agree, set up everything the check needs:
-
Script. The hook runs a copy committed in the repository, so every clone runs the same check. If this skill folder is committed in the repository, point the hook at its
scripts/check-file-size.mjs; otherwise copy that file to where the repository keeps its tool scripts (scripts/if it has none). The entries below usescripts/check-file-size.mjs; substitute the real path. -
Dependency. Add
linguist-languagesat an exact version as a dev dependency of the repository's rootpackage.json, with the package manager its lockfile names, or npm if there is none. The check needs Node even in a repository written in another language: with nopackage.json, create one at the root holding only"private": trueand what this setup adds, and make sure.gitignorecoversnode_modules/. -
Hook. Run the script on every staged file with
node(orbunwhere the repository already runs its tools with it), appending--max-tokens Nfor a budget other than the default. Add it beside the existing entries of the pre-commit runner the repository already has:| Runner | Where | Entry | |---|---|---| | lint-staged | its config |
"*": "node scripts/check-file-size.mjs"| | lefthook |pre-commit.commands|run: node scripts/check-file-size.mjs {staged_files}| | pre-commit |.pre-commit-config.yaml,repo: local|id: ratchet-files,name: source file size,entry: node scripts/check-file-size.mjs,language: system| | husky or a plain hook | thepre-commitscript |git diff --cached --name-only -z \| xargs -0 node scripts/check-file-size.mjs|With no runner, add husky with lint-staged as dev dependencies, run
npx husky init, replace the whole of.husky/pre-commit(it starts asnpm test) withnpx lint-stagedor the package manager's equivalent, and add the lint-staged entry above. Husky installs the hook on each clone's package install. -
Exclusions. Mark generated and vendored code
linguist-generatedorlinguist-vendoredin.gitattributesinstead of adding skip lists. The script reads the staged.gitattributes, so stage it before rerunning--all. -
Docs. Document the budget, the opt-out pragma, and that a clone needs a package install for the hook, where the repository documents its other hooks; failing that, in a section of its README, creating one if needed.
Commit the setup through the new hook, without --no-verify.
Done when the setup commit passed the hook, and the installed hook refuses
git commit both of a staged new source file over the budget (a .js file
of more than four bytes per token of budget) and of a line added to a file the audit
listed, printing the split rules. Unstage and discard both probes afterwards.
Related Skills
taste-skill
102.3kAgent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages
ai-job-search
65.4kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
44.9kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
