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.
npx skills add OKHP3/skillz --skill refactoring-best-practicesgit clone --depth 1 https://github.com/OKHP3/skillzWrote 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.
[](https://agentmods.dev/skills/okhp3/skillz/refactoring-best-practices)<a href="https://agentmods.dev/skills/okhp3/skillz/refactoring-best-practices"><img src="https://agentmods.dev/badge/skills/okhp3/skillz/refactoring-best-practices/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.
<a href="https://agentmods.dev/skills/okhp3/skillz/refactoring-best-practices"><img src="https://agentmods.dev/badge/skills/okhp3/skillz/refactoring-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00086 | $0.01246 |
| Opus 5 | $0.00043 | $0.00623 |
| Sonnet 5 | $0.00017 | $0.00249 |
| Haiku 4.5 | $0.00009 | $0.00125 |
Grade A, and why
refactoring-best-practices 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 6d 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.
How it starts
The opening of the file, as written. The whole thing — 114 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactoring Best Practices
Use this skill when the main challenge is changing existing code safely.
Working Style
- Protect behavior before improving design.
- Prefer small reversible moves over dramatic rewrites.
- Add feedback before adding abstraction.
- Change one responsibility at a time.
- Let the current pain point decide the next move.
Safe Refactoring Workflow
-
Observe current behavior.
- Identify outputs, side effects, and error paths.
- Identify what must not change.
-
Add feedback.
- Prefer characterization tests around visible behavior.
- Add logs or temporary probes only when tests are not enough.
-
Find a seam.
- Isolate time, file system, network, framework globals, singletons, and external APIs.
- Create the narrowest possible boundary around the risky dependency.
-
Choose the next move.
- extract method
- extract class
- introduce value object
- introduce first-class collection
- move method
- replace conditional with polymorphism
- separate construction from behavior
- extract a Domain Event and one secondary subscriber
-
Re-run feedback after every meaningful step.
High-Value Refactoring Moves
- Replace a cohesive domain parameter group with a Value Object; use a Parameter Object when the group has no shared domain meaning or invariant.
- Break large services into role-focused collaborators.
- Move business rules out of controllers, scripts, and utility classes.
- Replace type codes and unstable conditionals with explicit roles.
- Wrap infrastructure behind ports or adapters.
- Split classes when different method clusters change for different reasons.
Red Flags
- Big-bang rewrites.
- New abstractions without a protected behavior baseline.
- Splitting code into tiny classes without a clearer model.
- Introducing inheritance only to make tests easier.
- Refactoring based on aesthetics alone while ignoring risk.
Decision Rules
Refactor now when
- the same knowledge is duplicated in multiple places
- the code is blocking a real change
- the next feature would deepen coupling or duplication
- the current structure makes defects likely
What ships with it
9 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.
- references/characterization-tests.md 9.4 KB
- references/code-smells.md 10 KB
- references/domain-event-migration.md 3.0 KB
- references/error-contract-migration.md 1.8 KB
- references/fran-iglesias-refactoring-guidance.md 12 KB
- references/language-examples.md 25 KB
- references/legacy-code-techniques.md 15 KB
- references/refactoring-moves.md 6.0 KB
- references/safe-change-workflow.md 6.3 KB
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.
- 6d ago First seen · 114 lines · 86 tokens per session scan A 16dd3e5c1492
refactoring-best-practices is a skill published in the GitHub repository OKHP3/skillz (3 stars, last pushed yesterday), licensed MIT. It adds 86 tokens to every session and 1,246 once invoked, about $0.0004 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-03.
Other skills, from other repositories
ontoly-software-graph
Use Ontoly's deterministic Software Graph and MCP capabilities for architecture review, request tracing, dependency analysis, configuration lookup, and impact analysis before falling back to source-file search.
openclaw-diagnose
Diagnose and fix OpenClaw gateway and node host issues. Use when openclaw services have warnings, connection failures, pairing errors, or port conflicts.
lxd-docker-firewall-conflict
Diagnose and fix the well-known Docker/LXD firewall conflict on a host running both. Docker sets the iptables FORWARD chain policy to DROP and accepts only its own bridges, so forwarded traffic from the LXD bridge (lxdbr0) is silently dropped and LXD containers/VMs get no outbound internet (the host itself is fine).…
baoyu-diagram
Create professional, dark-themed SVG diagrams of any type — architecture diagrams, flowcharts, sequence diagrams, structural diagrams, mind maps, timelines, illustrative/conceptual diagrams, and more. Use this skill whenever the user asks for any kind of technical or conceptual diagram, visualization of a system…
log-analyzer
A log-analysis helper that reads application and system logs to find unusual patterns and likely causes. Logs are records of events such as errors, requests, warnings, and service activity.
Reverse Engineering & Binary Analysis
Binary analysis, assembly interpretation, disassembly, decompilation, firmware RE, and protocol reverse engineering.