itsthecsguy/ratchet
A local Rust CLI that lints agent guidance and enforces rules at tool-call time
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Tracked from daily D1 telemetry snapshots. Hover any data point for exact daily star counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Ratchet is a Rust 2021 workspace that ships one ratchet binary. It runs a short-lived process per hook event rather than a daemon. Typed rule blocks in CLAUDE.md, AGENTS.md, and SKILL.md, plus optional .ratchet/checks.yaml, turn repository guidance into checkable policy. ratchet-syntax/src/skill.rs defines the block grammar, ratchet-core/src/skill.rs defines its types, and ratchet-cli/src/lint.rs implements linting. The workspace separates shell handling, I/O, hook integration, and optional model testing into distinct crates. It uses Serde and enables key-order preservation in serde_json when rewriting settings.
ratchet setup installs rules and wires the harness’s native lifecycle hooks. At a supported pre-tool event, the harness passes JSON to Ratchet and waits while it parses or normalizes the action and matches it against policy. A deny response can carry a rule ID, the original guidance, and a corrective fix:. Post-tool and session-end events cover checks that need execution results or test-freshness state. MCP calls are actions Ratchet can govern through a supported adapter, not a reason to deploy an MCP server.
Key Capabilities & Differentiators
ratchet lint distinguishes deterministic checks from rules that require judgment. It detects malformed frontmatter, dead globs, unchecked claims, stale references, broken links, and contradictions across files or lockfiles. ratchet try previews a decision without executing the action, and ratchet test exercises inline ok: and bad: fixtures. Runtime rules cover shell commands, supported file reads and writes, pre-write content scans, MCP and generic tool calls, diff or command checks, and test freshness. Reference timings are roughly 36 ms for linting a 35,000-file repository and 1.8 ms for a hook call, not deployment guarantees.
Adapters cover Claude Code, Antigravity, Codex CLI, Cursor, Gemini CLI, Amp, GitHub Copilot CLI, OpenCode, and Windsurf. Capabilities vary: Codex’s listed pre-tool coverage is Bash and apply_patch, while OpenCode and Windsurf rely on ratchet check and CI for finish or commit rules. Claude Code and Cursor support native interactive ask prompts; binary allow/deny integrations fall back to denial and one-time approval. Optional ratchet test --models runs real agent CLIs, and .ratchet/models.yaml supports custom runners.
Trade-offs & Limitations
Compared with prose-only guidance, Ratchet gives concrete requirements a repeatable decision point. Compared with an ordinary CI linter, it can intervene before a supported tool action rather than waiting for a commit or merge. Its strongest fit is shared repository policy across several agent clients: a package-manager rule can live alongside the guidance, carry positive and negative fixtures, and return a targeted correction. For a team on one client with only coarse permission needs, native controls may be simpler than maintaining a second rule layer. Reviews of style and design intent still belong in prose or model evaluations.
Treat hook policy as a workflow safeguard, not a sandbox. Coverage depends on the events each harness exposes and what the parser can infer from submitted command text. Protected-read checks do not follow shell wildcard expansion, an earlier cd, interpreter code, or recursive discovery. on_opaque: ask|deny and fail_closed: true can make selected rules stricter, but may interrupt legitimate workflows without adding visibility into unobserved actions. Use native permissions or isolation for hard security boundaries, and CI for repository-wide gates.
Hardware & Deployment Guide
Prebuilt binaries are available for Linux and macOS on x86-64 and arm64; the installer verifies SHA-256 checksums. Source installation uses Rust 1.82 or later, either through cargo install --git https://github.com/itsthecsguy/ratchet --locked ratchet-cli or cargo install --path crates/ratchet-cli from a checkout. Linting and enforcement run offline without a daemon, model API key, or GPU. The target harness provides the tool events; optional model tests require the chosen agent CLI and whatever credentials or environment that CLI needs.
Start with ratchet lint, then use ratchet setup --level shadow or --level warn to evaluate rules without blocking work. Setup otherwise enforces by default. Exercise representative actions with ratchet try and fixture tests before promoting rules. Teams can add Git pre-commit and GitHub Actions through --git-hook --ci and run ratchet check --ci in automation. After v0.1.0 and v0.1.1, v0.1.2 added opt-in user-wide guidance rules, .agent/ scanning, and lint --root, and narrowed W103 behavior at cd boundaries.
.ratchet/checks.yaml keep machine-enforced rules alongside agent guidance.E006 flags malformed frontmatter, W108 finds dead globs, and W103 catches stale repository references.shadow, warn, ask, and enforce separate observation from blocking; ratchet approve offers a one-time exception.ok: and bad: fixtures test rules deterministically; ratchet test --models measures behavior with real agent CLIs.ratchet check --staged targets staged changes, while ratchet ci init sets up GitHub Actions verification.Teams using multiple coding-agent clients that want shared, testable guardrails for package managers, sensitive paths, and required test runs, with feedback before a supported tool action executes.
You need a security sandbox, uniform interception of every action across clients, or automated judgment of subjective guidance. If native permissions and CI already cover your requirements, another hook layer may not pay off.
Quick Start & Installation
# Prebuilt release binary (Linux x86_64/arm64, macOS arm64/x86_64, SHA-256 verified): curl -fsSL https://raw.githubusercontent.com/itsthecsguy/ratchet/main/scripts/install.sh | sh # Update anytime to the latest release (SHA-256 verified, atomic swap): ratchet update # Or install from source via Git (Rust 1.82+): cargo install --git https://github.com/itsthecsguy/ratchet --locked ratchet-cli # Or from a local checkout: cargo install --path crates/ratchet-cli
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| ratchet ★ | 373 | +373 | Rust | MIT | A local Rust CLI that lints agent guidance and enforces rules at tool-call time |
| rtk | 88.7k | +684 | Rust | Apache-2.0 | A local Rust CLI wrapper that trims command output before coding agents read it. |
| obsidian-skills | 56.2k | +1.7k | Shell | MIT | Agent Skills plugins for editing Obsidian files and working with vaults |
| ECC | 316.1k | +4.2k | JavaScript | MIT | Plugins and CLI workflows for planning, reviewing, and verifying agent-written c |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/itsthecsguy/ratchet.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about ratchet
Does Ratchet need an MCP server or a background service?
when: tool rule can govern MCP and other tool calls.What hardware and runtime overhead should we budget for?
Can we self-host Ratchet for commercial use?
When is Ratchet better than native agent permissions or ordinary CI linting?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy