Refactor Engine

Refactor Engine is a skill for Claude Code, Codex 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 CodeCodex

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.

agentmods
npx agentmods add skills/razaib-khan/forgeweave/refactor-engine
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, 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 Engine

README.md
[![agentmods](https://agentmods.dev/badge/skills/razaib-khan/forgeweave/refactor-engine.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00023 $0.00607
Opus 5 $0.00012 $0.00303
Sonnet 5 $0.00005 $0.00121
Haiku 4.5 $0.00002 $0.00061

Measured 4d ago against content hash de34351916f0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 4d 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. 4d 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 2mo ago), licensed MIT. It adds 23 tokens to every session and 607 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

performant-code

Writing efficient code that handles large data and tight constraints.

vstorm-co/pydantic-deepagents · 14 tokens

refactor

Refactor code to improve structure and maintainability.

vstorm-co/pydantic-deepagents · 12 tokens

absolute-simplify

Use when the user wants to simplify, clean up, refactor, tidy, or refine code — their staged/unstaged git changes or a target file/path. Reduces complexity, flattens nesting, removes redundancy and dead code, scores each change by value (holding low-value churn), then runs tests to prove nothing broke. Invoke on…

maddhruv/absolute · 178 tokens

code-refactor

Implement safe, behavior-preserving code refactors after inspecting the existing project. Use when the user asks to refactor, split large files, extract methods, reduce duplication, rename, clean dead code, or says 重构代码, 拆分模块, 提取方法, 优化命名, 优化注释, 删除未调用代码. For broad requests, plan safe slices and wait for approval; for…

bahayonghang/my-ai-cli-toolkit · 97 tokens

agenthub

Browse, create, and complete tasks on Clawsy AgentHub — a distributed task platform for AI agents. Create tasks from GitHub repos, PDF/DOCX/PPTX/audio URLs, or plain text. Use custom LLM validation, earn karma. Categories: content, data, research, creative.

citedy/adclaw · 65 tokens

deep-clean

Full-spectrum consolidation of AI agent configuration files. Goes beyond memory-only dream skills: audits and optimizes context files (AGENTS.md/AGENTS.md/GEMINI.md/.cursorrules), rules, skills, and memory. Detects stale references, dead file paths, duplicated rules, stack mismatches, contradictions, vague directives…

opencue/cuecards · 87 tokens