Ratchet is an MIT-licensed command-line tool that reads the rules in your CLAUDE.md, AGENTS.md and SKILL.md files and installs hooks, so Claude Code and eight other coding agents are stopped before they run a forbidden command, with no model call involved (README). Version 0.1.1 is dated November 29, 2026 in its changelog. This is what the author reports, plus the commands from the project’s docs.
Applies to: Ratchet 0.1.1 (README, guide and changelog read on November 30, 2026); Claude Code hooks docs read on November 30, 2026. Last checked: November 30, 2026.
On this page
The problem it targets
A line such as “Always use pnpm” in CLAUDE.md is advice: the model can read it and still run npm install. The README’s answer is to turn the sentences that can be checked into rules a program evaluates, and to leave the rest as prose. ratchet lint reports which sentences are enforceable and which are judgment calls, and the README says no LLM takes part in enforcement (README).
A rule is a fenced rule block placed under the sentence it comes from. This is the README’s example:
## 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 guide lists four kinds of rule by the when: key:
when: | Checked | Main keys |
|---|---|---|
run | Before a shell command runs | deny:, pattern:, use: |
write | Before a file is written | deny: with path globs |
commit (or diff) | On added lines, when the agent finishes and in CI | pattern:, in:, except: |
finish | When the agent finishes | require: (a test command), after: |
A rule set to warn or enforce needs at least one ok: and one bad: example, which ratchet test and ratchet lint check against the rule.
Install and set up
The README gives three ways to install. The first downloads a prebuilt binary and verifies its SHA-256, the others build from source with Rust 1.82 or newer:
curl -fsSL https://raw.githubusercontent.com/itsthecsguy/ratchet/main/scripts/install.sh | sh
cargo install --git https://github.com/itsthecsguy/ratchet --locked ratchet-cli
Warning
The first command pipes a script from the internet into
sh. The same README offers thecargo install --gitroute, and you can openscripts/install.shin the repository before running either. Ratchet is at version 0.1.x, and its SECURITY.md says only the latest release receives security fixes. The tool then sits in the path of every command your agent runs, so read the code you are trusting first.
Then run the checks from the project root:
ratchet lint
ratchet setup
ratchet try "npm install lodash"
According to the README, lint reports unchecked claims, stale paths, broken links and contradictions. setup detects your guidance files and agents, shows how many rules it would install, and asks whether to use enforce, warn or shadow. try dry-runs a command against the loaded rules without executing it, and the README shows it answering deny with a fix: command for npm install lodash in a pnpm repository. Add --level warn or --level shadow to setup for a rollout that does not block anything. The README says setup --git-hook --ci also wires a pre-commit hook and a GitHub Actions workflow.
How it hooks into Claude Code
For Claude Code, the README’s table says Ratchet writes its hook into .claude/settings.local.json, supports deny and warn on PreToolUse, handles PostToolUse, and can block at Stop. Anthropic’s hooks reference describes the mechanism it builds on: a PreToolUse hook receives the tool call as JSON and can return a permissionDecision of allow, deny, ask or defer, and when several hooks disagree the precedence is deny, then defer, then ask, then allow. A hook that exits with code 2 is treated like a denial, and Claude sees its stderr as the reason. The same page lists .claude/settings.local.json as the single-project settings file that is not meant to be committed.
Ratchet’s four levels map onto that, as the README describes them:
| Level | What happens |
|---|---|
enforce (default) | The tool call is blocked and the agent gets a reason with a concrete fix: command |
ask | A native confirmation prompt on Claude Code and Cursor; other agents fall back to deny plus ratchet approve |
warn | A visible warning, nothing blocked |
shadow | Hits are logged silently so you can measure before enforcing |
The README says hedged sentences such as “prefer pnpm” are capped at warn. To let one blocked command through once, it offers ratchet approve, and ratchet off or the environment variable RATCHET=0 pauses the hooks. The guide says an internal error, malformed input or a watchdog overrun exits 0 with no output, so a fault in Ratchet lets the command through rather than blocking your session, and three internal errors in a session trip a circuit breaker. The guide gives a median of 1.79 ms for an allowed call on Claude Code, measured by the author on Linux. These figures have not been reproduced here.
For how Claude Code’s own permission rules and hooks fit together, see Claude Code permissions and Claude Code hooks.
What ratchet lint checks
The guide’s diagnostics table names these codes. The errors E001 to E005 cover rule parsing, duplicate ids, examples a rule misses or wrongly catches, and conflicts between rules. The warnings that touch ordinary guidance files are:
| Code | What it reports |
|---|---|
W102 | A normative sentence (“never”, “always”, “must”) not covered by a rule |
W103 | A backticked path, package.json script or Makefile target that does not exist |
W105 | A markdown link or @file include pointing to a missing file |
W106 | Contradictions across files or lockfiles, for example npm against pnpm or ruff against flake8 |
W107 | An exact duplicate instruction paragraph, with an estimate of always-loaded tokens |
The guide says lint scans CLAUDE.md, AGENTS.md, GEMINI.md, .claude/rules/, Cursor and Windsurf rule files, .github/copilot-instructions.md and every SKILL.md it finds. If you are deciding where such rules belong in the first place, see CLAUDE.md best practices and CLAUDE.md vs AGENTS.md.
Nine agents, one rule set
The README lists the hook file Ratchet writes for each agent it supports:
| Agent | Hook or plugin file |
|---|---|
| Claude Code | .claude/settings.local.json |
| Codex CLI | .codex/hooks.json |
| Cursor | .cursor/hooks.json |
| Gemini CLI | .gemini/settings.json |
| GitHub Copilot CLI | .github/hooks/ratchet.json |
| Antigravity | .agents/hooks.json |
| OpenCode | .opencode/plugins/ratchet.ts |
| Windsurf | .windsurf/hooks.json |
| Amp | .amp/plugins/ratchet.ts |
Per the README, hook files Ratchet creates are excluded locally in .git/info/exclude and removed by ratchet uninstall. The guide adds that for Codex CLI you approve repository hooks through /hooks on first run. For the Codex side of hooks, see Codex hooks.
What it does not cover
The guide’s limits section says AST rules and command-backed checks are parsed and skipped, and that native Windows support, pre-push hooks and importers from other linter configs are not built. It also says OpenCode and Windsurf enforce before and after tool calls but check finish and commit rules only through ratchet check and CI, because neither exposes a synchronous stop-blocking hook yet. A rule only sees what the agent does through a hooked tool call, so it complements, and does not replace, the permission rules and sandbox of the agent itself.





