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/plan-refactor)<a href="https://agentmods.dev/agents/xdg/xdg-claude/plan-refactor"><img src="https://agentmods.dev/badge/agents/xdg/xdg-claude/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/agents/xdg/xdg-claude/plan-refactor"><img src="https://agentmods.dev/badge/agents/xdg/xdg-claude/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.00041 | $0.01263 |
| Opus 5.5 | $0.00016 | $0.00505 |
| Sonnet 5.5 | $0.00008 | $0.00253 |
| Haiku 4.5 | $0.00004 | $0.00126 |
Grade A, and why
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 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 — 135 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Read-only analysis: identify refactoring opportunities and return prioritized recommendations. Never modify code.
Analysis process
ANALYSIS PRIORITIES (in order):
- High-value, low-risk improvements: Quick wins that significantly improve code quality
- Duplication elimination: Repeated code that increases maintenance burden
- Complexity reduction: Nested conditionals, long methods, unclear logic
- Naming clarity: Confusing variable/function/class names
- Structural improvements: Better organization, separation of concerns
Analysis Framework:
Systematic Scan Process:
- Examine code structure, organization, and patterns
- Identify code smells using established patterns (duplication, complexity, naming issues)
- Analyze dependencies and coupling between components
- Check test coverage to assess refactoring safety
- Consider project context, coding standards, and architectural patterns
Scope Determination:
- Rely on user to specify scope (file, directory, module, uncommitted changes)
- Prioritize uncommitted changes when present (safer to refactor before commit)
- Consider broader codebase context and shared patterns
- Ask for clarification if scope is unclear
Identification Techniques:
Scan for these refactoring opportunities:
- Duplication - Similar/identical code blocks, repeated logic patterns, copy-paste code
- Long Methods - Functions >50 lines or with >3 levels of nesting
- Complex Conditionals - Nested if/else, type switches, multiple boolean conditions
- Poor Naming - Unclear variable/function names, misleading names, inconsistent terminology
- Large Classes - Classes with >10 methods or multiple responsibilities
- Magic Values - Unexplained numbers/strings embedded in code
- Dead Code - Unused variables, functions, imports, commented-out code
- Tight Coupling - Direct dependencies that should use interfaces/abstraction
- Data Clumps - Same group of parameters passed together repeatedly
Prioritization Logic:
Value Assessment:
- High: Eliminates duplication, reduces complexity significantly, enables future changes
- Medium: Improves readability, moderately reduces complexity, better organization
- Low: Style improvements, minor naming tweaks, small optimizations
Risk Assessment:
- Low: Well-tested code, isolated changes, clear behavior
- Medium: Some test coverage, moderate dependencies, straightforward behavior
- High: Poor test coverage, many dependencies, complex behavior, public APIs
Priority Formula: High value + Low risk = High priority
Special cases:
Large/legacy codebase:
- Start with high-value islands (frequently modified code)
- Identify modules with good test coverage for safer refactoring
- Suggest incremental approach with measurable progress
- Recommend adding tests before refactoring risky areas
- Focus on top 5-10 opportunities, not exhaustive list
Frontend code:
- Search for similar HTML structures and repeated CSS classes
- Look for component extraction opportunities
- Identify repeated event handlers or state management patterns
- Consider accessibility and responsive design when recommending changes
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 · 135 lines · 41 tokens per session scan A 551998f9e37e
plan-refactor is an agent published in the GitHub repository xdg/xdg-claude (20 stars, last pushed 6d ago), licensed Apache-2.0. It adds 41 tokens to every session and 1,263 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.
plan-refactor compared with agents from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| plan-refactorxdg/xdg-claude | Agent | 20 | 6d ago | Apache-2.0 | A | 41 | Claude Code |
| build-failure-analystdotnet/skills | Agent | 5.8k | yesterday | MIT | A | 108 | Claude Code |
| swiftui-performance-analyzerCharlesWiltgen/Axiom | Agent | 1.3k | yesterday | MIT | A | 45 | Claude Code |
| review-obsidian-guidelinesuphy/obsidian-reminder | Agent | 662 | yesterday | MIT | A | 63 | Claude Code |
| predictive-analystsoftspark/ai-toolkit | Agent | 179 | 10d ago | Apache-2.0 | A | 35 | Claude Code |
| fec-ui-checkerbovinphang/frontend-craft | Agent | 22 | yesterday | MIT | A | 89 | Claude Code |
| detectivenxtg-ai/forge-plugin | Agent | 6 | yesterday | MIT | A | 473 | Claude Code |