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/kid-sid/claude-spellbook/refactorgit clone --depth 1 https://github.com/kid-sid/claude-spellbookWhat 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.00000 | $0.00691 |
| Opus 5 | $0.00000 | $0.00345 |
| Sonnet 5 | $0.00000 | $0.00138 |
| Haiku 4.5 | $0.00000 | $0.00069 |
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 — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Analyze code for smells and suggest or apply refactoring with examples.
Instructions
- Read the target file or directory the user specifies.
- Detect the language and analyze the code for these smell categories:
Code Smells to Detect
Size & Complexity:
- Functions longer than 30 lines
- Classes with more than 10 methods (God Class)
- Cyclomatic complexity > 10
- Deep nesting (> 3 levels)
- Long parameter lists (> 4 parameters)
Duplication & Coupling:
- Duplicate or near-duplicate code blocks
- Shotgun surgery (one change requires editing many files)
- Feature envy (method uses another class's data more than its own)
- Inappropriate intimacy (classes that know too much about each other)
Naming & Clarity:
- Unclear variable/function names
- Magic numbers without named constants
- Boolean parameters (use named options/enums instead)
- Comments explaining "what" instead of code being self-documenting
Design:
- Primitive obsession (using primitives instead of small value objects)
- Data clumps (groups of data that always appear together)
- Switch statements that should be polymorphism
- Refused bequest (subclass doesn't use parent's methods)
- Speculative generality (unused abstractions)
SOLID Violations:
- Single Responsibility: class/function doing too many things
- Open/Closed: modification required instead of extension
- Liskov Substitution: subtypes not substitutable for base types
- Interface Segregation: forced to depend on unused methods
- Dependency Inversion: high-level modules depending on low-level details
-
For each smell found, provide:
- Location: file:line
- Smell: name of the code smell
- Severity: Low / Medium / High
- Current code: the problematic snippet
- Refactored code: the improved version
- Technique: name of the refactoring pattern applied (e.g., Extract Method, Replace Conditional with Polymorphism, Introduce Parameter Object)
-
Output format:
## Refactoring Report
**File(s):** {paths}
**Language:** {language}
**Issues found:** {count}
### High Priority
#### 1. {Smell Name} — {file:line}
**Technique:** {refactoring pattern}
Before:
```{lang}
{original code}
After:
{refactored code}
Why: {explanation of the improvement}
Medium Priority
{same format}
Low Priority
{same format}
Summary
- {count} issues found across {severity levels}
- Estimated improvement: {what gets better — readability, testability, maintainability}
- Suggested order: {which refactors to do first}
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 · 101 lines · 0 tokens per session scan A 2a0c04c82223
refactor is a command published in the GitHub repository kid-sid/claude-spellbook (187 stars, last pushed 28d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 691 tokens. 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
git
Git operations with intelligent commit messages and workflow optimization.
checklist
Generate a custom checklist for the current feature based on user requirements.
clarify
Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec.
specify
Create or update the feature specification from a natural language feature description.
analyze
Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation.
converge
Assess the current codebase against the feature's spec, plan, and tasks, then append any remaining unbuilt work as new tasks to tasks.md so implement can complete it.