refactoring-recipes

refactoring-recipes is a skill for Claude Code from KhaledSaeed18/dotclaude. It costs 123 tokens per session (1,248 once invoked), scanned A, original, MIT.

A guide to changing a program's internal structure without changing what it does. Refactoring recipes name common changes, such as extracting a function, renaming code, or replacing a conditional, and describe safe steps.

In plain words
What is it for?
Use it to split large functions, remove duplication, rename or move code, replace complex conditionals, encapsulate collections, and plan gradual replacement of a large system.
Why use it?
It keeps cleanup separate from feature work and makes behavior changes easier to detect. Small steps and tests provide evidence that the program still behaves the same way.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Part of the engineering plugin — 22 skills, 2 commands, 7 agents shipped together

Good fit Use it to split large functions, remove duplication, rename or move code, replace complex conditionals, encapsulate collections, and plan gradual replacement of a large system.

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

Made for: Claude Code.

Or install engineering, the plugin that ships this one along with the rest of its 22 skills, 2 commands, 7 agents.

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-recipes

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/khaledsaeed18/dotclaude/refactoring-recipes"><img src="https://agentmods.dev/badge/skills/khaledsaeed18/dotclaude/refactoring-recipes.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 123 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,248 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.00123 $0.01248
Opus 5.5 $0.00049 $0.00499
Sonnet 5.5 $0.00025 $0.00250
Haiku 4.5 $0.00012 $0.00125

Measured 25d ago against content hash 2074d2e1d838, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

refactoring-recipes 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 25d 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.

.claude-plugin/plugins/engineering/skills/refactoring-recipes/SKILL.md · 58 lines

How it starts

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

A refactoring changes structure without changing behaviour, in steps small enough that the tests pass after each one. If you cannot run tests between steps, the first refactoring is to make the code testable. If you are changing behaviour, that is a feature or a fix; do not mix it with refactoring in the same commit.

Before any refactoring

  1. Tests exist and pass. Characterisation tests for legacy code: capture current outputs for representative inputs before touching anything.
  2. Scope is named. The smell you are removing and the boundary you will not cross.
  3. Commit is clean. Refactor on its own commit(s) so a reviewer can verify "no behaviour change" by reading the diff.

Recipes

Extract function. When a block does one nameable thing inside a longer function, or the same block appears twice. Steps: name the function after what it does; copy the block; identify inputs (parameters) and outputs (return); replace the block with a call; run tests. Watch for variables assigned in the block and read after it (return them, or split the extraction).

Inline function. When a function's body is as clear as its name and it has one caller, or the indirection hides what happens. Steps: check it is not overridden; replace each call with the body; remove the function; run tests.

Rename. When a name lies or is vague. Steps: use the IDE or language-server rename for symbols; for strings and config keys, grep all occurrences including docs and tests; rename in one commit. Keep the old name as a deprecated alias when it is public API, with a removal date.

Extract module or class. When a file has two reasons to change, or one group of functions shares state the others do not touch. Steps: move the cohesive functions and their state; leave re-exports at the old location temporarily; update imports; run tests; remove re-exports when no caller remains.

Move function. When a function uses another module's data more than its own. Steps: copy to the target; make the original delegate; move callers one by one; delete the original.

Read the full file on GitHub · 58 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. 25d ago First seen · 58 lines · 123 tokens per session scan A 2074d2e1d838

Subscribe to this mod's changes

refactoring-recipes is a skill published in the GitHub repository KhaledSaeed18/dotclaude (5 stars, last pushed 2d ago), licensed MIT. It adds 123 tokens to every session and 1,248 once invoked, about $0.0005 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-09-22.