safe-refactoring

safe-refactoring is a skill for Claude Code, Codex from New1Direction/korgex. It costs 16 tokens per session (251 once invoked), scanned A, original, MIT.

A step-by-step method for improving code structure while keeping its behaviour unchanged. Refactoring means reorganizing code without changing what it does.

In plain words
What is it for?
It helps rename, extract, inline, or move code safely, add tests that capture existing behaviour, keep changes focused, and create small reversible commits.
Why use it?
It limits accidental behaviour changes by using tests, making one structural change at a time, and checking that tests remain green.

Skill for Claude CodeCodex

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/new1direction/korgex/safe-refactoring
Any agent
npx skills add New1Direction/korgex --skill safe-refactoring
Clone the repo
git clone --depth 1 https://github.com/New1Direction/korgex

Made for: Claude Code, Codex.

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-refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/new1direction/korgex/safe-refactoring.svg)](https://agentmods.dev/skills/new1direction/korgex/safe-refactoring)
Your own site
<a href="https://agentmods.dev/skills/new1direction/korgex/safe-refactoring"><img src="https://agentmods.dev/badge/skills/new1direction/korgex/safe-refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 251 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.00016 $0.00251
Opus 5 $0.00008 $0.00125
Sonnet 5 $0.00003 $0.00050
Haiku 4.5 $0.00002 $0.00025

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

Security

Grade A, and why

safe-refactoring 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.

src/skills_builtin/safe-refactoring/SKILL.md · 23 lines

What it actually says

Refactoring is improving structure while behaviour stays identical. If behaviour changes, that's a feature/fix — do it separately, with its own test.

  1. Pin behaviour first. Make sure the code is covered by tests. If it isn't, add characterization tests that capture current behaviour before you touch it.
  2. One transformation at a time. Rename, extract, inline, move — a single kind of change per step. Don't mix a rename with a logic tweak.
  3. Stay green. Run the tests after each step. If they go red, the step changed behaviour — revert it and redo it smaller.
  4. Don't expand scope. Resist "while I'm here" rewrites. Keep the diff about the one structural improvement you set out to make.
  5. Commit in small steps so each is independently revertable.

Red flags: tests you had to change to stay green (you altered behaviour); a giant diff touching unrelated code; no tests before you started.

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 · 23 lines · 16 tokens per session scan A 5322840ce1bb

Subscribe to this mod's changes

safe-refactoring is a skill published in the GitHub repository New1Direction/korgex (5 stars, last pushed 2mo ago), licensed MIT. It adds 16 tokens to every session and 251 once invoked, about $0.0001 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.