Skip to content
Back to skills

Safe Refactor

ASecurity

Change internal code structure while preserving observable behavior through small verified steps. Use for renames, extractions, moves, decomposition, and duplication removal when behavior must remain stable. Do not use for bug fixes, public contract changes, dependency or framework migrations, schema migrations, or other work expected to change compatibility or runtime behavior.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 19, 2026
ai-agentsgoapidatabaseperformancedocumentation

Works with

  • api

Security analysis

A100/100

Scanned September 19, 2026

npx -y skills add adityaarakeri/senior-agent-skills --skill safe-refactor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Safe Refactor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Safe Refactor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adityaarakeri-safe-refactor/badge)](https://www.skillsdirectory.com/skills/adityaarakeri-safe-refactor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: safe-refactor
description: Change internal code structure while preserving observable behavior through small verified steps. Use for renames, extractions, moves, decomposition, and duplication removal when behavior must remain stable. Do not use for bug fixes, public contract changes, dependency or framework migrations, schema migrations, or other work expected to change compatibility or runtime behavior.
---

# Safe Refactor

Treat behavior preservation as a claim that requires a baseline and repeated evidence.

## Define Observable Behavior

Include public APIs and types, serialized and database representations, errors, logs and events, generated output, filesystem effects, performance budgets, deployment compatibility, and user-visible behavior that callers rely on.

## Refactor Loop

1. Inspect repository instructions, worktree status, callers, tests, and generated-code boundaries. Preserve unrelated work.
2. Establish a green focused baseline. If coverage is thin, add characterization tests that capture current behavior before changing structure.
3. Make one mechanical step: rename, extract, move, or deduplicate.
4. Update direct callers and search for dynamic references in configuration, reflection, templates, serialization, migrations, documentation, and build tooling.
5. Run the smallest relevant checks after each step and expand to the full affected suite at stable checkpoints.
6. Keep behavior fixes and compatibility migrations outside the refactor. Pause and reclassify the task when a behavior change becomes necessary.
7. Use logical working-tree checkpoints. Do not create branches or commits unless the user explicitly requests them.

## Completion Evidence

- Show that focused and relevant suites remain green against the baseline.
- Confirm snapshots, golden files, generated output, and public contracts did not change unless explicitly approved.
- Search for obsolete names and paths after moves or renames.
- Review the final diff for a clear structural improvement and no hidden behavior change.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.