๐ŸŽฏ

rust-refactor-helper

๐ŸŽฏSkill

from goooice/rust-skills

VibeIndex|
What it does

Performs safe Rust refactoring by analyzing symbol references, checking conflicts, and applying changes across project files using LSP.

๐Ÿ“ฆ

Part of

goooice/rust-skills(35 items)

rust-refactor-helper

Installation

Add MarketplaceAdd marketplace to Claude Code
/plugin marketplace add ZhangHanDong/rust-skills
Install PluginInstall plugin from marketplace
/plugin install rust-skills@rust-skills
Quick InstallInstall with npx
npx skills add ZhangHanDong/rust-skills
git cloneClone repository
git clone https://github.com/ZhangHanDong/rust-skills.git
๐Ÿ“– Extracted from docs: goooice/rust-skills
4Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

"Safe Rust refactoring with LSP analysis. Triggers on: /refactor, rename symbol, move function, extract, ้‡ๆž„, ้‡ๅ‘ฝๅ, ๆๅ–ๅ‡ฝๆ•ฐ, ๅฎ‰ๅ…จ้‡ๆž„"

Overview

# Rust Refactor Helper

Perform safe refactoring with comprehensive impact analysis.

Usage

```

/rust-refactor-helper [--dry-run]

```

Actions:

  • rename - Rename symbol
  • extract-fn - Extract to function
  • inline - Inline function
  • move - 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 tool

```

Output:

```

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 changes

```

2. 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 call

```

Output:

```

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 {

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 plan

```

Output:

```

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 detected

```

Safety 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-run

```

This 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 |

More from this repository10

๐ŸŽฏ
m14-mental-model๐ŸŽฏSkill

Applies the M14 mental model framework to enhance decision-making and strategic thinking through structured cognitive analysis.

๐ŸŽฏ
m04-zero-cost๐ŸŽฏSkill

Guides developers in choosing zero-cost abstractions by analyzing type system constraints and performance trade-offs in Rust generics and traits.

๐ŸŽฏ
m10-performance๐ŸŽฏSkill

Optimizes code performance by identifying bottlenecks, measuring impact, and guiding strategic improvements across algorithm, data structure, and memory efficiency.

๐ŸŽฏ
meta-cognition-parallel๐ŸŽฏSkill

Performs parallel three-layer meta-cognitive analysis by forking subagents to simultaneously analyze language mechanics, design choices, and domain constraints, then synthesizing results.

๐ŸŽฏ
unsafe-checker๐ŸŽฏSkill

Identifies and reviews unsafe Rust code patterns, FFI risks, and potential memory unsafety in Rust projects.

๐ŸŽฏ
rust-skill-creator๐ŸŽฏSkill

Dynamically generates Claude skills for Rust crates, standard library modules, and documentation by extracting and processing technical details from specified URLs.

๐ŸŽฏ
coding-guidelines๐ŸŽฏSkill

Provides comprehensive Rust coding guidelines covering naming conventions, best practices, error handling, memory management, concurrency, and code style recommendations.

๐ŸŽฏ
m03-mutability๐ŸŽฏSkill

Diagnoses and guides resolution of Rust mutability and borrowing conflicts by analyzing ownership, mutation patterns, and thread-safety requirements.

๐ŸŽฏ
domain-iot๐ŸŽฏSkill

Enables building robust, efficient IoT applications with offline-first design, power-aware networking, and secure device communication using Rust.

๐ŸŽฏ
m05-type-driven๐ŸŽฏSkill

Explores and demonstrates type-driven development techniques in Rust, showcasing advanced type system features and pattern matching strategies.