refactor-selected

Refactor selected Rust code to reduce indentation with early-exit control flow.

31|5|Updated Jul 26, 2025
One-click install
npx skills add https://github.com/mutemoon/moon-lol --skill refactor-selected
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-selected
Source: https://github.com/mutemoon/moon-lol/tree/main/.claude/skills/refactor-selected
Command: npx skills add https://github.com/mutemoon/moon-lol --skill refactor-selected

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactoring selected code to reduce nesting and improve readability, especially when control flow can exit early.

Core Features & Use Cases

  • Optimize selected code blocks: Refactors only the portion of code you choose, improving structure without changing broader behavior.
  • Reduce indentation via early returns: Encourages patterns like let-else return or if with return to avoid deep nesting.
  • Use case: When reviewing a Rust function with multiple nested conditionals, select the most nested section and refactor it so the function becomes easier to scan.

Quick Start

Apply the refactor-selected skill to your selected Rust code to reduce indentation by using early returns.

Frequently Asked Questions about refactor-selected

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

FAQPage Schema
How do I reduce nesting in Rust code to improve readability?

Reduce nesting in Rust code by applying early-exit control flow patterns like let-else return and if return. This technique flattens deeply nested conditionals, making the selected block easier to scan and maintain.

What is the best way to refactor only a small selected block of Rust code?

Refactor a small selected block of Rust code by applying early returns to transform nested conditionals into let-else return or if return patterns. This scopes the structural improvement strictly to your chosen selection without altering broader behavior.

When do I need to use early returns in Rust code review?

Use early returns in Rust code review when a function contains multiple nested conditionals or let patterns. Transforming these into early-exit control flow reduces indentation depth, making the logic significantly easier to scan and understand.

Does refactor-selected work with Rust let-else patterns to reduce indentation?

Yes, it works with Rust let-else patterns by transforming them into early return statements. This reduces indentation and improves readability while keeping the change scoped exactly to the selected code block.

Are there limitations to refactoring Rust code with early returns?

The main limitation is scope: refactoring applies only to the selected code block and handles patterns like let-else return and if return. It does not change broader function behavior or restructure logic outside your selection.