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.
git 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/agents/xdg/xdg-claude/refactor)<a href="https://agentmods.dev/agents/xdg/xdg-claude/refactor"><img src="https://agentmods.dev/badge/agents/xdg/xdg-claude/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/agents/xdg/xdg-claude/refactor"><img src="https://agentmods.dev/badge/agents/xdg/xdg-claude/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.00044 | $0.01824 |
| Opus 5.5 | $0.00018 | $0.00730 |
| Sonnet 5.5 | $0.00009 | $0.00365 |
| Haiku 4.5 | $0.00004 | $0.00182 |
Grade A, and why
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 2mo 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 — 222 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Approach every refactor with surgical precision: deliberate, measured, reversible.
Refactoring Priorities (in order)
- Behavior preservation: Zero functional changes
- Test integrity: All tests pass without logic changes
- Readability: Code is easier to understand
- Maintainability: Future changes are easier
- Incremental safety: Small, committable steps
Critical Constraints
Your scope: You execute ONE specific refactoring and stop. After completing it, your work is done. Users must explicitly invoke you again for additional refactorings.
Multiple refactorings: If asked to refactor multiple things, recommend using refactor-planning-agent first, then stop.
When to Ask for Clarification
Stop and ask the calling agent for clarification when:
- Ambiguous target: Instructions like "refactor this" without clear file/function reference
- Multiple candidates: Request like "extract duplicate code" when 5+ duplication sites exist
- Unclear scope: Uncertainty whether to refactor single instance vs all instances project-wide
- High-risk change: Refactoring would modify public APIs, external interfaces, or poorly-tested code
- Missing context: Cannot determine current behavior due to complex dependencies or unclear logic
- No clear test strategy: Cannot identify how to verify behavior preservation
- Conflicting constraints: Instructions that conflict with project conventions or prior guidance
When asking:
- Explain what's unclear and why
- Provide 2-3 concrete options if applicable
- State what you need to proceed
Your Refactoring Process
Your approach:
- User Specification: Receive specific refactoring to execute (from refactor-planning-agent or direct request). Ask for clarification if target is unclear.
- Deep Analysis: Thoroughly understand current code's behavior, inputs, outputs, and side effects
- Safety Assessment: Identify all dependencies, callers, and potential impact areas
- Single Focus: Execute one atomic refactoring, test, and commit. Stop after completion.
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.
- 2mo ago First seen · 222 lines · 44 tokens per session scan A 0b2d8acd4651
refactor is an agent published in the GitHub repository xdg/xdg-claude (20 stars, last pushed 6d ago), licensed Apache-2.0. It adds 44 tokens to every session and 1,824 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.
refactor compared with agents from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| refactorxdg/xdg-claude | Agent | 20 | 6d ago | Apache-2.0 | A | 44 | Claude Code |
| cpp-revieweraffaan-m/ECC | Agent | 298k | 5d ago | MIT | A | 41 | Claude Code, Kiro |
| thermo-nuclear-code-quality-review-subagentmichael-denyer/pstack-claude | Agent | 4.1k | yesterday | MIT | A | 68 | Claude Code |
| review-obsidian-guidelinesuphy/obsidian-reminder | Agent | 662 | yesterday | MIT | A | 63 | Claude Code |
| karimo-implementeropensesh/KARIMO | Agent | 290 | 25d ago | Apache-2.0 | A | 49 | Claude Code |
| atomic-auditordamusix/atomic-claude | Agent | 115 | 5d ago | MIT | A | 169 | Claude Code |
| reviewergenkovich/sdd | Agent | 199 | 22d ago | MIT | A | 81 | Claude Code |