refactor-engineer

refactor-engineer is a skill for Claude Code, Codex from Kshitijpalsinghtomar/depth-skills. It costs 23 tokens per session (536 once invoked), scanned A, original, MIT.

A method for changing code structure while keeping its existing behaviour unchanged.

In plain words
What is it for?
Use it to document existing behaviour, add characterization tests when needed, and make gradual structural improvements.
Why use it?
It reduces the risk of breaking software during refactoring by checking current behaviour first and keeping tests passing after small changes.

Skill for Claude CodeCodex

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

Good fit Use it to document existing behaviour, add characterization tests when needed, and make gradual structural improvements.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/kshitijpalsinghtomar/depth-skills/refactor-engineer/github.svg)](https://agentmods.dev/skills/kshitijpalsinghtomar/depth-skills/refactor-engineer)
Your own site
<a href="https://agentmods.dev/skills/kshitijpalsinghtomar/depth-skills/refactor-engineer"><img src="https://agentmods.dev/badge/skills/kshitijpalsinghtomar/depth-skills/refactor-engineer/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-engineer

Your own site · 80×15
<a href="https://agentmods.dev/skills/kshitijpalsinghtomar/depth-skills/refactor-engineer"><img src="https://agentmods.dev/badge/skills/kshitijpalsinghtomar/depth-skills/refactor-engineer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 23 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 536 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.00023 $0.00536
Opus 5 $0.00012 $0.00268
Sonnet 5 $0.00005 $0.00107
Haiku 4.5 $0.00002 $0.00054

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

Security

Grade A, and why

refactor-engineer 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 9d 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-engineer/SKILL.md · 59 lines

What it actually says

Refactor Engineer

You are a refactor engineer. You improve code structure without changing behavior. The operative word is "without."

The Core Shift

Characterize before changing. The test suite is the safety net. No net, no refactor.

Refactoring is not rewriting. Rewriting changes behavior. Refactoring changes structure while preserving behavior exactly. The distinction is survival-critical.

The Protocol

1 — Characterize Current Behavior

  • What does this code actually do? (Not what it should do — what it DOES)
  • What tests exist? Do they pass? What do they cover?
  • What are the inputs, outputs, and side effects?
  • If no tests exist: write characterization tests FIRST, then refactor

2 — Define the Structural Goal

  • What structural problem are you fixing? (Duplication? Coupling? Complexity? Naming?)
  • What does "better" look like? (Be specific — not "cleaner")
  • What is the minimum change that achieves the structural goal?

3 — Small Steps, Continuous Green

  • Each step must keep tests passing
  • If tests break, the step was too large — undo and split
  • Commit after each successful step
  • Never combine structural changes with behavioral changes in the same commit

4 — Verify Behavior Preservation

  • Run the full test suite after each step
  • Pay special attention to edge cases and error paths
  • If test coverage was added in Step 1, it pays off here

5 — Common Refactoring Moves

  • Extract: pull repeated code into a named function
  • Inline: replace indirection that adds complexity without value
  • Rename: make names match what the code actually does
  • Move: put code where it belongs (closer to its data or its consumers)
  • Simplify conditionals: reduce nested if/else into clear paths

Anti-Patterns

  • Refactoring and adding features in the same step
  • Refactoring without tests (flying without instruments)
  • "While I'm in here..." scope creep
  • Renaming for aesthetics without improving clarity
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. 9d ago First seen · 59 lines · 23 tokens per session scan A a386a1d35139

Subscribe to this mod's changes

refactor-engineer is a skill published in the GitHub repository Kshitijpalsinghtomar/depth-skills (4 stars, last pushed 3mo ago), licensed MIT. It adds 23 tokens to every session and 536 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.

Related

Other skills, from other repositories

code-consolidation

This skill should be used when the user asks to "find duplicated code", "map responsibilities", "consolidate code", "find code sprawl", "analyze duplication", "create consolidation plan", or mentions "código duplicado", "responsabilidades espalhadas", "consolidar". Analyzes codebases to identify scattered…

parisgroup-ai/imersao-ia-setup · 79 tokens

RubyCritic Code Quality Analysis

Analyze Ruby and Rails code quality with RubyCritic. Identifies code smells, complexity issues, and refactoring opportunities. Provides detailed metrics, scores files A-F, compares branches, and prioritizes high-churn problem areas. Use when analyzing Ruby code quality, reviewing PRs, or identifying technical debt.

esparkman/claude-rubycritic-skill · 68 tokens

simplify-codebase

Simplification audit or authorized codebase simplification whose stated objective is to remove accidental complexity. Use for evidence-backed deletion or consolidation of dead code, duplicate state, redundant APIs or layers, ownerless abstractions, obsolete compatibility or design records, and over-engineering in any…

tt-a1i/simplify-codebase · 93 tokens

software-code-refactoring

Improve production code quality while preserving all existing test behavior. Commonly used for the Refactor phase of TDD red-green-refactor, but applicable to any codebase with tests. Use when production code works but needs cleanup — reducing duplication, improving naming, simplifying complexity, aligning with…

stencila/stencila · 102 tokens

pr-review

AUTHOR SKILL (internal to microsoft/aspire-skills). Reviews pull requests into this repo for problems only — bugs, regressions, missing eval coverage, frontmatter or routing damage, plugin-manifest drift, hook safety, and other concrete issues. Drives a six-step workflow: identify the PR, ensure the branch is…

microsoft/aspire-skills · 241 tokens

review-pr

Multi-agent PR review with four modes (review, re-review, self-review, address-feedback) - spawns parallel subagents, saves diff to /tmp for context efficiency, supports file exclusion patterns.

hoblin/claude-ruby-marketplace · 39 tokens