refactor-engineer

refactor-engineer is a skill for Claude Code, Codex from Kshitijpalsinghtomar/depth-skills. It costs 41 tokens per session (3,208 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 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,208 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.00041 $0.03208
Opus 5.5 $0.00016 $0.01283
Sonnet 5.5 $0.00008 $0.00642
Haiku 4.5 $0.00004 $0.00321

Measured 23d ago against content hash 415d758b84c7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 23d 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 · 404 lines

How it starts

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

REFACTOR-ENGINEER v2.0 — Behavior-Preserving Transformation (Premium)

Mathematical Compliance: This skill implements the DEPTH-MATHEMATICS specification. It computes and outputs ADS phase activation, CEI components, SI components, cognitive traces (refactor safety calculus, refactor ), and verifies Gates V1, V3, V5. It formalizes refactoring as a measurable calculus.

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.

New in v2.0: Mathematical depth metrics, refactor safety calculus, refactor , recursive self-audit, verification gates.


The Protocol

0 — PARAMETERIZE: Read Thinking Parameters

Read thinking_parameters:

  • require_safety_calculus (default true) — compute refactor safety calculus
  • require_refactor_ (default true) — issue refactor
  • recursion_depth (default 1) — recursive self-audit rounds

1 — REFACTOR SAFETY CALCULUS (if require_safety_calculus = true)

NEW IN v2.0 — Formal calculus for refactor safety.

REFACTOR SAFETY CALCULUS
────────────────────────────────────────
Characterization Coverage:
  Functions/Methods Characterized: [N/N]
  Inputs Documented: [YES/NO]
  Outputs Documented: [YES/NO]
  Side Effects Documented: [YES/NO]
  Edge Cases Covered: [YES/NO]
  Characterization Score: [0.0-1.0]

Test Suite Health:
  Tests Exist: [YES/NO]
  Tests Pass: [YES/NO]
  Coverage: [XX%]
  Edge Case Coverage: [XX%]
  Mutation Score: [XX% — if available]
  Test Health Score: [0.0-1.0]

Structural Goal Clarity:
  Problem Defined: [YES/NO — duplication/coupling/complexity/naming]
  "Better" Defined: [YES/NO — specific, not "cleaner"]
  Minimum Change: [YES/NO]
  Goal Clarity Score: [0.0-1.0]

Step Granularity:
  Max Step Size: [small / medium / large]
  Each Step Keeps Tests Green: [YES/NO]
  Commit Per Step: [YES/NO]
  Structural/Behavioral Separation: [YES/NO]
  Granularity Score: [0.0-1.0]

Refactor Safety = (Characterization × 0.3) + (Test_Health × 0.3) + (Goal_Clarity × 0.2) + (Granularity × 0.2) = [0.0-1.0]

Thresholds:
  ≥ 0.8: SAFE TO REFACTOR
  0.5-0.8: CAUTION — address gaps first
  < 0.5: UNSAFE — do not refactor until gaps addressed
────────────────────────────────────────

Read the full file on GitHub · 404 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. 23d ago Changed · +345 lines · +18 tokens per session 415d758b84c7
  2. 1mo 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 (5 stars, last pushed 12d ago), licensed MIT. It adds 41 tokens to every session and 3,208 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

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

verification-quality

Truth scoring, code-quality verification, and automatic rollback with a high accuracy threshold. Use when validating agent output before it ships, gating changes on quality, or adding a verify-and-rollback safety loop.

frankxai/claude-skills-library · 43 tokens

refactoring-workflow

Improve the structure of existing code without changing its behaviour, in small verified steps under a green test suite. Use when the user asks to refactor, clean up, restructure or simplify code, wants to reduce duplication or coupling, is preparing a codebase for a feature it cannot currently accommodate, or when…

personamanagmentlayer/pcl · 83 tokens

Behavior-Structure Separation 振る舞い変更と構造変更の分離・外部挙動維持

A code review check that separates refactoring—changing code structure without changing its behavior—from feature changes that intentionally alter what the software does. It also checks whether tests, type checks, or other evidence support the claim that behavior stayed the same.

s977043/river-review · 211 tokens

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

qa-advisor

You are a senior software quality engineer conducting a systematic audit of a codebase. Your mandate is to surface real risks — not lint warnings, not style preferences. You evaluate five dimensions: test quality, maintainability, security, reliability/scalability, and delivery health. You are direct, specific, and…

wavect/ai-skills · 3 tokens