
Rust Refactor Helper
- 836 installs
- 1.3k repo stars
- Updated May 24, 2026
- zhanghandong/rust-skills
This is a copy of rust-refactor-helper by actionbook - installs and ranking accrue to the original listing.
rust-refactor-helper is a Rust refactoring skill that performs LSP-powered impact analysis before rename, extract, inline, or move edits for developers who need safe structural changes in Rust codebases.
About
rust-refactor-helper is a Claude Code skill from zhanghandong/rust-skills that performs safe Rust refactoring with comprehensive LSP impact analysis before applying edits. Invoke it via `/rust-refactor-helper <action> <target> [--dry-run]` for actions including rename, extract-fn, inline, and move across modules. Allowed tools are LSP, Read, Glob, Grep, and Edit. Developers reach for it when renaming symbols like parse_config to load_config, extracting selections into functions, or moving items between modules without breaking references. The --dry-run flag previews impact before any file change.
- Performs comprehensive pre-refactor LSP analysis including findReferences, hover, goToDefinition and incomingCalls
- Supports rename symbol, extract-fn, inline, and move operations with full cross-reference safety checks
- Offers --dry-run mode to preview every affected location before committing changes
- Works with Rust-specific symbol understanding and module boundaries
- Triggers via slash commands: /refactor, rename, extract, move, 重构
Rust Refactor Helper by the numbers
- 836 all-time installs (skills.sh)
- +10 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Security screen: HIGH risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/zhanghandong/rust-skills --skill rust-refactor-helperAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 836 |
|---|---|
| repo stars | ★ 1.3k |
| Security audit | 2 / 3 scanners passed |
| Last updated | May 24, 2026 |
| Repository | zhanghandong/rust-skills ↗ |
How do you safely rename Rust symbols with LSP?
Perform safe, analysis-driven refactoring of Rust code using LSP-powered impact detection before any edit is applied.
Who is it for?
Rust developers refactoring crates or backend services who need rename, extract, inline, or move operations with impact analysis before editing.
Skip if: Developers working in non-Rust languages or those who only need greenfield code generation without structural refactors.
When should I use this skill?
The user triggers /refactor, rename symbol, move function, extract, safe refactor, or Chinese refactor terms like 重构 or 重命名 in Rust code.
What you get
LSP-verified Rust refactors including renamed symbols, extracted functions, inlined code, or moved module items.
- Refactored Rust modules
- LSP impact analysis report
- Dry-run preview of symbol changes
Files
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/rust-refactor-helper move UserService src/services/
LSP Operations Used
Pre-Refactor Analysis
# Find all references before renaming
LSP(
operation: "findReferences",
filePath: "src/lib.rs",
line: 25,
character: 8
)
# Get symbol info
LSP(
operation: "hover",
filePath: "src/lib.rs",
line: 25,
character: 8
)
# Check call hierarchy for move operations
LSP(
operation: "incomingCalls",
filePath: "src/lib.rs",
line: 25,
character: 8
)Refactoring Workflows
1. Rename Symbol
User: "Rename parse_config to load_config"
│
▼
[1] Find symbol definition
LSP(goToDefinition)
│
▼
[2] Find ALL references
LSP(findReferences)
│
▼
[3] Categorize by file
│
▼
[4] Check for conflicts
- Is 'load_config' already used?
- Are there macro-generated uses?
│
▼
[5] Show impact analysis (--dry-run)
│
▼
[6] Apply changes with Edit toolOutput:
## Rename: parse_config → load_config
### Impact Analysis
**Definition:** src/config.rs:25
**References found:** 8
| File | Line | Context | Change |
|------|------|---------|--------|
| src/config.rs | 25 | `pub fn parse_config(` | Definition |
| src/config.rs | 45 | `parse_config(path)?` | Call |
| src/main.rs | 12 | `config::parse_config` | Import |
| src/main.rs | 30 | `let cfg = parse_config(` | Call |
| src/lib.rs | 8 | `pub use config::parse_config` | Re-export |
| tests/config_test.rs | 15 | `parse_config("test.toml")` | Test |
| tests/config_test.rs | 25 | `parse_config("")` | Test |
| docs/api.md | 42 | `parse_config` | Documentation |
### Potential Issues
⚠️ **Documentation reference:** docs/api.md:42 may need manual update
⚠️ **Re-export:** src/lib.rs:8 - public API change
### Proceed?
- [x] --dry-run (preview only)
- [ ] Apply changes2. Extract Function
User: "Extract lines 20-35 in main.rs to a function"
│
▼
[1] Read the selected code block
│
▼
[2] Analyze variables
- Which are inputs? (used but not defined in block)
- Which are outputs? (defined and used after block)
- Which are local? (defined and used only in block)
│
▼
[3] Determine function signature
│
▼
[4] Check for early returns, loops, etc.
│
▼
[5] Generate extracted function
│
▼
[6] Replace original code with callOutput:
## Extract Function: src/main.rs:20-35
### Selected Code
```rust
let file = File::open(&path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let config: Config = toml::from_str(&contents)?;
validate_config(&config)?;
```
### Analysis
**Inputs:** path: &Path
**Outputs:** config: Config
**Side Effects:** File I/O, may return error
### Extracted Function
```rust
fn load_and_validate_config(path: &Path) -> Result<Config> {
let file = File::open(path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let config: Config = toml::from_str(&contents)?;
validate_config(&config)?;
Ok(config)
}
```
### Replacement
```rust
let config = load_and_validate_config(&path)?;
```3. Move Symbol
User: "Move UserService to src/services/"
│
▼
[1] Find symbol and all its dependencies
│
▼
[2] Find all references (callers)
LSP(findReferences)
│
▼
[3] Analyze import changes needed
│
▼
[4] Check for circular dependencies
│
▼
[5] Generate move planOutput:
## Move: UserService → src/services/user.rs
### Current Location
src/handlers/auth.rs:50-120
### Dependencies (will be moved together)
- struct UserService (50-80)
- impl UserService (82-120)
- const DEFAULT_TIMEOUT (48)
### Import Changes Required
| File | Current | New |
|------|---------|-----|
| src/main.rs | `use handlers::auth::UserService` | `use services::user::UserService` |
| src/handlers/api.rs | `use super::auth::UserService` | `use crate::services::user::UserService` |
| tests/auth_test.rs | `use crate::handlers::auth::UserService` | `use crate::services::user::UserService` |
### New File Structure
```
src/
├── services/
│ ├── mod.rs (NEW - add `pub mod user;`)
│ └── user.rs (NEW - UserService moved here)
├── handlers/
│ └── auth.rs (UserService removed)
```
### Circular Dependency Check
✅ No circular dependencies detectedSafety Checks
| Check | Purpose |
|---|---|
| Reference completeness | Ensure all uses are found |
| Name conflicts | Detect existing symbols with same name |
| Visibility changes | Warn if pub/private scope changes |
| Macro-generated code | Warn about code in macros |
| Documentation | Flag doc comments mentioning symbol |
| Test coverage | Show affected tests |
Dry Run Mode
Always use --dry-run first to preview changes:
/rust-refactor-helper rename old_name new_name --dry-runThis shows all changes without applying them.
Related Skills
| When | See |
|---|---|
| Navigate to symbol | rust-code-navigator |
| Understand call flow | rust-call-graph |
| Project structure | rust-symbol-analyzer |
| Trait implementations | rust-trait-explorer |
Related skills
How it compares
Pick rust-refactor-helper for LSP-gated structural edits; pick a Rust lint or clippy skill when you need style and warning fixes instead of symbol-level refactors.
FAQ
Which actions does rust-refactor-helper support?
rust-refactor-helper supports rename, extract-fn, inline, and move actions via `/rust-refactor-helper <action> <target> [--dry-run]`. Each action runs LSP impact analysis before edits are applied.
What does --dry-run do in rust-refactor-helper?
rust-refactor-helper --dry-run previews comprehensive LSP impact analysis for a planned rename, extract, inline, or move without writing file changes, letting developers verify reference safety first.
Is Rust Refactor Helper safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.