ratchet
A code-size budget for your repo that only goes down.
A real run on pallets/click; the bloated change is a scripted patch standing in for an agent. Full commands and output: docs/examples.md.
Why
Coding agents are good at adding code and bad at deciding not to. Ratchet gives the repo a line budget that can only shrink. When a change would go over it, the agent is refused in plain words: it trims the code, or stops and asks you, since only a human can raise the budget.
Quickstart
Remove it any time: uninstall.
- Install:
pip install ratchet-size(orpipx install ratchet-size) - Baseline: run
ratchet initanywhere in the repo, and commit the.ratchet.jsonit writes. - Wire up your agent: tell it: "Set up ratchet in /path/to/repo by following https://raw.githubusercontent.com/krishansubudhi/ratchet/main/SETUP-FOR-AGENTS.md"
A real Gemini CLI run after step 3, sped up: refused, it asks for a grant instead of cutting code, declines "commit it", and commits once granted (cast).
Only code files count, split into source and tests groups; docs never
do. Your own commits are not blocked.
Strict mode (optional): to block your own commits too, install the git pre-commit hook.
What a refusal looks like
A real headless Claude Code run, replayed: the commit is blocked by 1 line, the agent stops and asks instead of cutting code, and commits once a human grants it (docs/agent-demo.sh).
ratchet: refused -- source grew 56 lines past its limit (556 / 500)
app/api.py +40
app/store.py +16
Fix it one of two ways:
1. remove 56 lines of code (dead code, duplicates), or
2. stop and ask a human to allow the growth (humans only -- never run this yourself):
ratchet grant +56 --group source --reason "why"
Do not edit .ratchet.json or .ratchet-grants.jsonl to get past this.
Refused again on the same change? Stop here: report these numbers to a human instead of cutting more and resubmitting.
Humans see the same facts with "allow the growth" instead of "ask a human". Other wordings: How it works.
More
- How it works / FAQ: what counts, the four rules,
ratchet budget, grants, refusal wording, exit codes, requirements - Configuration:
.ratchet.json, groups, slack - Integrations: Claude Code plugin, Cursor, Codex, aider, pre-commit, GitHub Actions, strict mode, CI
- Uninstall
License
Apache-2.0. Copyright 2026 Krishan Subudhi.
Metadata
Release files for ratchet-size 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ratchet_size-0.2.3.tar.gz | 23.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ratchet_size-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.3 kB
Release files / ratchet_size-0.2.3.tar.gz
| Download URL | ratchet_size-0.2.3.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
632ceaa0326a9b695cd28b5107ca12a5380a1e7df0d99c4567d7b14e6196e7e6
|
|
BLAKE2b-256 checksum How to use checksums |
93d698f16de9250f4ae15ba6c4a2417d833bcabd289def86fc001c6fb2277c09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / ratchet_size-0.2.3-py3-none-any.whl
| Download URL | ratchet_size-0.2.3-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dbf4c35de40e66723e457b6f38377fed137c27e0e50d5b4dbe62b2e54f6d7450
|
|
BLAKE2b-256 checksum How to use checksums |
3186760a42e8082471d68d670f063b67080ff1deb45b35a8e0f79279cfd5b1d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency log