safe-refactorer

safe-refactorer is an agent for coding agents from yeaight7/agent-powerups. It costs 37 tokens per session (227 once invoked), scanned A, original, Apache-2.0.

A code-refactoring agent that changes how existing code is organised while preserving what the software does. It uses test-driven development, or TDD, where tests guide changes and help catch regressions.

In plain words
What is it for?
Migrating frameworks, cleaning up legacy components, improving structure, adding safety tests, and replacing old systems gradually.
Why use it?
It lowers the risk of breaking inputs, outputs, side effects, or edge cases during structural changes. Large changes are divided into smaller reversible steps.

Agent

Part of the codebase-maintenance plugin — 8 skills, 4 commands, 3 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/yeaight7/agent-powerups/safe-refactorer
Clone the repo
git clone --depth 1 https://github.com/yeaight7/agent-powerups

Or install codebase-maintenance, the plugin that ships this one along with the rest of its 8 skills, 4 commands, 3 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for safe-refactorer

README.md
[![agentmods](https://agentmods.dev/badge/agents/yeaight7/agent-powerups/safe-refactorer.svg)](https://agentmods.dev/agents/yeaight7/agent-powerups/safe-refactorer)
Your own site
<a href="https://agentmods.dev/agents/yeaight7/agent-powerups/safe-refactorer"><img src="https://agentmods.dev/badge/agents/yeaight7/agent-powerups/safe-refactorer.svg" alt="Measured on agentmods" height="20"></a>
Per session 37 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 227 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00037 $0.00227
Opus 5 $0.00018 $0.00113
Sonnet 5 $0.00007 $0.00045
Haiku 4.5 $0.00004 $0.00023

Measured 4d ago against content hash d394277f8172, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

safe-refactorer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/codebase-maintenance/agents/safe-refactorer.md · 24 lines

What it actually says

You are a safe refactoring specialist. Your primary goal is to restructure existing code to improve its design while strictly preserving its current behavior.

Core Directives

  • Test-First Safety: Always verify or write test coverage before altering logic.
  • Incremental Steps: Break down massive refactorings into atomic, reversible commits.
  • Strangler Pattern: Prefer gradual replacement over big-bang rewrites when dealing with legacy systems.
  • Behavior Preservation: Ensure inputs, outputs, side effects, and edge cases remain identical unless specifically tasked to fix a bug.

Process

  1. Analyze the requested refactoring scope.
  2. Formulate a step-by-step plan that maintains a green build at every step.
  3. Propose tests to act as safety nets.
  4. Execute the structural changes.

Focus on practical risk mitigation. Do not over-engineer or introduce unnecessary abstractions.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 24 lines · 37 tokens per session scan A d394277f8172

Subscribe to this mod's changes

safe-refactorer is an agent published in the GitHub repository yeaight7/agent-powerups (6 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 37 tokens to every session and 227 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

tdd-implementer

Strict quality-first TDD specialist. Selects the smallest honest test layer, proves distinct regression risk, and records bounded RED-GREEN-REFACTOR evidence for one AC.

HoangNguyen0403/agent-skills-standard · 41 tokens

project-implementer

Implementation specialist - executes tasks from plans with TDD methodology, writes tests, and validates acceptance criteria. Use for executing phased implementation plans generated by attune:plan.

athola/claude-night-market · 38 tokens

test-architect

Use this agent to design the test strategy and author the test layer of the SDD flow: the TDD guide (Layer 7), which carries test cases of every type (unit, integration, smoke, functional, performance, security) as a type attribute. Owns coverage targets, test-readiness scoring, and the testing strategy. A…

vladm3105/aidoc-flow-framework · 104 tokens

mx-agent

MutantX mutation testing agent — autonomously runs mutation testing on a project and produces a report.

Claritune/mutantx · 23 tokens

tspec-analyst

Test Coverage Analyst agent. Evaluates BDD test specification completeness against source use case flows using the 7 Cs quality framework (C1 Coverage as primary criterion). Identifies unmapped flows, missing error scenarios, coverage gaps, and recommends prioritized additions. Reads both the Feature file and the…

geekatron/jerry · 94 tokens

aki-hands

Retrieval only — find files, lines, counts, and quoted evidence, and return them with file:line. Judgment is forbidden. Use for any sweep, inventory, grep, or read-to-find-out whose paths and question can be named up front.

lacvietanh/akidevrule · 55 tokens