Contents
Most refactoring tooling needs a language server. TypeScript has one, Python has Rope and LibCST, Rust has rust-analyzer. When none of them is installed — a scratch snippet, a code review comment, a gist you are triaging — you fall back to find-and-replace and hope. The Refactoring Assistant is a small browser tool for exactly that gap: paste a snippet, pick a refactoring, inspect the diff before you copy anything.
There is no backend, no language model, and no network call. Every rewrite happens in your browser and the code never leaves the page. It is the second entry in the Code Transformation block of CodeIntel’s tools roadmap, after the Language Transpiler.
The five refactorings
The tool ships a fixed set of transformations, and it is honest about being a fixed set:
- Rename symbol — a whole-word rename of one identifier across the snippet. A line-level scanner splits each line into code versus string/comment regions, so occurrences inside a literal or a trailing comment are skipped and counted in a warning rather than silently renamed.
- Inline variable — finds a simple local assignment, confirms the name is used exactly once on a later line, substitutes the right-hand side into that use, and deletes the assignment. If the variable is used zero times or two or more times, or is reassigned, the tool refuses and says so instead of guessing.
- Extract function — takes a 1-indexed line range and wraps it into a new function. Python gets a
defplus a re-indented body; JavaScript and TypeScript get afunctiondeclaration in braces, with the selection replaced by a call. Parameter inference is best-effort and frequently needs a manual pass. - Convert to arrow function — rewrites
function name(args) {intoconst name = (args) => {, the mechanical half of a common modern-JS cleanup (MDN). - Replace var with let — swaps
vardeclarations forlet, leavingconstuntouched.
Each transformation is a pure function from source text to source text. Each returns a change count and a list of warnings, and the warnings are the interesting part: they name the occurrence counts, the skipped string/comment matches, the unsupported cases.
The diff is real, not decorative
Before you copy the result, the tool renders a line-level diff between the input and the output, with removed lines marked - and added lines marked +. It is a standard longest-common-subsequence diff, computed in the page, with a set-based fallback for inputs large enough to blow the O(n·m) table. Running the same paste twice always produces the same diff, because the engine is a deterministic function of its input — you can verify that yourself by applying a refactoring, undoing it, and applying it again.
How the heuristic works, and what that costs
The engine is line-oriented and token-aware but not a parser. It knows a string starts at a quote and a comment starts at # or //; it does not know what a binding is, what scope a name lives in, or what a full expression parses to. That single design choice is the whole trade-off.
The gain is that it is fast, inspectable, dependency-free, and works on any snippet regardless of environment. The cost is precision. Rename is scope-unaware: if two different variables share a name, both get renamed. Inline only fires on the textbook single-assignment, single-use case. Extract cannot infer parameters from data flow — it offers a plausible list and flags the rest.
So the tool never claims more than it can prove. When a transformation is ambiguous, it leaves the code unchanged and explains why. A visible refusal is better than a silent wrong edit.
Limitations worth stating plainly
This is a rewriter, not a compiler. It does not build an abstract syntax tree, it does not resolve types, and it does not guarantee semantic equivalence. Comment and string detection is heuristic, so an unusual quoting style can confuse the masker. Treat the output as a reviewed draft: run your normal tests, and check the diff before you paste it back into a real file. The roadmap card links to the scope the tool commits to, and the limitations section on the tool page lists every known edge case.
Try it
The tool is live at codeintel.xyz/tools/refactoring-assistant/. Language selection can auto-detect or be set explicitly to Python, JavaScript, TypeScript, or Rust. Load the built-in sample, apply a rename and then an inline, and watch the diff and the warnings panel update. To confirm the “no backend” claim, disconnect from the network before you paste anything sensitive.




