refactor-safe
Improves code structure while guaranteeing behavior remains unchanged.
Install
mkdir -p .claude/skills/refactor-safe && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13115" && unzip -o skill.zip -d .claude/skills/refactor-safe && rm skill.zipInstalls to .claude/skills/refactor-safe
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Safely refactor code while preserving behavior. Use for cleanup, modularization, extracting functions, reducing duplication, improving boundaries, or preparing a feature.Key capabilities
- →Define refactor target and non-goals
- →Inspect existing tests and add characterization tests
- →Make small, structure-preserving changes
- →Run targeted checks after each step
- →Avoid formatting-only churn
How it works
The skill guides through a procedure of defining targets, inspecting tests, making small changes, and running checks to improve code structure.
Inputs & outputs
When to use refactor-safe
- →Extracting functions
- →Reducing code duplication
- →Improving module boundaries
- →Cleaning up legacy code
About this skill
Safe Refactor Skill
Goal
Improve structure without changing observable behavior.
Procedure
- Define the refactor target and non-goals.
- Inspect existing tests. If weak, add characterization tests when practical.
- Make the smallest structure-preserving change.
- Run targeted checks after each meaningful step.
- Avoid formatting-only churn unless formatter is part of the repo workflow.
- Do not change public APIs, schema, or behavior unless explicitly requested.
Output
- Before/after structure.
- Files changed.
- Behavior-preservation evidence.
- Remaining cleanup opportunities.
When not to use it
- →When the goal is to change public APIs
- →When the goal is to change schema
- →When the goal is to change behavior without explicit request
Limitations
- →The skill does not change public APIs, schema, or behavior unless explicitly requested
- →The skill avoids formatting-only churn unless a formatter is part of the repo workflow
How it compares
This skill provides a structured, step-by-step procedure for refactoring with an emphasis on preserving behavior, unlike an unstructured approach that might introduce regressions.
Compared to similar skills
refactor-safe side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| refactor-safe (this skill) | 0 | 1mo | No flags | Intermediate |
| software-architecture | 333 | 6mo | No flags | Intermediate |
| effective-go | 323 | 9mo | No flags | Beginner |
| solid-principles | 57 | 9mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by emanhthangngot
View all by emanhthangngot →You might also like
software-architecture
davila7
Guide for quality focused software architecture. This skill should be used when users want to write code, design architecture, analyze code, in any case that relates to software development.
effective-go
openshift
Apply Go best practices, idioms, and conventions from golang.org/doc/effective_go. Use when writing, reviewing, or refactoring Go code to ensure idiomatic, clean, and efficient implementations.
solid-principles
SmidigStorm
Enforce SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) in object-oriented design. Use when writing or reviewing classes and modules.
typescript-review
metabase
Review TypeScript and JavaScript code changes for compliance with Metabase coding standards, style violations, and code quality issues. Use when reviewing pull requests or diffs containing TypeScript/JavaScript code.
react-modernization
wshobson
Upgrade React applications to latest versions, migrate from class components to hooks, and adopt concurrent features. Use when modernizing React codebases, migrating to React Hooks, or upgrading to latest React versions.
ast-grep
ast-grep
Guide for writing ast-grep rules to perform structural code search and analysis. Use when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text search. This skill should be used when users ask to search for code patterns, find specific language constructs, or locate code with particular structural characteristics.