fowler-rust-refactoring

Assess Rust code for refactoring opportunities and produce behavior-preserving Fowler-style plans.

2|Updated May 6, 2026
One-click install
npx skills add https://github.com/bpcakes/jig-skills --skill fowler-rust-refactoring-bpcakes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fowler-rust-refactoring
Source: https://github.com/bpcakes/jig-skills/tree/main/plugins/jig-rust/skills/fowler-rust-refactoring
Command: npx skills add https://github.com/bpcakes/jig-skills --skill fowler-rust-refactoring-bpcakes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Rust codebases accumulate structural debt—long functions, primitive obsession, scattered error handling, and misplaced responsibilities—that makes future changes risky and slow. This Skill reviews Rust code against Fowler's refactoring principles adapted to Rust idioms, validates each candidate with concrete evidence, and produces a prioritized, behavior-preserving refactoring plan instead of style-driven nitpicks. ## Core Features & Use Cases - Evidence-based smell detection: Combines a heuristic Python scanner, compiler/Clippy signals, Git change-history analysis, and semantic design review to find real maintenance costs rather than metric violations. - Rust-adapted Fowler catalog: Maps classic refactorings to idiomatic Rust forms—enums over dynamic dispatch, newtypes for validated primitives, typed Result<T, E> errors, and split-phase type-driven design. - Small-step migration plans: Every accepted finding includes a Fowler move name, target shape, independently verifiable steps, compatibility risks (semver, unsafe, FFI, async), and rollback boundaries. - Use Case: Ask for a refactoring assessment of a Rust module before a feature change; receive a prioritized report with exact file/line evidence, impact/confidence/risk labels, and an expand-migrate-contract sequence for any public API changes. ## Quick Start Ask the agent to review a Rust module or working diff for refactoring opportunities and produce a prioritized behavior-preserving plan without editing code.

Frequently Asked Questions about fowler-rust-refactoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I plan a behavior-preserving refactor of Rust code?

Request a refactoring assessment scoped to specific paths or a Git diff. The skill inspects Cargo configuration, runs a heuristic scanner, validates candidates against code context, and outputs a prioritized plan with small verifiable steps that preserve observable behavior.

How does Fowler refactoring apply to Rust instead of OOP?

Fowler's object-oriented moves are adapted to Rust idioms: enums with exhaustive matches replace conditional polymorphism for closed sets, newtypes enforce validated primitives, and typed Result errors replace exception-based control flow. Traits are used only for genuinely open extension points.

Does the refactoring scanner modify my Rust source files?

No, the bundled Python scanner is read-only and reports heuristic candidates only. The skill defaults to analysis and planning; it edits code only when the user explicitly requests implementation mode.

Can it review only changed code in a Git diff?

Yes, the scanner supports a --git-diff flag to scan Rust files changed relative to a base reference such as origin/main. The workflow also uses Git history and blame to validate Divergent Change and Shotgun Surgery candidates.

What are the limitations of automated refactoring detection?

Scanner signals are syntactic proxies with low confidence; long functions, exhaustive matches, data-only structs, and clones are often legitimate Rust. Every candidate requires manual verification of callers, ownership, and domain context before being reported as a finding.