# Repository Briefing: itsthecsguy/ratchet
> Source: https://repoforai.com/repo/itsthecsguy/ratchet (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/itsthecsguy/ratchet
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Rust
- **License**: MIT
- **Engineering Health**: A (86/100 · Maintenance 35/35 · Adoption 11/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v0.1.5 (2026-12-03) — https://github.com/itsthecsguy/ratchet/releases
- **Review Snapshot**: 2026-12-01 (Note: v0.1.5 on 2026-12-03 shipped after this review; verify latest release notes)
- **Deployment / Stack Signals**: CLI, Self-Hosted
- **Momentum**: 373 ★ total (+13 24h / +373 7d) · 21 forks
- **Topics**: `ai-agents`, `claude-code`, `cli`, `codex`, `cursor`, `developer-tools`, `linter`, `rust`
- **When to Use**: Best for: 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. Skip if: 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.

## Overview
```text
### Architecture & 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.
```

## Key Capabilities
```text
- Rule source: Typed Markdown blocks and optional `.ratchet/checks.yaml` keep machine-enforced rules alongside agent guidance.
- Lint diagnostics: `E006` flags malformed frontmatter, `W108` finds dead globs, and `W103` catches stale repository references.
- Hook adapters: Nine coding-agent harnesses are supported, with adapter-specific tool coverage and session-end behavior.
- Rollout control: `shadow`, `warn`, `ask`, and `enforce` separate observation from blocking; `ratchet approve` offers a one-time exception.
- Verification: Inline `ok:` and `bad:` fixtures test rules deterministically; `ratchet test --models` measures behavior with real agent CLIs.
- Repository gates: `ratchet check --staged` targets staged changes, while `ratchet ci init` sets up GitHub Actions verification.
```

## Quick Start / Clone
```bash
# 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
```
