code-refactor
БесплатноБез исполняемых скриптовНе проверенRefactor toward pure functions, immutability, composition. Use when extracting pure functions, removing side effects, replacing loops with map/filter/reduce…
от laurigates★ 61 звезда на GitHubОб этом скилле
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 to the agent.
The refactor 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 bemap,filter,reduce, orflatMap - 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
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
Установить code-refactor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
TaskTodoWriteFAQ
Что делает скилл 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.
Как установить скилл code-refactor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл code-refactor запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic