agentleFS
dzhngdzhng/jevgrep/.agents/skills/ratchet-files/SKILL.md

ratchet-files

Skill2.9k starsChanged 10 days agoMITView on GitHub

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.

  • Installs packages

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run the script with --all from the repository root, passing the repository's --max-tokens if its hook sets one.

    line 16
  2. Distinctive:

    Never install the hook without the user's explicit yes, even when they asked to set up the repository.

    line 46
  3. Distinctive:

    Ask once, with everything the user is agreeing to: how many files the hook would freeze and which are largest, leaving out generated or …

    line 55
  4. Very specific:

    Dependency: Add linguist-languages at an exact version as a dev dependency of the repository's root package.json, with the package manager …

    line 70
  5. Very specific:

    Hook: Run the script on every staged file with node (or bun where the repository already runs its tools with it), appending --max-tokens N …

    line 76
  6. Distinctive:

    Docs: Document the budget, the opt-out pragma, and that a clone needs a package install for the hook, where the repository documents its …

    line 97
  7. Very specific:

    Commit the setup through the new hook, without --no-verify.

    line 101

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Run the script with --all from the repository root, passing the repository's --max-tokens if its hook sets one. Its list is the backlog.
  2. 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.
  3. 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.
  4. 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:

  1. Copy the script to a scratch directory outside the repository, run npm install --prefix <scratch> linguist-languages there, and run node <scratch>/check-file-size.mjs --all from the repository root (Node 18.3 or later). The script finds the package beside itself when the repository lacks it.
  2. 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 use scripts/check-file-size.mjs; substitute the real path.
  • Dependency. Add linguist-languages at an exact version as a dev dependency of the repository's root package.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 no package.json, create one at the root holding only "private": true and what this setup adds, and make sure .gitignore covers node_modules/.
  • Hook. Run the script on every staged file with node (or bun where the repository already runs its tools with it), appending --max-tokens N for a budget other than the default. Add it beside the existing entries of the pre-commit runner the repository already has:

    RunnerWhereEntry
    lint-stagedits config"*": "node scripts/check-file-size.mjs"
    lefthookpre-commit.commandsrun: node scripts/check-file-size.mjs {staged_files}
    pre-commit.pre-commit-config.yaml, repo: localid: ratchet-files, name: source file size, entry: node scripts/check-file-size.mjs, language: system
    husky or a plain hookthe pre-commit scriptgit 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 as npm test) with npx lint-staged or 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-generated or linguist-vendored in .gitattributes instead 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.

Download now (ZIP)

Trending

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Aug 30: 0 new projectsWeek of Sep 6: 0 new projectsWeek of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projects
Aug 2026Sep 2026Oct 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about dzhng/jevgrep

The biggest 5 of 45 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 45

Talked about on YouTube, GitHub, the web, Bluesky and Hacker News (45 times).

On YouTube · 21

16 more on YouTube

On GitHub · 13

8 more on GitHub

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.