Ratchets: Progressive lint enforcement for human and AI developers
Ratchets is a progressive lint enforcement tool that allows codebases to contain existing violations while preventing new ones. Unlike traditional linters that enforce binary pass/fail, Ratchets permits a budgeted number of violations per rule per region. These budgets can only decrease over time (the "ratchet" mechanism), ensuring technical debt monotonically decreases.
Key Features
- Progressive enforcement: Allow existing violations while preventing new ones
- Region-based budgets: Set different limits for different parts of your codebase
- Regex and AST rules: Match patterns via text or tree-sitter queries
- Agent-friendly: JSONL output, deterministic results, clear exit codes
- Fast: Parallel execution, lazy parser loading, Rust performance
Installation
Install from Github
Install from source using the installation script:
|
This will automatically build and install ratchets to ~/.cargo/bin/. Requires Rust/Cargo to be installed.
Quick Start
Initialize Ratchets in your repository:
This creates:
ratchets.toml— Configuration fileratchet-counts.toml— Violation budgetsratchets/— Directory for custom rules
Run checks:
Usage
ratchets check
Verify that violations are within budget:
ratchets bump
Increase the violation budget (requires justification in commit message):
ratchets tighten
Reduce budgets to match current violation counts:
ratchets list
List all enabled rules and their status:
Configuration
ratchets.toml
[]
= "1"
= ["rust", "typescript"]
= ["src/**", "tests/**"]
= ["**/generated/**"]
[]
= true
= { = "warning" }
[]
= "human"
ratchet-counts.toml
[]
= 0
= 15
= 50
[]
= 23
Regions are directory subtrees. Child regions inherit parent budgets unless overridden.
Git Integration
Merge Driver
Ratchets provides a merge driver that resolves conflicts by taking the minimum count:
# .gitattributes
# .git/config
)
Pre-commit Hook
#!/bin/sh
||
Exit Codes
| Code | Meaning |
|---|---|
| 0 | All rules within budget |
| 1 | At least one rule exceeded budget |
| 2 | Configuration or usage error |
| 3 | Parse error in source file |
Documentation
- DESIGN.md — Design specification and rationale
- ARCHITECTURE.md — Implementation architecture
Further Reading
The ratchet concept was originally described by qntm: https://qntm.org/ratchet