Linter Auto-Fix Delegation (Local CLI Formatting Protocol)
Overview
When a continuous integration check or code quality gate reports 30 style violations (missing semicolons, trailing commas, unused import statements, improper quote marks), naive agents attempt to fix each violation manually through LLM code generation turns.
Asking an LLM to fix mechanical lint errors burns 2,000 to 5,000 output tokens, takes 15 to 25 seconds of streaming latency, and risks introducing subtle logic regressions during the rewrite.
The Linter Auto-Fix Delegation Protocol delegates 100% of deterministic style, formatting, and import fixes to local high-speed CLI linters (ruff, biome, eslint --fix, cargo clippy), resolving violations in 10 milliseconds on local CPU at zero token cost.
Manual LLM Refactoring vs. Local Linter Auto-Fix
┌─────────────────────────────────────────────────────────────┐
│ Linter Resolution Comparison │
│ │
│ Manual LLM Code Rewrite (30 Lint Errors): │
│ • Agent reads 400-line file into context │
│ • Generates 400 lines of modified code to fix quotes/semis │
│ • 2,200 tokens billed, 14.5 seconds streaming latency │
│ • High risk of accidentally altering business logic │
│ │
│ Local Linter Delegation (`ruff --fix` / `biome --write`): │
│ • Agent executes: `ruff check --fix src/` via CLI │
│ ↳ 30 violations healed deterministically in 12ms (Local CPU)│
│ ↳ 0 Tokens Billed ($0.00), 1,200x Faster Execution! │
└─────────────────────────────────────────────────────────────┘
The High-Speed Linter Delegation Arsenal
Execute these sub-50ms CLI commands via run_command:
1. Python (ruff - 100x Faster than Flake8/Black)
# Fix unused imports, sorting, quotes, and standard PEP8 rules
ruff check --fix src/
ruff format src/
2. TypeScript / JavaScript (biome or eslint)
# Ultra-fast Rust-based linter & formatter (Biome)
npx -y @biomejs/biome check --write src/
# Standard ESLint auto-fix
npx -y eslint --fix src/
3. Rust & Go
# Rust: Auto-format and apply clippy suggestions
cargo fmt
cargo clippy --fix --allow-dirty
# Go: Format and optimize imports
gofmt -w .
goimports -w .
The 2-Tier Rule for Agent Lint Tasks
┌───────────────────────────────────────────────────────────────────────────┐
│ TIER 1: RUN LOCAL AUTO-FIX FIRST (Always Mandatory) │
│ Run `ruff check --fix` or `eslint --fix`. In 90% of cases, all errors heal│
│ │
│ TIER 2: LLM INTERVENTION ONLY FOR REMAINING SEMANTIC ERRORS │
│ If linter reports un-fixable semantic error (e.g. `TS2345: Type mismatch`)│
│ • Use `replace_file_content` targeting *only* that specific line │
└───────────────────────────────────────────────────────────────────────────┘
Benchmark Comparison
Resolving 50 formatting, import, and style violations across a 15-file repository:
| Metric | Manual LLM Code Rewriting | Linter CLI Auto-Fix Delegation | Improvement |
|---|---|---|---|
| Total LLM Tokens Billed | 18,500 tokens | 0 tokens | 100% Token Savings |
| Execution Duration | 48.0 seconds | 0.04 seconds | 1,200x Faster |
| Accidental Logic Loss | 2 bugs introduced | 0 (Guaranteed by AST engine) | 100% Deterministic |
Agent Operational Directive
MANDATORY: Agents must NEVER manually rewrite code files to fix formatting, indentation, semicolon, or unused import violations. Always delegate mechanical lint fixes to local CLI tools (
ruff --fix,biome check --write,eslint --fix).