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 ApexIQ/skillsmith --skill refactoring_patternsgit clone --depth 1 https://github.com/ApexIQ/skillsmithWrote 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/apexiq/skillsmith/refactoring_patterns)<a href="https://agentmods.dev/skills/apexiq/skillsmith/refactoring_patterns"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/refactoring_patterns/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/apexiq/skillsmith/refactoring_patterns"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/refactoring_patterns.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.00027 | $0.00548 |
| Opus 5.5 | $0.00011 | $0.00219 |
| Sonnet 5.5 | $0.00005 | $0.00110 |
| Haiku 4.5 | $0.00003 | $0.00055 |
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 3mo 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.
What it actually says
♻️ Refactoring Patterns
Rule: Refactor with tests. No tests = No refactor.
1. When to Refactor
| Signal | Action |
|---|---|
| Same code in 3+ places | Extract to function/component. |
| Function >50 lines | Split into smaller functions. |
| File >500 lines | Split into modules. |
| "I don't understand this" | Add comments, then simplify. |
When NOT to Refactor:
- No tests covering the code.
- Deadline pressure (ship first, refactor later).
- "Just because" - there must be a clear benefit.
2. Common Refactoring Patterns
Extract Function
# Before
def process_email(email):
# 50 lines of validation
# 50 lines of processing
# After
def process_email(email):
validate_email(email)
transform_email(email)
Extract Component (React)
// Before: 200-line component
// After: Split into <EmailList />, <EmailRow />, <EmailActions />
Replace Magic Numbers
# Before
if priority > 7:
# After
HIGH_PRIORITY_THRESHOLD = 7
if priority > HIGH_PRIORITY_THRESHOLD:
Introduce Parameter Object
# Before
def send_email(to, subject, body, cc, bcc, attachments): ...
# After
def send_email(request: SendEmailRequest): ...
3. Safe Refactoring Workflow
- Write tests (if they don't exist).
- Run tests - they should pass.
- Refactor in small steps.
- Run tests after each step.
- Commit when green.
Examples
- Good refactor: Extract
calculatePriority()from a 100-line function. Tests pass before and after. - Bad refactor: "Cleaned up" a file with no tests. Shipped a bug.
Guidelines
- One refactor per commit. Don't mix refactors with features.
- Use IDE refactoring tools (Rename, Extract) - they're safer.
- If refactor is risky, create a feature flag to roll back.
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.
- 3mo ago First seen · 87 lines · 27 tokens per session scan A 77658d59be41
refactoring-patterns is a skill published in the GitHub repository ApexIQ/skillsmith (5 stars, last pushed 8mo ago), licensed MIT. It adds 27 tokens to every session and 548 once invoked, about $0.0001 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-08-31.
refactoring-patterns compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| refactoring-patternsApexIQ/skillsmith | Skill | 5 | 8mo ago | MIT | A | 27 | Claude Code, Codex |
| refactor-agentchandrudp29/skillhub | Skill | 14 | 5mo ago | MIT | A | 32 | Claude Code, Codex |
| refactoringasgarovf/locusai | Skill | 23 | 8mo ago | MIT | A | 31 | Claude Code |
| refactoring-patternssummarybotng/summarybot-ng | Skill | 2 | 5mo ago | MIT | A | 33 | Claude Code |
| a-philosophy-of-software-designciembor/agent-rules-books | Skill | 3.4k | 2mo ago | MIT | A | 33 | Claude Code, Codex |
| domain-driven-designciembor/agent-rules-books | Skill | 3.4k | 2mo ago | MIT | A | 29 | Claude Code, Codex |
| pptxaxoviq-ai/synthadoc | Skill | 2.0k | today | AGPL-3.0 | A | 10 | Claude Code, Codex |