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 agentmods add agents/xdg/xdg-claude/refactorgit clone --depth 1 https://github.com/xdg/xdg-claudeWhat 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 | $0.00044 | $0.01824 |
| Opus 5 | $0.00022 | $0.00912 |
| Sonnet 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 3d 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.
- 3d 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 13d 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. 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.
Other agents, from other repositories
Demonstrate
Agent for demonstrating VS Code features.
playwright-test-generator
Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.
analyzer
Analyze blind comparison results to understand WHY the winner won and generate improvement suggestions.
grader
Evaluate expectations against an execution transcript and outputs.
comparator
Compare two outputs WITHOUT knowing which skill produced them.
.NET-Notebook-Migration-Agent
Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.