refactoring-to-patterns — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited refactoring-to-patterns (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Refactoring is the process of changing the internal structure of code without changing its observable behavior. Every refactoring step must leave all tests passing. Never refactor while also adding features — separate the two activities.
Refactor when you need to:
refactor first, then change. Two small moves beat one large dangerous move.
tolerate duplicate code the second time, refactor the third time.
fix reliably. Clarify first, then fix.
Do NOT refactor when:
sake is waste.
do not block the feature.
Smell: A function that is too long to understand in one reading (~30+ lines is a guideline, not a rule — some 10-line functions are too long).
Refactorings:
function. The new name documents intent.
into a method so the name explains what is computed.
branches into named methods.
Smell: The same structure appears in two or more places. The danger: a bug in the pattern must be fixed in every copy.
Refactorings:
shared behavior into a new class both can use.
base class.
order, extract the skeleton into a template method and override the varying parts.
Smell: A class has too many responsibilities, indicated by many instance variables, many methods, or methods that use only a subset of variables.
Refactorings:
move them to a new class and compose.
conditions, extract a subclass for each behavioral variant.
that callers actually need.
Smell: A function with four or more parameters is hard to call correctly and hard to remember.
Refactorings:
always travel together with a single object.
multiple values from it before calling.
calling a method on another, remove it and call the method inside.
Smell: A single class changes for multiple different reasons — every time X happens you change one set of methods, every time Y happens you change a different set. This is SRP violation made visible.
Refactorings:
change.
Smell: One logical change requires small edits to many different classes. The opposite of Divergent Change: behavior that should be together is spread apart.
Refactorings:
home.
them.
Smell: A method that seems more interested in another class's data than its own — it uses getters to pull out data and compute something.
Refactorings:
data and the behavior belong together.
that part and move it.
Smell: Using primitives (strings, integers, booleans) to represent domain concepts — phone numbers as strings, money as floats, status as magic string constants.
Refactorings:
carries validation, formatting, and behavior.
that the compiler can check.
use polymorphism instead of a type field.
Smell: Complex chains of if/else or switch that must be updated every time a new variant is added. Frequently accompanies Primitive Obsession.
Refactorings:
override in a subclass or strategy.
that does nothing (or the right default thing).
named methods so the intent is readable.
Smell: A single function alternates between high-level orchestration ("save the order, charge the card, send the receipt") and low-level primitives ("for each line, format the price as fixed-width 8 chars"). Readers must repeatedly swap mental contexts. Often a sign of an unextracted helper.
Refactorings:
at the surrounding level's abstraction.
abstraction below its own; never two or more levels at once.
Smell: A class that delegates most of its methods to another class. If half or more of a class's public methods just forward to another class, the middle man adds no value.
Refactorings:
Smell: A class instantiates its dependencies inside methods (new HttpClient() inside fetchUser()), takes per-call work parameters in the constructor (new ReportGenerator(2024, 1, 1, 2024, 12, 31)), or does I/O / static lookups in the constructor. No seam exists for tests to substitute collaborators.
Refactorings:
dependencies (HTTP client, DB, clock, logger) to the constructor signature. Inject them; do not new them inside.
query strings, and request bodies belong on the method, not the constructor.
no expensive computation. Just assign collaborators and return.
This creates a seam: production wires real collaborators through DI; tests substitute fakes or stubs at construction.
Every refactoring step must follow this sequence:
refactor broken code.
time.
immediately. Do not proceed with broken tests.
When working with existing code during implementation:
to make the feature easier to add, do the refactoring in its own commit first, then add the feature.
distant code unrelated to the current task — that is scope creep.
user validation into UserValidator (Long Method)" tells reviewers exactly what happened and why.
breaks tests is worse than the smell it was trying to fix. Only refactor when you are confident the transformation is safe.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.