Refactor existing code while preserving public behavior, callers and project conventions; use compatibility evidence rather than bundling unrelated cleanup.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Safe Refactoring?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/najuaircrack-safe-refactoring)
---
name: safe-refactoring
description: "Refactor existing code while preserving public behavior, callers and project conventions; use compatibility evidence rather than bundling unrelated cleanup."
license: MIT
---
# Behavior-preserving refactoring
Identify the owning module, exported contract, callers and serialized forms before moving code. Check whether reflection, configuration, dependency injection, dynamic imports or persisted names create consumers that a static import graph cannot see.
Keep behavior changes separate unless the request authorizes both. Establish characterization at the actual boundary when coverage is missing, including ordering, mutation, error types and side effects that consumers rely on. An accidental existing behavior needs an explicit decision before treating it as a requirement or deleting it.
Make one coherent structural change. Preserve native resources, cancellation, ownership and transaction boundaries. Avoid broad abstractions for a single consumer. When a public name or schema must change, update producer and actual consumers together and retain a deliberate compatibility path if supported versions require one.
Run the affected normal entry point and regression checks. Inspect the final diff for moved behavior, overlooked callers and unrelated formatting. Report any compatibility surface that source search or local execution could not verify.