refactoring-patterns

A method for improving Go or TypeScript code structure through small changes that keep its behaviour the same. TDD means using tests to check the code before and after each change.

In plain words
What is it for?
Use it when preparing code for a feature, responding to code-review concerns, or making existing code easier to test. Tests should already pass; if coverage is missing, work with legacy-code techniques first.
Why use it?
It reduces the risk of breaking existing behaviour while addressing duplication, long methods, and tangled conditions.

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/clubpay/ronykit/refactoring-patterns
Any agent
npx skills add clubpay/ronykit --skill refactoring-patterns
Clone the repo
git clone --depth 1 https://github.com/clubpay/ronykit

Made for: Claude Code, Codex.

Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,516 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 91% copy Near-identical to another mod 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.00057 $0.03516
Opus 5 $0.00028 $0.01758
Sonnet 5 $0.00011 $0.00703
Haiku 4.5 $0.00006 $0.00352

Measured 3d ago against content hash f613975fe311, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactoring-patterns 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 3d 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.

Origin

This is a copy

91% identical to refactoring-patterns — 34 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

ronyup/internal/skeleton/skills/refactoring-patterns/SKILL.md · 241 lines

How it starts

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

Refactoring Patterns Framework

A disciplined approach to improving the internal structure of existing code without changing its observable behavior. Every refactoring follows the same loop: verify tests pass, apply one small structural change, verify tests still pass.

Core Principle

Refactoring is not rewriting. It is a sequence of small, behavior-preserving transformations, each backed by tests. You never change what the code does — only how it is organized. Big-bang rewrites fail because they combine structural change with behavioral change, making it impossible to know which broke things.

The foundation: Bad code is a natural consequence of delivering under time pressure, not a character flaw. Code smells are objective signals of degraded structure; the smell catalog tells you where to look, and the refactoring catalog tells you what to do.

When to use

  • Restructuring before or after a feature (preparatory refactoring).
  • A PR review flags duplication, long methods, or tangled conditionals.
  • Preparing a RonyKit internal/app method for clearer unit tests.

Prerequisites: tests green before you start. No coverage? Read working-with-legacy-code first, then go-testing. Run verification-before-completion after each step — never mix structure and behavior in one commit.

Scoring

Goal: 10/10. Score structural quality by how many of the eight Quick Diagnostic rows pass — score = round(passed / 8 × 10), adjusting down when a single smell is severe. Bands:

  • 9-10: no obvious smells remain, each function does one thing, names reveal intent, duplication is eliminated, conditionals use polymorphism where apt, and tests cover the refactored paths.
  • 5-6: a few smells remain (a Long Method, some duplication) but structure is mostly sound.
  • ≤3: pervasive smells — tangled conditionals, God classes, duplication everywhere — or no tests to refactor safely.

Always state the current score, name the smells driving it down, and list the specific refactorings needed to reach 10/10.

Read the full file on GitHub · 241 lines

Files

What ships with it

6 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. 3d ago First seen · 241 lines · 57 tokens per session scan A f613975fe311

Subscribe to this mod's changes

refactoring-patterns is a skill published in the GitHub repository clubpay/ronykit (38 stars, last pushed 5d ago), licensed BSD-3-Clause. It adds 57 tokens to every session and 3,516 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 91% identical to refactoring-patterns, differing in 34 lines, and is treated as a copy.

Related

Other skills, from other repositories

procedure

Vovk.ts procedures — atomic unit of server-side logic in Vovk project. Use whenever user asks to build ANYTHING producing or consuming data on server — page loading data ("users page", "dashboard", "product list"), endpoint, API handler, server action, form submission, controller, validation with Zod / Valibot /…

finom/vovk · 342 tokens

rpc

Vovk.ts RPC client — how vovk generate turns controllers into type-safe client modules, composed vovk-client vs segmented clients, call shape (apiRoot, params, body, query, meta, init, disableClientValidation, validateOnClient, interpretAs, transform, fetcher), customizing generation via outputConfig.imports.fetcher +…

finom/vovk · 354 tokens

tools

Building LLM tools with Vovk.ts — deriveTools() (procedures → tools), createTool() (standalone tools, no controller/procedure needed), @operation.tool({ name, title, description, hidden }) decorator, x-tool metadata, ToModelOutput.DEFAULT vs ToModelOutput.MCP formatters, the tools + toolsByName return shape, the meta…

finom/vovk · 261 tokens

mixins

Vovk.ts OpenAPI mixins — importing third-party OpenAPI 3.x schemas as typed client modules that share the same call signature as native Vovk RPC modules. Use whenever the user asks to "call a third-party API from my Vovk app", "mixin an OpenAPI schema", "import an OpenAPI spec as a client", "wrap an external service…

finom/vovk · 275 tokens

bundle

Vovk.ts vovk bundle CLI — packages composed TypeScript client as zero-dep publishable npm package. Covers bundle.build async fn, [email protected] recipe, outputConfig.origin / package / reExports / imports.validateOnClient: null, prebundleOutDir / outDir / keepPrebundleDir, --include/--exclude segments, --openapi- mixin…

finom/vovk · 250 tokens

decorators

Vovk.ts decorators — built-in (@prefix, @operation, @get/@post/@put/@patch/@del, .auto()) and custom via createDecorator. Covers authorization / auth decorators, middleware-style wrapping (pre-handler + post-handler logic), req.vovk.meta() for cross-decorator state, stacking order, the decorate() alternative for…

finom/vovk · 228 tokens