rust-refactor-helper
Safe Rust refactoring with LSP-driven impact analysis and dry-run preview.
- Supports four refactoring actions: rename symbol, extract function, inline function, and move to module
- Performs pre-refactor analysis using LSP operations (find references, go to definition, call hierarchy) to identify all affected code locations
- Generates detailed impact reports showing definition location, all references categorized by file, and potential issues like documentation updates or public API changes
- Includes dry-run mode to preview all changes before applying them, with safety checks for name conflicts, visibility changes, macro-generated code, and circular dependencies
Rust Refactor Helper
Perform safe refactoring with comprehensive impact analysis.
Usage
/rust-refactor-helper <action> <target> [--dry-run]
Actions:
rename <old> <new>- Rename symbolextract-fn <selection>- Extract to functioninline <fn>- Inline functionmove <symbol> <dest>- Move to module
Examples:
/rust-refactor-helper rename parse_config load_config/rust-refactor-helper extract-fn src/main.rs:20-35
More from zhanghandong/rust-skills
m15-anti-pattern
Use when reviewing code for anti-patterns. Keywords: anti-pattern, common mistake, pitfall, code smell, bad practice, code review, is this an anti-pattern, better way to do this, common mistake to avoid, why is this bad, idiomatic way, beginner mistake, fighting borrow checker, clone everywhere, unwrap in production, should I refactor, 反模式, 常见错误, 代码异味, 最佳实践, 地道写法
5.4Kcoding-guidelines
Use when asking about Rust code style or best practices. Keywords: naming, formatting, comment, clippy, rustfmt, lint, code style, best practice, P.NAM, G.FMT, code review, naming convention, variable naming, function naming, type naming, 命名规范, 代码风格, 格式化, 最佳实践, 代码审查, 怎么命名
1.1Km10-performance
CRITICAL: Use for performance optimization. Triggers: performance, optimization, benchmark, profiling, flamegraph, criterion, slow, fast, allocation, cache, SIMD, make it faster, 性能优化, 基准测试
803m07-concurrency
CRITICAL: Use for concurrency/async. Triggers: E0277 Send Sync, cannot be sent between threads, thread, spawn, channel, mpsc, Mutex, RwLock, Atomic, async, await, Future, tokio, deadlock, race condition, 并发, 线程, 异步, 死锁
744m06-error-handling
CRITICAL: Use for error handling. Triggers: Result, Option, Error, ?, unwrap, expect, panic, anyhow, thiserror, when to panic vs return Result, custom error, error propagation, 错误处理, Result 用法, 什么时候用 panic
734m01-ownership
CRITICAL: Use for ownership/borrow/lifetime issues. Triggers: E0382, E0597, E0506, E0507, E0515, E0716, E0106, value moved, borrowed value does not live long enough, cannot move out of, use of moved value, ownership, borrow, lifetime, 'a, 'static, move, clone, Copy, 所有权, 借用, 生命周期
717