refactor

refactor is a skill for Claude Code from boshu2/agentops. It costs 40 tokens per session (1,706 once invoked), scanned A, original, Apache-2.0.

A workflow for making one structural code change while keeping the program’s observable behavior the same.

In plain words
What is it for?
Use it to extract, rename, inline, simplify, encapsulate, move, or remove dead code, then run focused checks and report results and untested areas.
Why use it?
It limits the change to a defined refactoring and records checks that show whether the existing behavior was preserved.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the agentops plugin — 25 skills shipped together

Good fit Use it to extract, rename, inline, simplify, encapsulate, move, or remove dead code, then run focused checks and report results and untested areas.

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

Made for: Claude Code.

Or install agentops, the plugin that ships this one along with the rest of its 25 skills.

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/boshu2/agentops/refactor/github.svg)](https://agentmods.dev/skills/boshu2/agentops/refactor)
Your own site
<a href="https://agentmods.dev/skills/boshu2/agentops/refactor"><img src="https://agentmods.dev/badge/skills/boshu2/agentops/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/boshu2/agentops/refactor"><img src="https://agentmods.dev/badge/skills/boshu2/agentops/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,706 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 pass 7 Sept 2026
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.00040 $0.01706
Opus 5.5 $0.00016 $0.00682
Sonnet 5.5 $0.00008 $0.00341
Haiku 4.5 $0.00004 $0.00171

Measured 19d ago against content hash f428d6b41a79, 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 19d 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.

plugin/skills/refactor/SKILL.md · 150 lines

How it starts

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

Refactor — one structural experiment

Refactor changes structure while preserving observable behavior. It performs one caller-selected transformation and reports the result. "Behavior-preserving" is a claim to prove with before/after checks, never to assert. A user sees it worked when the report shows the same checks run before and after with identical results, and any suspected bug listed unfixed.

What counts as behavior

Unless the caller explicitly excluded a surface, all of these must survive:

  • Messages and exit codes. Error and output text compares byte-for-byte; exit codes, error types and which input raises which error stay the same. Scripts and callers parse them. Preserve an inconsistent message and report it; normalizing it is a behavior change.
  • Differences between near-duplicates. When merging duplicated branches, carry every difference (constants, comparisons, messages, extra steps) as a parameter or a branch. Do not unify a difference the caller has not declared accidental.
  • Interfaces. Public signatures, defaults, return types, persisted field names, protocol values and CLI flags. Renaming one is a compatibility change unless the accepted scope provides for it.
  • Order and coverage. Branch priority, default handling, evaluation count, side-effect order, and the set of tests that run. A pre-existing red that vanishes, or a test that stops running, is a behavior change.
  • Protective checks. Trust-boundary validation, data-loss guards, security controls and accessibility affordances stay, even when another layer, upstream or downstream, duplicates one or no test reaches it. The neutrality gates cannot see their removal, so looking redundant is no reason to delete one.

Procedure

  1. Name the preserved behavior, the focused acceptance surface and the concrete structural problem for its callers, in the caller's domain terms.
  2. Run the focused check and the smallest regression check the changed surface justifies, error paths included, and record that honest baseline, including reproducible ambient failures. Add any characterization test the transformation needs now, before the edit, so it is part of the baseline. For output-producing surfaces (generators, serializers, formatters, reports), hash the output over fixed inputs. When the caller's evaluation compares the built program before and after the change, pin the starting source, build its baseline before edits and keep that binary and the comparison inputs.
  3. Apply one bounded transformation: extract, move, rename, inline, simplify a conditional, reduce parameters, encapsulate, substitute existing code, or delete dead code; the refactoring catalog holds per-pattern safety checks. Judge it by what callers must understand and where a domain rule must change, not by file size.
  4. A bug or suspicious inconsistency found on the way is reported separately (location, why it looks wrong) and left unfixed. Fixing it inside the refactor hides a behavior change the caller did not authorize.
  5. Rerun exactly the step-2 checks over the same inputs and compare any output hashes byte-for-byte.
  6. Report, then stop. A red result is evidence for the caller; this skill does not revert, narrow, retry, commit, validate, or route subsequent work.

Read the full file on GitHub · 150 lines

Files

What ships with it

1 file 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. 19d ago Changed · +11 lines f428d6b41a79
  2. 29d ago Changed · +3 lines 91abe2a02ce9
  3. 1mo ago Changed · -22 lines 0024a2e5dcab
  4. 1mo ago Changed · +20 lines 07726aaa28c9
  5. 1mo ago Changed · +42 lines · +9 tokens per session a44d65da917d
  6. 2mo ago Changed · -27 lines 4733d437e97b
  7. 2mo ago Changed · +19 lines · +2 tokens per session 7bf047eef937
  8. 2mo ago Changed · +4 lines e63c6c33fb01
  9. 2mo ago Changed · +13 lines 515d71efb7d1
  10. 3mo ago First seen · 87 lines · 29 tokens per session scan A 30c934734b38

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository boshu2/agentops (464 stars, last pushed yesterday), licensed Apache-2.0. It adds 40 tokens to every session and 1,706 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
refactorboshu2/agentopsSkill464yesterdayApache-2.0A40Claude Code
brainstormOutlineDriven/odin-claude-pluginSkill402mo agoApache-2.0A85Claude Code, Codex
audit-projectOutlineDriven/odin-claude-pluginSkill402mo agoApache-2.0A50Claude Code, Codex
commit-push-prOutlineDriven/odin-claude-pluginSkill402mo agoApache-2.0A46Claude Code, Codex
commitOutlineDriven/odin-claude-pluginSkill402mo agoApache-2.0A46Claude Code, Codex
duetOutlineDriven/odin-claude-pluginSkill402mo agoApache-2.0A28Claude Code, Codex
prototypeOutlineDriven/odin-claude-pluginSkill402mo agoApache-2.0A36Claude Code, Codex