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 commands/paulduvall/ai-development-patterns/refactorgit clone --depth 1 https://github.com/PaulDuvall/ai-development-patternsWhat 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.00012 | $0.00666 |
| Opus 5 | $0.00006 | $0.00333 |
| Sonnet 5 | $0.00002 | $0.00133 |
| Haiku 4.5 | $0.00001 | $0.00067 |
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 2d 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 — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactoring Assistant
You are helping a developer improve code maintainability by identifying code smells and recommending specific refactoring techniques from Martin Fowler's catalog.
Usage Examples
/refactor # Full analysis
/refactor --smell # Code smells only
/refactor --duplicates # Find duplicate code
/refactor --suggest # Quick suggestions without deep analysis
Implementation
1. Code Smell Detection
Analyze codebase for maintainability issues:
- Long methods (>20 lines)
- Duplicate code blocks (repeated patterns across files)
- Complex conditionals (cyclomatic complexity >10)
- Large classes (>250 lines)
For each smell found:
- Identify exact location (file:line)
- Assess severity (CRITICAL/HIGH/MEDIUM/LOW)
- Suggest specific refactoring from Fowler's catalog
- Estimate effort and risk
2. Bloater Detection
Find oversized code structures:
- Methods with excessive parameters (>4)
- Data clumps (same variables passed together repeatedly)
- Primitive obsession (overuse of primitives vs objects)
- Long parameter lists (>3-4 parameters)
3. Refactoring Strategy
For each issue identified:
- Name the code smell (e.g., "Long Method", "Feature Envy", "Shotgun Surgery")
- Recommend specific refactoring technique from Fowler's catalog:
- Extract Method
- Move Method
- Replace Temp with Query
- Introduce Parameter Object
- Replace Conditional with Polymorphism
- Show before/after example with actual code snippets
- Estimate maintainability improvement (complexity reduction, testability increase)
4. Output Format
Generate step-by-step refactoring plan prioritized by impact:
## Refactoring Report
### Summary
- Total smells found: X
- Critical issues: Y
- Estimated total effort: Z hours
### Priority 1: Critical Issues
1. **Long Method in src/api/users.js:45-120**
- Smell: Long Method (75 lines)
- Severity: CRITICAL
- Recommended refactoring: Extract Method
- Estimated effort: 1 hour
- Impact: Improves testability, reduces complexity by 40%
### Priority 2: High Issues
...
### Refactoring Plan
Step-by-step implementation guide with code examples
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.
- 2d ago First seen · 102 lines · 12 tokens per session scan A 2fbcc21bdfec
refactor is a command published in the GitHub repository PaulDuvall/ai-development-patterns (645 stars, last pushed 3d ago), licensed MIT. It adds 12 tokens to every session and 666 once invoked, about $0.0001 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 commands, from other repositories
paul:help
Show available PAUL commands and usage guide.
paul:handoff
Generate comprehensive session handoff document.
paul:plan-fix
Plan fixes for UAT issues from verify.
paul:research-phase
Research unknowns for a phase using subagents.
config
Manage PAUL project configuration and integrations. Create or update .paul/config.md at any point in the project lifecycle.
paul:progress
Smart status with routing - suggests ONE next action.