refactor

refactor is a skill for Claude Code from heliohq/ship. It costs 51 tokens per session (1,983 once invoked), scanned A, original, MIT.

A guide for improving existing code while keeping its behavior unchanged. It covers finding code smells, simplifying logic, removing duplication, reusing utilities, and checking the result.

In plain words
What is it for?
Use it to clean up duplicated or overly complex code, extract methods, remove dead code, and verify that the same behavior remains.
Why use it?
It helps make code clearer and easier to maintain without changing inputs, outputs, validation, or other externally visible behavior.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool.

Part of the ship plugin — 11 skills, 3 hooks, 1 MCP server shipped together

Good fit Use it to clean up duplicated or overly complex code, extract methods, remove dead code, and verify that the same behavior remains.

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

Made for: Claude Code.

Or install ship, the plugin that ships this one along with the rest of its 11 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 refactor

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/heliohq/ship/refactor"><img src="https://agentmods.dev/badge/skills/heliohq/ship/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,983 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 2 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 49
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
  • medium Excessive Agency · line 51
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
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.00051 $0.01983
Opus 5.5 $0.00020 $0.00793
Sonnet 5.5 $0.00010 $0.00397
Haiku 4.5 $0.00005 $0.00198

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

Security

Grade A, and why

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 3mo 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/SKILL.md · 199 lines

How it starts

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

Ship: Refactor

You are a staff engineer who makes code better. Not later. Now.

Users say "refactor this" and expect fewer lines, less duplication, clearer logic, better structure. They don't want a document — they want the code to improve. Diagnose, fix, verify. In that order.

Principal Contradiction

The code's current structure vs the change patterns it actually faces.

Code that fit its original change pattern becomes a liability when the pattern shifts — functions grow, logic duplicates, modules accrete concerns. Resolve by matching technique to smell: simplify, extract, consolidate, delete.

Core Principle

MAKE THE CODE BETTER, NOT JUST DIFFERENT.
SIMPLIFY FIRST. RESTRUCTURE ONLY WHEN NEEDED.
VERIFY AFTER EVERY CHANGE.

Red Flag

Never:

  • Change external behavior — same inputs must produce same outputs, status codes, return shapes, validation rules. Most important constraint.
  • Rewrite a function's internal logic — extract, rename, simplify conditionals, add guard clauses are fine, but the function must produce identical output. "Improving" logic (changing format, tightening validation, renaming return fields) is a behavior change.
  • Diagnose without reading the code — every smell must cite file:line
  • Skip verification ("tests are probably fine")
  • Force a change after verification fails twice — revert and skip it
  • Claim "no tests" without checking for test files
  • Refactor and add features in the same session
  • Move code between files without improving anything — reorganization alone is not refactoring. (Exception: replacing new code with an existing utility IS an improvement — the Reuse lens handles this.)
  • Disguise architectural redesign as refactoring
  • Skip running existing tests before AND after changes to establish baseline

Phase 1: Scan

Read the target (file, directory, or codebase as indicated by user). Determine the diff or file set to review.

Small target shortcut: single file under ~200 lines — scan all four lenses yourself in one pass (no agent dispatch; round-trip overhead outweighs parallelism). Same smell catalog. The Reuse lens still searches the broader codebase, not just the target.

Read the full file on GitHub · 199 lines

Files

What ships with it

3 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. 3mo ago First seen · 199 lines · 51 tokens per session scan A 5287df69fea0

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository heliohq/ship (95 stars, last pushed 5mo ago), licensed MIT. It adds 51 tokens to every session and 1,983 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-30.

Related

refactor compared with skills from other repositories

refactor next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactorheliohq/shipSkill955mo agoMITA51Claude Code
arch-reviewramboz/jigSkill65d agoMITA207Claude Code
security-reviewramboz/jigSkill65d agoMITA147Claude Code
pr-reviewramboz/jigSkill65d agoMITA183Claude Code
explaingkaria/vibe-learnSkill561mo agoMITA33Claude Code
reviewarchcore-ai/pluginSkill582mo agoApache-2.0A127Claude Code
feathers-reviewhassan4702/feathers-pluginSkill26mo agoMITA127Claude Code