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/rchgrav/claudebox/refactorgit clone --depth 1 https://github.com/RchGrav/claudeboxWhat 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.00009 | $0.00855 |
| Opus 5 | $0.00005 | $0.00428 |
| Sonnet 5 | $0.00002 | $0.00171 |
| Haiku 4.5 | $0.00001 | $0.00085 |
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.
What it actually says
You are now in refactoring mode. Focus on improving code design while keeping tests green.
Target: $ARGUMENTS
SCOPE DETECTION:
If no arguments provided:
- On feature branch: Automatically assess changes since branching from main
- On main branch: Ask user what they'd like refactored
If arguments provided:
- File path: Refactor specific file (e.g., "src/auth.js")
- Module/area: Refactor specific functionality (e.g., "authentication module")
- Feature: Refactor specific behavior (e.g., "payment processing")
REFACTORING WORKFLOW:
-
Assess current code:
- Read and understand the code to be refactored
- Identify the scope and boundaries
- Run tests to ensure current behavior is captured
-
Impact assessment:
- High impact: Code changed frequently + complex logic + poor readability
- Medium impact: Code changed occasionally + moderate complexity
- Low impact: Stable code + simple logic + already readable
-
Risk assessment:
- Low risk: Well-tested code, simple changes
- Medium risk: Some test coverage, moderate changes
- High risk: Poor test coverage, complex changes → require characterization tests first
-
Code smell detection:
- Long functions (>20 lines) with multiple responsibilities
- Deep nesting (>3 levels) indicating complex control flow
- Magic numbers/strings without named constants
- Feature envy (functions accessing other objects' data excessively)
- Shotgun surgery (small changes requiring edits across many files)
-
ROI prioritization:
- Immediate value: Code being actively modified
- Future value: Code likely to change soon
- Team value: Code that confuses multiple developers
- Maintenance value: Code with frequent bugs
-
Context integration:
- Review recent commits for patterns needing improvement
- Check PR feedback for recurring refactoring suggestions
- Identify code that slows down current feature development
-
Make incremental changes:
- One improvement at a time
- Run tests after each change
- Commit improvements that provide value
CODE QUALITY CHECKLIST:
Dead code elimination:
- Functions or utilities that aren't called anywhere
- Parameters that aren't used by any callers
- Configuration options that aren't referenced
- Helper functions added "just in case" but never used
- Rule: Every function/utility must have demonstrated usage
Duplication elimination:
- Multiple functions defining the same variables
- Similar validation logic within functions
- Repeated string constants or configuration values
- Identical error handling patterns
Design improvements:
- Extract common functionality into utility libraries
- Consolidate configuration into modules
- Improve function naming and interface design
- Break large functions into smaller, focused ones
Maintainability enhancements:
- Centralize configuration (paths, constants, defaults)
- Improve error messages and user feedback
- Add helpful code comments for complex logic
- Simplify conditional logic and reduce nesting
BRANCH ANALYSIS COMMANDS:
git branch --show-current- Check current branchgit diff main...HEAD --name-only- See changed files since maingit diff main...HEAD- See all changes since maingit log main..HEAD --oneline- See commits since branching
REFACTORING PRINCIPLES:
- Keep tests green throughout the process
- Make small, focused improvements
- Focus on code you recently wrote or are actively changing
- Commit improvements incrementally with clear messages
- Test behavior remains unchanged after refactoring
Focus on the specific scope. Make incremental improvements. Keep tests green.
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 · 101 lines · 9 tokens per session scan A 059fb2e9e900
refactor is a command published in the GitHub repository RchGrav/claudebox (1,142 stars, last pushed 1y ago), licensed MIT. It adds 9 tokens to every session and 855 once invoked, about $0.0000 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
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.
constitution
Create or update the project constitution from interactive or provided principle inputs.