code-refactor

When to Use This Skill

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "code-refactor" with this command: npx skills add laurigates/claude-plugins/laurigates-claude-plugins-code-refactor

When to Use This Skill

Use this skill when... Use something else when...

A file or directory has mixed side effects and business logic Deduplicating code across files → /code:dry-consolidation

Functions mutate state or parameters Detecting code smells without fixing → /code:antipatterns

Business logic is tangled with I/O or logging Reviewing overall quality and architecture → /code:review

Imperative loops can be replaced with map/filter/reduce Large multi-phase refactor spanning 10+ files → /workflow:checkpoint-refactor

Deep nesting obscures intent

Context

  • Target path: !echo "$1"

Parameters

  • $1 : Required file path or directory to refactor

Your task

Delegate this task to the code-refactoring agent.

Use the Agent tool with subagent_type: code-refactoring to refactor the specified code. Pass all the context gathered above to the agent.

The code-refactoring agent should:

Identify refactoring opportunities — look for these FP code smells:

  • Side effects (mutation, I/O, logging) mixed into computation functions

  • Parameters or external state mutated in place

  • Imperative loops (for , while ) that could be map , filter , reduce , or flatMap

  • Shared mutable state accessed across functions

  • Deep nesting where early returns or guard clauses would clarify intent

  • Business logic entangled with I/O at call sites

  • Duplicated transformation logic

Apply functional programming principles:

  • Pure functions: Extract computation into functions with no side effects — same input always produces same output

  • Immutability: Replace in-place mutation with data transformations (spread , map , Object.assign , structural copies)

  • Composition: Build complex behavior from small, focused, single-purpose functions

  • Higher-order functions: Replace imperative loops with map , filter , reduce , flatMap , find

  • Explicit effects: Push I/O, logging, and mutations to the outermost boundary; keep inner functions pure

  • Early returns / guard clauses: Validate preconditions at the top, return early to avoid deep nesting

  • DRY / KISS: Eliminate repetition; prefer the simplest shape that works

Preserve functionality:

  • Ensure all existing tests pass

  • Maintain the external API contract

  • No behavioral changes

Output the refactored code with clear structure

Provide the agent with:

  • The target file or directory path

  • The detected programming language

  • Any style guide examples from the project

The agent has expertise in:

  • Behavior-preserving code transformations

  • Functional refactoring patterns

  • Code smell detection and remediation

  • Semantic code search for similar patterns

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

python-code-quality

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

python-development

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

python-testing

No summary provided by upstream source.

Repository SourceNeeds Review