refactor-safely

refactor-safely is a skill for Claude Code, Codex from hamakyo/okf-skills. It costs 52 tokens per session (515 once invoked), scanned A, original, MIT.

A set of instructions for reorganizing code while keeping its behavior unchanged. Refactoring means improving structure, names, or duplication without changing what users or other code see.

In plain words
What is it for?
Use it to simplify control flow, extract helpers, improve naming, reduce duplication, or prepare code for a later change.
Why use it?
It guides small, safer maintenance changes and protects public interfaces, data formats, and user-visible behavior.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to simplify control flow, extract helpers, improve naming, reduce duplication, or prepare code for a later change.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hamakyo/okf-skills/refactor-safely
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.

Any agent
npx skills add hamakyo/okf-skills --skill refactor-safely
Clone the repo
git clone --depth 1 https://github.com/hamakyo/okf-skills

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/hamakyo/okf-skills/refactor-safely/github.svg)](https://agentmods.dev/skills/hamakyo/okf-skills/refactor-safely)
Your own site
<a href="https://agentmods.dev/skills/hamakyo/okf-skills/refactor-safely"><img src="https://agentmods.dev/badge/skills/hamakyo/okf-skills/refactor-safely/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactor-safely

Your own site · 80×15
<a href="https://agentmods.dev/skills/hamakyo/okf-skills/refactor-safely"><img src="https://agentmods.dev/badge/skills/hamakyo/okf-skills/refactor-safely.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 515 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00052 $0.00515
Opus 5.5 $0.00021 $0.00206
Sonnet 5.5 $0.00010 $0.00103
Haiku 4.5 $0.00005 $0.00052

Measured 1mo ago against content hash aad0a3bbcbbb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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 · 76 lines

How it starts

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

Refactor Safely

When to use

Use this Skill when:

  • Reducing duplication.
  • Improving naming or structure.
  • Extracting helpers or simplifying control flow.
  • Preparing code for a later change while preserving behavior.

Do not use this Skill when:

  • User-visible behavior must change.
  • Public APIs, schemas, migrations, or data contracts must change.
  • The code is not covered enough to safely refactor and no validation plan exists.

Inputs

  • Target files, modules, or code smell.
  • Reason for the refactor.
  • Available tests or validation commands.
  • Relevant OKF docs when architecture or contracts are documented.

Required context

Before editing, read:

  • Existing code around the target area.
  • Tests that cover the behavior.
  • Relevant OKF architecture, data, or feature documents.
  • Public API, schema, or integration boundaries.

Workflow

  1. Define the behavior that must remain unchanged.
  2. Identify public APIs, schemas, data contracts, and external behavior that must not move.
  3. Run or identify baseline tests when available.
  4. Make the smallest meaningful structural change.
  5. Avoid mixing formatting-only changes with logic movement unless the repository already does so.
  6. Run targeted tests.
  7. Compare the diff to confirm behavior was preserved.
  8. If a behavior change becomes necessary, stop and switch to implement-feature or ask for confirmation.

Guardrails

  • Do not change behavior intentionally or accidentally.
  • Do not change public APIs, schemas, migrations, serialized formats, or user-visible text without explicit approval.
  • Do not perform broad cleanup outside the requested area.
  • Do not introduce new dependencies unless explicitly justified.
  • Do not remove tests to simplify the refactor.
  • Do not update OKF unless architecture, boundaries, or maintainership knowledge changed.

Completion checklist

  • Behavior to preserve was identified.
  • Public APIs and schemas were checked.
  • Diff is small and scoped.
  • Tests or validation were run.
  • Any residual risk is stated.

Read the full file on GitHub · 76 lines

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. 1mo ago First seen · 76 lines · 52 tokens per session scan A aad0a3bbcbbb

Subscribe to this mod's changes

refactor-safely is a skill published in the GitHub repository hamakyo/okf-skills (2 stars, last pushed 1mo ago), licensed MIT. It adds 52 tokens to every session and 515 once invoked, about $0.0002 per session on Opus 5.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

ai-slop-cleaner

Clean AI-generated code slop with a regression-safe, deletion-first workflow and optional reviewer-only mode.

Yeachan-Heo/oh-my-claudecode · 25 tokens

debug

Diagnose the current OMC session or repo state using logs, traces, state, and focused reproduction.

Yeachan-Heo/oh-my-claudecode · 22 tokens

hns-lsel-curator

Local Self-Evolution Loop (LSEL) curator — the CLUSTER + drain engine for the GOOS-local PROPOSE→APPLY seam closure (SPEC-LSEL-LOCAL-EVOLUTION-001). Companion-offset drain of .moai/lessons-inbox.jsonl with a drain-side severity filter that drops the 65% Bash-timeout/sandbox noise, eventkey clustering with a frequency…

modu-ai/moai-adk · 135 tokens

moai-lane-watchdog

One lane stall watchdog iteration: measure lane progress on three channels, classify the stall cause, apply the remedy or resolve the judgment through the decision ladder — instead of waiting on a reply — then record the outcome and report. Reads the unified --auto doctrine at…

modu-ai/moai-adk · 86 tokens

five-whys

Finds the root cause of a bug, failure or recurring problem by asking "why" until the answer is a cause you can fix. Use when the user asks why something keeps happening, or wants the root cause rather than a quick fix.

wesammustafa/Claude-Code-Everything-You-Need-to-Know · 53 tokens

moai-workflow-loop

Ralph Engine - Automated feedback loop with LSP diagnostics and AST-grep integration for continuous code quality improvement. Use when implementing error-driven development, automated fixing, or continuous quality validation workflows.

modu-ai/moai-adk · 44 tokens