refactoring

refactoring is a skill for Claude Code from brunob54/superpowers-orchestrator. It costs 156 tokens per session (1,575 once invoked), scanned A, original, MIT.

A procedure for reorganising existing code while keeping its observable behaviour unchanged; this is called refactoring.

In plain words
What is it for?
It helps extract functions or modules, rename code, simplify structure, decouple components, and reorganise files.
Why use it?
It reduces the risk that moving or simplifying code quietly breaks existing behaviour by requiring tests before and during the changes.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the superpowers-orchestrator plugin — 28 skills, 2 agents, 6 hooks shipped together

Good fit It helps extract functions or modules, rename code, simplify structure, decouple components, and reorganise files.

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

Made for: Claude Code.

Or install superpowers-orchestrator, the plugin that ships this one along with the rest of its 28 skills, 2 agents, 6 hooks.

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 refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/brunob54/superpowers-orchestrator/refactoring.svg)](https://agentmods.dev/skills/brunob54/superpowers-orchestrator/refactoring)
Your own site
<a href="https://agentmods.dev/skills/brunob54/superpowers-orchestrator/refactoring"><img src="https://agentmods.dev/badge/skills/brunob54/superpowers-orchestrator/refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 156 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,575 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.00156 $0.01575
Opus 5 $0.00078 $0.00788
Sonnet 5 $0.00031 $0.00315
Haiku 4.5 $0.00016 $0.00158

Measured 7d ago against content hash 3e68659bf53d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

refactoring 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 7d 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/refactoring/SKILL.md · 108 lines

How it starts

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

Refactoring

Change structure without changing behavior. Prove it at every step.

Why This Exists

Refactoring feels safe — "I'm just moving things around." That's exactly why it's dangerous. Without a behavior lock, structural changes silently break contracts, reorder side effects, or drop edge cases. This skill enforces the discipline that makes refactoring actually safe.

Phase 1: Behavior Lock

Before touching any structure, lock the current behavior with tests.

  1. Run the existing test suite. Detect the project's test runner (check package.json scripts, Makefile, pytest.ini, Cargo.toml, etc.) and run it. Every test must pass. If tests fail before you start, you're debugging, not refactoring — switch to systematic-debugging.

  2. Identify the refactoring surface — which functions, modules, or files will be structurally changed.

  3. Audit test coverage on that surface. For each function/module in scope:

    • Is there a test that exercises its public API or observable behavior?
    • If yes: verify it passes. That test is now your behavior lock.
    • If no: write a characterization test that captures current behavior. This test doesn't assert "correct" behavior — it asserts "current" behavior. The point is to detect unintended changes, not to validate design.

    Writing characterization tests: Call the function with representative inputs and assert on the exact output. For side-effectful code (writes files, sends requests, modifies state), wrap the side effect in a spy/mock and assert it was called with the expected arguments. For error cases, trigger the error and assert on the error type/message. If the function is too tightly coupled to test in isolation, that's useful information — note it as a reason the refactoring is needed, and test at the integration level (HTTP request → response, CLI input → output) instead.

  4. Confirm: all tests green. This is your baseline. Any structural change that breaks a test has changed behavior — stop and investigate.

Read the full file on GitHub · 108 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. 7d ago First seen · 108 lines · 156 tokens per session scan A 3e68659bf53d

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository brunob54/superpowers-orchestrator (3 stars, last pushed yesterday), licensed MIT. It adds 156 tokens to every session and 1,575 once invoked, about $0.0008 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

github-pr-review

Handles PR review comments and feedback resolution. Use when user wants to resolve PR comments, handle review feedback, fix review comments, address PR review, check review status, respond to reviewer, verify PR readiness, review PR comments, analyze review feedback, evaluate PR comments, assess review suggestions, or…

fvadicamo/dev-agent-skills · 95 tokens

privacy-guard

Prevents private infrastructure details (node hostnames, internal project names, local usernames and personal emails, absolute home paths, private and VPN IP ranges) from leaking into public repositories through commits, PRs, docs or release artifacts. Use when working in a public or soon-to-be-public repo, before…

fvadicamo/dev-agent-skills · 128 tokens

github-pr-merge

Merges GitHub Pull Requests after validating pre-merge checklist. Use when user wants to merge PR, close PR, finalize PR, complete merge, approve and merge, or execute merge. Runs pre-merge validation (tests, lint, CI, comments), confirms with user, merges with proper format, handles post-merge cleanup.

fvadicamo/dev-agent-skills · 72 tokens

github-pr-creation

Creates GitHub Pull Requests with automated validation and task tracking. Use when user wants to create PR, open pull request, submit for review, or check if ready for PR. Analyzes commits, validates task completion, generates Conventional Commits title and description, suggests labels. NOTE - for merging existing…

fvadicamo/dev-agent-skills · 75 tokens

git-commit

Creates git commits following Conventional Commits format with type/scope/subject. Use when user wants to commit changes, create commit, save work, or stage and commit. Enforces project-specific conventions from CLAUDE.md.

fvadicamo/dev-agent-skills · 49 tokens

assess

Issue triage and status assessment - analyze current state, detect health signals, and recommend next action with full workflow plan.

sequant-io/sequant · 27 tokens