A repository can tell a coding agent to use pnpm, leave production configuration alone and run tests before finishing. Those instructions are useful context, but the shell doesn’t enforce them. An agent that misses a line can still run npm install and leave a second lockfile behind.
Ratchet offers a concrete way to handle rules like that: put a machine-checkable rule next to the instruction, then check the agent’s tool call before it runs. Its repository was created on November 28. This is a look at the documented design, not an independent test of the tool.
Turn a sentence into a decision
Ratchet’s README shows a rule embedded in a Markdown instruction file:
## pnpm-only
Always use pnpm. Never use npm, npx or yarn.
```rule
when: run
level: enforce
deny: npm *, npx *, yarn *
use: npx => pnpm dlx {{args}}
say: This repo uses pnpm; {{program}} would write a second lockfile.
ok: pnpm install
bad: npm install
```
The prose tells the agent why the convention exists. The rule gives the hook a decision to make when it sees a command. The examples also give the project something to check: pnpm install should be allowed and npm install should not.
According to the README, ratchet setup compiles rules and connects to supported agents’ lifecycle hooks. At a pre-tool hook, Ratchet examines the proposed action and can return a denial with a suggested correction. ratchet try "npm install lodash" checks a command without executing it. There are also shadow and warning levels, which make sense for a first rollout: watch what a rule matches before making it block a working workflow.
The same approach applies beyond package managers. The documentation describes rules for selected file reads and writes, tool calls, command checks and test freshness. A small team could start with one repeatable failure, such as writing to a protected configuration path, add allowed and rejected examples, and review the matches before enabling enforcement.
The boundary matters
A hook sees the actions its host sends to it. That is not the same as controlling every possible effect of a process. Ratchet’s README explicitly notes limits to its shell-read inspection: it reads command text and does not follow a wildcard, an earlier cd, an interpreter such as python -c, or a recursive search. A rule that catches cat .env is not proof that the same file cannot be read another way.
That distinction changes where this tool belongs. Use a hook to make common project conventions harder to forget and to give the agent a useful correction. Use operating-system permissions, isolated credentials and network restrictions for boundaries that must hold against alternate paths. Keep CI checks too: a developer, another agent or a process outside the hooked harness can still change the repository.
The maintainer reports low hook latency and describes enforcement as deterministic. Those are project claims; neither means a rule covers every route to the same outcome. Test the commands your own harness actually emits, including an allowed case and a bypass-shaped case, before relying on a new rule.
The practical starting point is one boring rule with an observable result. If the recurring problem is a second lockfile, check the package-manager command and review the diff. Then add another rule only when the failure is specific enough to describe and test.