refactor-safely

refactor-safely is a skill for Claude Code, Codex from Drizzy07x/Skillquiver. It costs 36 tokens per session (2,421 once invoked), scanned A, original, MIT.

A method for reorganising existing code while keeping its observable behaviour unchanged. When tests are missing, it recommends first adding tests that record what the current code does.

In plain words
What is it for?
It helps restructure messy, nested, duplicated, or poorly tested code, while limiting the change to a defined scope and checking the result.
Why use it?
It reduces the risk of breaking callers or undocumented behaviour while cleaning up difficult or legacy code.

Skill for Claude CodeCodex

Part of the skillquiver plugin — 24 skills 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 skills/drizzy07x/skillquiver/refactor-safely
Any agent
npx skills add Drizzy07x/Skillquiver --skill refactor-safely
Clone the repo
git clone --depth 1 https://github.com/Drizzy07x/Skillquiver

Made for: Claude Code, Codex.

Or install skillquiver, the plugin that ships this one along with the rest of its 24 skills.

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 refactor-safely

README.md
[![agentmods](https://agentmods.dev/badge/skills/drizzy07x/skillquiver/refactor-safely.svg)](https://agentmods.dev/skills/drizzy07x/skillquiver/refactor-safely)
Your own site
<a href="https://agentmods.dev/skills/drizzy07x/skillquiver/refactor-safely"><img src="https://agentmods.dev/badge/skills/drizzy07x/skillquiver/refactor-safely.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,421 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.00036 $0.02421
Opus 5 $0.00018 $0.01210
Sonnet 5 $0.00007 $0.00484
Haiku 4.5 $0.00004 $0.00242

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

Security

Grade A, and why

refactor-safely 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.

skills/refactor-safely/SKILL.md · 100 lines

How it starts

The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Refactor Safely

Change how code reads without changing what it does, and land changes in untested code without breaking callers nobody can enumerate. solve-efficiently decides what to build; this skill governs how existing code is reshaped. Bug hunting belongs to diagnose-systematically.

The non-negotiable rule

Never change observable behavior while refactoring. When no test covers the code, pin current behavior with a characterization test first, or state in the report that the change is unverified and why. Never put a behavior change and a refactor in the same commit.

Pick the mode

  • Cleanup: code works, reading it is painful, coverage exists or is cheap to pin. Follow Clean refactoring.
  • Legacy change: a requested change must land where coverage is absent and behavior is defined only by what the code currently does. Follow the Legacy protocol - the net comes first, the change second. Clean up afterward inside the net, only if asked.

Clean refactoring

  1. Scope. Name the files in scope: those already touched this session plus their direct callers. Do not expand the blast radius.
  2. Measure before judging. Read the code and record a baseline: function lengths, parameter counts, nesting depth, branch counts, file length, long lines, commented-out code, unresolved markers, duplication. Add what mechanical checks cannot see: wrong names, leaked abstractions, temporal coupling, boolean flag arguments, misplaced responsibility. If the repo records accepted violations, read the recorded reason before re-fixing what someone decided to keep.
  3. Rank by payoff.
Priority Condition
P0 Misleading name, or duplicated logic that already diverged
P1 Function mixing decision + side effect + formatting
P2 Nesting depth > 3, or function > 20 lines
P3 Cosmetic: ordering, spacing, comment cleanup

Fix P0 and P1. Fix P2 only where it makes P0 or P1 possible. Skip P3 unless a full pass was requested. State what you deliberately left alone and why; an honest "not worth it" is a valid deliverable.

Read the full file on GitHub · 100 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 100 lines · 36 tokens per session scan A fc5e596496bb

Subscribe to this mod's changes

refactor-safely is a skill published in the GitHub repository Drizzy07x/Skillquiver (2 stars, last pushed 12d ago), licensed MIT. It adds 36 tokens to every session and 2,421 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 skills, from other repositories

create-site

Creates a new Power Pages code site (SPA) using React, Angular, Vue, or Astro. Guides through the full process from initial concept to deployed site: requirements discovery, scaffolding, component planning, design, implementation, validation, and deployment. Use when the user wants to create, build, or scaffold a new…

microsoft/power-platform-skills · 73 tokens

google-ads-audit

Google Ads account audit and business context setup. Run this first — it gathers business information, analyzes account health, and saves context that all other ads skills reuse. Trigger on "audit my ads", "ads audit", "set up my ads", "onboard", "account overview", "how's my account", "ads health check", "what should…

nowork-studio/notfair-plugin · 114 tokens

review

5-pass structured code review — correctness, security, performance, readability, consistency.

SethGammon/Citadel · 17 tokens

alive:system-upgrade

Upgrade ALIVE to the current version. Handles v1/v2/v3.x source states, multi-surface aware (alive-mcp / Hermes / Codex), retroactive version detection, partial-failure resume, dry-run previews, and rollback inspection.

alivecontext/alive · 57 tokens

codex-test-gen

Generate unit tests for specified functions using Codex MCP.

sd0xdev/sd0x-harness · 15 tokens

ensure-pipelines-host

Ensures the tenant has a usable Power Platform Pipelines host environment before any pipeline operation runs. Detects host state via the same resolution order as the Power Apps UI (org-db setting → BAP env metadata → default-custom-host setting); if any existing host (Platform or Custom) is found, uses it. If no host…

microsoft/power-platform-skills · 222 tokens