refactor

refactor is a skill for Claude Code, Codex from membrane/api-gateway. It costs 22 tokens per session (2,878 once invoked), scanned A, original, Apache-2.0.

A Java refactoring workflow for restructuring existing code without changing what it does. Refactoring means improving code structure while preserving its behavior.

In plain words
What is it for?
Use it to carry out small Java refactorings such as moving or extracting code, while keeping the existing behavior checked.
Why use it?
It reduces the risk of hidden behavior changes by requiring tests, one transformation at a time, compilation, and affected-test runs.

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/membrane/api-gateway/refactor
Any agent
npx skills add membrane/api-gateway --skill refactor
Clone the repo
git clone --depth 1 https://github.com/membrane/api-gateway

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/membrane/api-gateway/refactor.svg)](https://agentmods.dev/skills/membrane/api-gateway/refactor)
Your own site
<a href="https://agentmods.dev/skills/membrane/api-gateway/refactor"><img src="https://agentmods.dev/badge/skills/membrane/api-gateway/refactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 22 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,878 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.00022 $0.02878
Opus 5 $0.00011 $0.01439
Sonnet 5 $0.00004 $0.00576
Haiku 4.5 $0.00002 $0.00288

Measured today against content hash 1f99bb979fce, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 today.

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.

.claude/skills/refactor/SKILL.md · 202 lines

How it starts

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

Refactor

Behavior-preserving restructuring, Fowler-style. The catalog below is the vocabulary; the workflow is what keeps it safe.

Workflow

  1. Pin behavior first. Find the existing test class (<module>/src/test/java/<mirrored package>/<ClassName>Test.java). If the code you're about to move has no test covering it, write a characterization test against the current behavior before touching anything. If the code is untestable as-is, the first refactoring is the one that makes it testable (usually Extract Method / Extract Class), done in the smallest step you can verify by compiling.
  2. One refactoring per step. Apply a single named transformation, then compile. Never mix two catalog entries in one edit, and never mix a refactoring with a behavior change — if you spot a bug mid-refactor, note it and finish the refactor first, then fix it as a separate change with its own failing test.
  3. Run the affected tests after each step, not just at the end, and delegate the run to the test-runner agent (CLAUDE.md) instead of hand-rolling Maven — it picks the runner for what you touched (a core class or package, a distribution/tutorial IT, or a module-wide run for annot; war has no tests of its own) and knows the traps that make a hand-rolled command silently run the wrong scope. Green after every step is the safety net for behavior, but a sequential test run does not establish thread safety: a refactoring that changes what is shared between threads needs a targeted concurrent test (below).
  4. Report at the end: which refactorings were applied to which methods, what is now testable that wasn't, whether anything you moved changed what is shared between threads, and anything you deliberately left alone.

Scope discipline

  • Refactor only what the user named plus what that change strictly requires. Adjacent messy code stays messy — mention it, don't touch it (CLAUDE.md §3).
  • Public API of @MCElement-annotated config classes is a contract: attribute/child setter names and signatures are the config grammar. Do not rename or re-sign them as part of a refactor. Private helpers behind them are fair game.
  • Delete what your change orphaned (now-unused imports, fields, private methods). Leave pre-existing dead code alone.

Read the full file on GitHub · 202 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. today First seen · 202 lines · 22 tokens per session scan A 1f99bb979fce

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository membrane/api-gateway (641 stars, last pushed today), licensed Apache-2.0. It adds 22 tokens to every session and 2,878 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-09-05.

Related

Other skills, from other repositories

fastapi-expert

Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.

personamanagmentlayer/pcl · 49 tokens

api-design-patterns

Design robust APIs with RESTful patterns, GraphQL schemas, versioning strategies, and error handling conventions. Supports OpenAPI/Swagger documentation and SDK generation patterns. Triggers on API design, schema definition, endpoint architecture, or developer experience requests.

organvm-iv-taxis/a-i--skills · 54 tokens

construtor-de-api

Construção e documentação de APIs REST e GraphQL: design de endpoints, versionamento, autenticação, tratamento de erros, documentação OpenAPI 3.0 e boas práticas de segurança e performance.

ricneves-ai/flowgrammers-skills · 46 tokens

api-designer

Designs production-grade APIs — REST, GraphQL, gRPC, and AsyncAPI patterns including pagination, versioning, error handling, rate limiting, and API governance. Use when the user asks to design APIs, create endpoints, build an API layer, write OpenAPI specs, or needs help with REST/GraphQL/gRPC service design.

buiphucminhtam/forgewright · 73 tokens

api-design

Design and implement RESTful APIs with proper routing, validation, error handling, and documentation. Use when building new API endpoints, designing API architecture, or improving existing APIs.

asgarovf/locusai · 37 tokens

api-design-first

Design-first API development skill. Generates OpenAPI 3.1 specifications, enforces REST design best practices, validates endpoints, handles versioning, pagination, error formatting, authentication patterns, rate limiting, and idempotency. Activates when users say "design an API", "create OpenAPI spec", "API endpoint"…

JPeetz/agent-skills · 117 tokens