Refactor Engine

Refactor Engine is a skill for Claude Code from Razaib-khan/ForgeWeave. It costs 23 tokens per session (607 once invoked), scanned A, original, MIT.

A guide for reorganizing existing code while keeping its observable behavior unchanged. Refactoring means improving code structure, naming, and maintainability without adding a new feature.

In plain words
What is it for?
Use it to improve a file, module, or code area for clarity, performance, maintainability, or all three, while recording what changed and what must not change.
Why use it?
It reduces duplication, unclear organization, long functions, dead code, and avoidable performance problems. Existing tests are used to check that behavior remains the same.

Skill for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions OpenCode.

Good fit Use it to improve a file, module, or code area for clarity, performance, maintainability, or all three, while recording what changed and what must not change.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/razaib-khan/forgeweave/refactor-engine
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 Razaib-khan/ForgeWeave --skill refactor-engine
Clone the repo
git clone --depth 1 https://github.com/Razaib-khan/ForgeWeave

Made for: Claude Code.

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 Engine

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/razaib-khan/forgeweave/refactor-engine"><img src="https://agentmods.dev/badge/skills/razaib-khan/forgeweave/refactor-engine.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 607 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.00607
Opus 5.5 $0.00009 $0.00243
Sonnet 5.5 $0.00005 $0.00121
Haiku 4.5 $0.00002 $0.00061

Measured 1mo ago against content hash de34351916f0, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

Refactor Engine 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.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/extract_function.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/forgeweave/templates/claude/.claude/skills/refactor-engine/SKILL.md · 84 lines

How it starts

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

Refactor Engine

Purpose

Restructure existing code to improve readability, performance, and maintainability while preserving exact external behavior. Every refactor is verified by ensuring existing tests continue to pass and no observable behavior changes.

When to Use

  • Code has duplicated logic that should be extracted
  • A function or module is too long or does too many things
  • Naming is unclear or inconsistent with project conventions
  • Performance can be improved by algorithmic changes
  • Dead code, commented-out code, or unused imports need removal

When Not to Use

  • The code has a bug — use debugger first
  • New features need to be added — use code-builder
  • The code works fine and doesn't need changes

Inputs

Input Type Required Description
target string Yes File, module, or code area to refactor
goal enum Yes clarity, performance, maintainability, or all
constraints string No What must NOT change (public API, performance bounds)

Expected Outputs

Output Description
Refactored code Restructured code preserving external behavior
Diff summary What changed and why
Verification Test results confirming no behavior change

Exact Workflow Steps

  1. Read and understand the target code fully
  2. Run existing tests to establish baseline
  3. Identify refactoring opportunities (duplication, complexity, naming)
  4. Apply one refactoring at a time (small, atomic changes)
  5. Run tests after each change to confirm no regression
  6. Repeat until all planned refactorings are applied

Required Checks

  • All existing tests pass before and after
  • No public API changed unless explicitly requested
  • Each change is atomic (one concern per change)
  • No dead code or debug artifacts left behind

Failure Modes

Failure Condition Response
Test fails after refactor Revert last change and re-approach differently
Refactor touches too many files Break into smaller, focused refactors
Goal is unclear Ask for specific examples of what to improve

Read the full file on GitHub · 84 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 84 lines · 23 tokens per session scan A de34351916f0

Subscribe to this mod's changes

Refactor Engine is a skill published in the GitHub repository Razaib-khan/ForgeWeave (1 stars, last pushed 4mo ago), licensed MIT. It adds 23 tokens to every session and 607 once invoked, about $0.0001 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.