Rust Refactoring Playbook
Decision frameworks for simplifying Rust, splitting modules and migrating types one safe commit at a time.
Claude's review
7/10 Self-contained Rust refactoring frameworks, transformations, examples and a checklist.
We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.
In detail
Decision frameworks for Rust refactoring, simplification, module decomposition, and incremental migration. Use this skill when simplifying Rust code, splitting large files, removing dead abstractions, migrating types incrementally, or cleaning up feature flags. Triggers on Rust refactoring, simplification, module splitting, parameter cleanup, or incremental type migration.
How you use it
- Add it to your pack, then download your pack (1 credit).
- In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
- Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide
Safety check
Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.
An automated scan lowers risk but cannot promise zero risk. How we check skills
Preview
The first lines of SKILL.md
---
name: rust-refactor
description: Decision frameworks for Rust refactoring, simplification, module decomposition, and incremental migration. Use this skill when simplifying Rust code, splitting large files, removing dead abstractions, migrating types incrementally, or cleaning up feature flags. Triggers on Rust refactoring, simplification, module splitting, parameter cleanup, or incremental type migration.
---
# Rust Refactoring Frameworks
This skill teaches you to look at working Rust code and see unnecessary complexity. Every refactoring starts with a diagnostic question, follows a transformation pattern, and ends with a self-review checklist.
---
## The Two Refactoring Philosophies
Before touching code, decide which mode you are in.
**Defensive mode:** Add abstraction for safety. Split types. Create From bridges. Audit every consumer. Use when: security-critical code, type evolution, multi-crate dependencies.
**Offensive mode:** Delete indirection. Remove forwarded parameters. Collapse layers. Use when: the abstraction adds complexity without adding safety, the mediator just forwards, the parameter is always None.
Know which mode you are in. Do not add abstraction when you should be deleting, and do not delete safety layers when you should be adding them.
---
## The 4 Diagnostic Questions
Run these BEFORE touching any code. They determine WHAT to refactor.
### 1. "Is this parameter just being forwarded?"
**Signal:** The function body only passes the parameter to another function. No local logic depends on it.
**Action:** Remove it. Replace with ambient/global access at the point of actual use. Remove from the lowest layer first, fix compilation errors upward.
### 2. "Is this feature flag still needed?"
**Signal:** Stage is `Stable` or equivalent, default is enabled, no rollback planned.
**Action:** Remove the flag. Delete the conditional. Rename gated functions (`init_if_enabled` -> `init`). Remove monitoring scaffolding.
### 3. "Is this file doing too many things?"
**Signal:** File over ~500 lines with `impl` blocks operating on different domains (e.g., threads AND logs AND jobs).
...From pproenca's repository, MIT licence.
Related skills
-
Checked
Rust best practices
Writes and reviews idiomatic, maintainable Rust code and runs a checklist before handing it back to you.
7/101 credit -
Checked
Port code to Rust
Ports C, C++, Python, Go or JavaScript code into idiomatic Rust, with tests that prove it behaves the same.
8/101 credit -
Checked
Rust code review
Reviews Rust code for idiom, errors, safety and API design, with a ranked report and a fix for every finding.
7/101 credit -
Checked
Java Debugging Guide
Finds the cause of Java bugs and failing tests, and attaches a debugger safely in Maven, Gradle, Spring or Docker.
7/101 credit -
Checked
Python games with pygame
Builds and debugs 2D pygame games with a proper loop and delta time, so they run the same on any PC.
7/101 credit -
Checked
Go Benchmarking and Profiling
Writes Go benchmarks, profiles them with pprof and proves each speedup with benchstat before you claim it.
7/101 credit