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 xdg/xdg-claude --skill how-to-plan-refactorgit clone --depth 1 https://github.com/xdg/xdg-claudeWrote 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/xdg/xdg-claude/how-to-plan-refactor)<a href="https://agentmods.dev/skills/xdg/xdg-claude/how-to-plan-refactor"><img src="https://agentmods.dev/badge/skills/xdg/xdg-claude/how-to-plan-refactor/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/xdg/xdg-claude/how-to-plan-refactor"><img src="https://agentmods.dev/badge/skills/xdg/xdg-claude/how-to-plan-refactor.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.00051 | $0.00579 |
| Opus 5.5 | $0.00020 | $0.00232 |
| Sonnet 5.5 | $0.00010 | $0.00116 |
| Haiku 4.5 | $0.00005 | $0.00058 |
Grade A, and why
how-to-plan-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 1mo 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 — 42 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Handling refactoring-planning requests
Delegate to the plan-refactor subagent (Agent tool, subagent_type: plan-refactor) when the user wants analysis of refactoring opportunities -- not execution. The subagent scans for code smells (duplication, long methods, complex conditionals, poor naming, magic values, dead code, tight coupling, data clumps) and returns a prioritized list under a strict 400-word budget.
For executing a specific refactoring, use refactor instead -- see how-to-refactor.
When to delegate vs. handle inline
Delegate when:
- The user asks "what should I refactor?", "find code smells", "where can this be improved?", "analyze this for refactoring opportunities".
- The user wants prioritized recommendations before deciding what to act on.
- The scope is large enough (a file, directory, or module) that reading inline would burn context.
Handle inline (do not delegate) when:
- The user is asking about a specific identified problem ("is this function too long?") -- that's a single judgment, not a survey.
- The scope is a short snippet already visible in conversation.
- The user is asking for design feedback or architectural input rather than refactoring opportunities -- that is conversation, not scanning.
Crafting the delegation prompt
State the scope. The subagent's defaults handle priority and reporting format -- don't reproduce them.
Examples:
- User: "what should I refactor?" → Delegate with empty prompt if the working set is the implicit scope; otherwise ask the user to narrow scope first.
- User: "find smells in src/api/" → "Analyze src/api/ for refactoring opportunities."
- User: "analyze the auth module" → "Analyze the auth module (src/auth/) for refactoring opportunities."
- User: "review my uncommitted changes for refactor opportunities" → "Analyze the uncommitted changes (staged + unstaged) for refactoring opportunities."
Anti-patterns
- Delegating without a scope when the working set is unclear. Ask the user to point at something first.
- Asking the subagent to fix what it finds. It only recommends; pass items to the
refactorsubagent for execution. - Expecting an exhaustive list. The subagent caps output at 10 items and 400 words -- top opportunities only.
- Delegating for tiny scopes (a single short function). The signal-to-overhead is poor.
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.
- 1mo ago Changed abc2852e0bb1
- 2mo ago First seen · 42 lines · 51 tokens per session scan A a174d7825ee7
how-to-plan-refactor is a skill published in the GitHub repository xdg/xdg-claude (20 stars, last pushed 6d ago), licensed Apache-2.0. It adds 51 tokens to every session and 579 once invoked, about $0.0002 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-30.
how-to-plan-refactor compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| how-to-plan-refactorxdg/xdg-claude | Skill | 20 | 6d ago | Apache-2.0 | A | 51 | Claude Code |
| autoreviewopenclaw/clawhub | Skill | 9.5k | yesterday | MIT | A | 17 | Claude Code, Codex |
| agent-teams-simplify-and-hardenLeoYeAI/openclaw-master-skills | Skill | 2.2k | 6d ago | MIT | A | 115 | Claude Code, Codex |
| omh-code-reviewrlaope/oh-my-hermes | Skill | 5.2k | yesterday | MIT | A | 48 | Claude Code, Codex |
| revdiff-planumputun/revdiff | Skill | 945 | yesterday | MIT | A | 84 | Claude Code |
| explore-unknownsdzhng/skills | Skill | 1.4k | 2d ago | MIT | A | 162 | Claude Code, Codex |
| re0-mergeLilMGenius/paperthin | Skill | 1.4k | 4d ago | MIT | A | 70 | Claude Code |