Skip to content
Skills Library
Programming · Building & coding

code-refactor

/code-refactor

Refactor toward pure functions, immutability, composition. Use when extracting pure functions, removing side effects, replacing loops with map/filter/reduce, or separating I/O.

Licence
MIT
Last repository change
24.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Refactor toward pure functions, immutability, composition. Use when extracting pure functions, removing side effects, replacing loops with map/filter/reduce, or separating I/O.

Arguments

/code-refactor <file-path|directory>
Original author description

Refactor toward pure functions, immutability, composition. Use when extracting pure functions, removing side effects, replacing loops with map/filter/reduce, or separating I/O.

How it works

  1. When to Use This Skill
  2. Context
  3. Parameters
  4. Your task
  5. Related Skills
Original SKILL.md headings · 69 lines, 432 words
SKILL.md preview
---
created: 2025-12-16
modified: 2026-05-09
reviewed: 2026-03-09
allowed-tools: Task, TodoWrite
args: <file-path|directory>
argument-hint: <file-path|directory>
description: Refactor toward pure functions, immutability, composition. Use when extracting pure functions, removing side effects, replacing loops with map/filter/reduce, or separating I/O.
name: 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 `agents-plugin:refactor` agent.**

Use the Agent tool with `subagent_type: agents-plugin:refactor` to refactor the specified code. Pass all the context gathered in [Context](#context) to the agent.

The refactor agent should:

1. **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

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

3. **Preserve functionality**:
   - Ensure all existing tests pass
   - Maintain the external API contract
   - No behavioral changes

4. **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

## Related Skills

- If complexity metrics needed before refactoring → `/code:complexity`
- If duplicated code needs consolidation → `/code:dry-consolidation`
- If linting standards not configured → `/configure:linting`

Versions

RepositoryScoreLicence
This page · laurigates/claude-plugins100MIT
bahayonghang/my-ai-cli-toolkit100MIT
mhattingpete/claude-skills-marketplace100Apache-2.0

Database snapshot: 13.11.2026 · package version 405c870885d9 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95refactor
    Refactor existing code by extracting helpers, splitting files, removing duplication, or untangling dependencies. Supports resumable and batch runs. Use for structural changes that preserve behavior; use zuvo:build for new features.
  • 100function-first-refactor
    Refactor or write Python by separating pure business logic from side effects ("functional core, imperative shell"), using plain functions and plain data. Use when the user asks to make code testable, decouple, simplify, or clean up Python; shares a function mixing…
  • 95refactor
    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
  • 95refactor
    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
  • 95refactor
    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
  • 90dev-loop-refactor-guide
    Use when the user asks about code refactoring, refactoring strategies, code smells, improving code structure, extracting functions/classes, or legacy code modernization. Do NOT use for: debugging (dev-loop-debugging-strategy), or performance optimization (dev-loop-performance-profiler).

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.