{{REPO}}-refactor

{{REPO}}-refactor is a skill for Claude Code from steph-dove/klaussy-agents. It costs 52 tokens per session (1,214 once invoked), scanned A, a copy of fastapi-refactor, MIT.

A refactoring workflow for reorganising code while preserving exactly what it does. It establishes a passing test baseline and makes changes in small, verifiable steps.

In plain words
What is it for?
Use it to restructure tested code, move responsibilities, or improve organisation without changing its external behavior.
Why use it?
It helps catch accidental behavior changes during structural cleanup. Existing failures stop the refactor before they can be mistaken for newly introduced problems.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions CLAUDE.md.

Part of the klaussy plugin — 79 skills, 3 hooks, 1 MCP server shipped together

Good fit Use it to restructure tested code, move responsibilities, or improve organisation without changing its external behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/steph-dove/klaussy-agents/refactor
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 steph-dove/klaussy-agents --skill refactor
Clone the repo
git clone --depth 1 https://github.com/steph-dove/klaussy-agents

Made for: Claude Code.

Or install klaussy, the plugin that ships this one along with the rest of its 79 skills, 3 hooks, 1 MCP server.

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 {{REPO}}-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/steph-dove/klaussy-agents/refactor/github.svg)](https://agentmods.dev/skills/steph-dove/klaussy-agents/refactor)
Your own site
<a href="https://agentmods.dev/skills/steph-dove/klaussy-agents/refactor"><img src="https://agentmods.dev/badge/skills/steph-dove/klaussy-agents/refactor/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 {{REPO}}-refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/steph-dove/klaussy-agents/refactor"><img src="https://agentmods.dev/badge/skills/steph-dove/klaussy-agents/refactor.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 1,214 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 97% copy Near-identical to another mod 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.01214
Opus 5 $0.00026 $0.00607
Sonnet 5 $0.00010 $0.00243
Haiku 4.5 $0.00005 $0.00121

Measured 6d ago against content hash 0029f196c163, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

{{REPO}}-refactor 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 6d 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.

Origin

This is a copy

97% identical to fastapi-refactor — 3 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

src/klaussy/templates/skills/refactor/SKILL.md · 89 lines

How it starts

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

Refactor the code the user described. The goal is to change structure while preserving behavior exactly. Do NOT change what the code does — only how it's organized.


Phase 1: Establish the Safety Net

Before changing any code, confirm you have tests that cover the current behavior.

  1. Read CLAUDE.md for project structure, test commands, and conventions.
  2. Read any .claude/rules/*.md whose paths: glob matches the area being refactored — they encode the conventions the moved code must continue to obey.
  3. Run the existing test suite. Record the results — every test must pass before you start. If tests are failing already, stop and report that. Do not refactor code that doesn't have a passing baseline.
  4. Assess coverage of the code you plan to change. Read the existing tests for the modules involved. If a function you're restructuring has no tests:
    • Write tests for its current behavior first.
    • Run them to confirm they pass.
    • These are your regression guardrails — they prove the refactor didn't break anything.

Phase 2: Understand the Current Code

Read the code you're refactoring in full. The three checks below are independent — issue them as a single batch of parallel tool calls, not sequentially:

  1. What it does — the inputs, outputs, side effects, and edge cases. Read the file(s) in full.
  2. Who calls it — grep for callers across the whole repo. Every caller is a contract you must preserve.
  3. What depends on its interface — function signatures, return types, exceptions thrown, event emissions. Grep for type/import references too. These are the things you cannot change without updating all consumers.

Phase 3: Plan the Refactor

Design the target structure before editing.

  1. Describe the structural change — what moves where, what gets renamed, what gets split or merged.
  2. List what must NOT change — public interfaces, return values, side effects, error behavior. Be explicit.
  3. Plan incremental steps. Break the refactor into the smallest possible moves that each leave the code in a working state. Never change behavior and structure in the same step. For example:
    • Step 1: Extract a function (tests still pass).
    • Step 2: Move the function to a new module (tests still pass).
    • Step 3: Update callers to use the new location (tests still pass).

Read the full file on GitHub · 89 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. 6d ago First seen · 89 lines · 0 tokens per session scan A 0029f196c163

Subscribe to this mod's changes

{{REPO}}-refactor is a skill published in the GitHub repository steph-dove/klaussy-agents (16 stars, last pushed 13d ago), licensed MIT. It adds 52 tokens to every session and 1,214 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to fastapi-refactor, differing in 3 lines, and is treated as a copy.