Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

recast

recast is a CLI for safe, atomic, transparent multi-file text rewrites. Pure Rust. Tuned for LLM coding agents driving mechanical edits; equally usable by humans for mechanical refactors.

Why it exists

LLM agents and shell scripts that rewrite code typically fall back to sed, sd, or a Python heredoc. All three share two silent failure modes:

  1. Silent no-match. The pattern misses, the tool exits 0, the agent moves on assuming success.
  2. Non-idempotent re-runs. Re-running a rewrite on already-rewritten text either no-ops (looks like the first run failed) or, worse, compounds the rewrite.

recast makes both impossible by default. A missing match is a non-zero exit; a non-convergent rewrite is rejected outright.

What it does

Capabilitysed / sdPython heredocrecast
Multi-file rewritemanual / yesyesyes
Match-required guardnonoyes
Idempotency checknonoyes
Atomic two-phase applynonoyes
Diff preview by defaultnonoyes
Crash-recovery sweepnonoyes
Agent-friendly JSONnonoyes
Regex patternyesyesyes
Script pattern (Rhai)noyes (Python)yes
Structural (AST)nonoyes (tree-sitter)

Status

Alpha. Tracked in PLAN.md; release notes in CHANGELOG.md.