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.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# Refactor
## Overview
Improve code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch.
## When to Use
Use this skill when:
- Code is hard to understand or maintain
- Functions/classes are too large
- Code smells need addressing
- Adding features is difficult due to code structure
- User asks "clean up this code", "refactor this", "improve this"
---
## Refactoring Principles
### The Golden Rules
1. **Behavior is preserved** - Refactoring doesn't change what the code does, only how
2. **Small steps** - Make tiny changes, test after each
3. **Version control is your friend** - Commit before and after each safe state
4. **Tests are essential** - Without tests, you're not refactoring, you're editing
5. **One thing at a time** - Don't mix refactoring with feature changes
### When NOT to Refactor
```
- Code that works and won't change again (if it ain't broke...)
- Critical production code without tests (add tests first)
- When you're under a tight deadline
- "Just because" - need a clear purpose
```
---
## Common Code Smells & Fixes
…
The line at the top of this page pins the label git:20260420.c261aaa, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
GET https://markdownregistry.com/api/v1/artifacts/art_barkz7wdfzpmcqdu
GET https://markdownregistry.com/api/v1/resolve?ref=devantler-tech/agent-plugins/refactor
GET https://markdownregistry.com/api/v1/blob/9986e42e3415ecd914b8ea17fd7414cb25c8182d28393a511c780b71eb3f46e9
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/agent-improvement/SKILL.md · How a meta-engineer improves an autonomous AI engineer from the OUTSIDE — mining the agent's own operational telemetry…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/agent-instructions/SKILL.md · Architect a repository's AI-agent instruction files so one canonical source drives every tool without drift — AGENTS.md…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/find-skills/SKILL.md · Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/grilling/SKILL.md · Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/portfolio-maintenance/SKILL.md · The run loop for an autonomous AI engineer acting as a portfolio's primary engineer — pre-flight, resume in-flight work…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/product-documentation/SKILL.md · Build or maintain user documentation sites for software products, including tutorials, task guides, API reference and…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/product-engineering/SKILL.md · The ADVANCE playbook for an autonomous AI engineer — how to move a product forward once it is healthy: product strategy…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/prototype/SKILL.md · Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model…
devantler-tech/agent-plugins · plugins/agentic-engineering/skills/self-improvement/SKILL.md · How an autonomous AI engineer improves its OWN definition (its engineering contract, agent definitions, and skills)…
devantler-tech/agent-plugins · plugins/engineering-practices/skills/conventional-release/SKILL.md · Ship changes through a squash-merge + Conventional Commits release pipeline where the PR title becomes the release note…
code-yeongyu/oh-my-openagent · packages/shared-skills/skills/refactor/SKILL.md · Guides a refactor, cleanup, or restructure with the right decomposition. Use when the user asks to refactor, simplify…
rsmdt/the-startup · plugins/start/skills/refactor/SKILL.md · Refactor, simplify, or clean up code for improved maintainability without changing business logic
boshu2/agentops · skills/refactor/SKILL.md · Restructure or clean up code with no behavior change, proved by before-and-after checks. Use when: asked to clean up…
boshu2/agentops · plugin/skills/refactor/SKILL.md · Restructure or clean up code with no behavior change, proved by before-and-after checks. Use when: asked to clean up…