Use a query tool to rewrite Rust code in bulk

They had Claude build a tool that finds Rust compiler patterns and rewrites them in batches instead of editing each site manually.

Done with Claude· Advanced· Nov 2026

What they did
A developer working on rustc asked Claude to create a reusable refactoring tool for broad compiler changes. The tool uses a structural query to find target code and its nearby context, then applies rewrite rules to those matches. That let the developer review proposed edits before running them again on main or nightly.
How it went
The effort is still in progress, so there are no useful speedup numbers yet. It is also still unclear whether bigger changes, such as running all crates in one process or reducing memory use, will be worth the tradeoff.
Tips
This kind of rewrite works best when you can rerun it on up-to-date branches, so you do not end up stuck with a stale fork. Plan for coordination with the compiler team if the changes may touch other open pull requests.

Try it yourself with Claude

I’m working in [path to repo]. Find every use of [identifier, function, pattern, or API] and rewrite it to [new form]. Build a small reusable refactoring tool that uses a structural query to locate matches, shows the surrounding code, and applies the transformation in bulk. First run it on a copy of the codebase and stop before any irreversible step, such as committing, submitting, or deleting files, so I can review the proposed diff and test results. After I approve, apply the change on [branch name] and report any files that still use the old form.

Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.

Get 3 agent uses like this every morning

With the day's top AI news. Free, and one click to unsubscribe.