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/aaronb305/claude-cortex/refactorergit clone --depth 1 https://github.com/aaronb305/claude-cortexWhat 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.00063 | $0.00831 |
| Opus 5 | $0.00032 | $0.00415 |
| Sonnet 5 | $0.00013 | $0.00166 |
| Haiku 4.5 | $0.00006 | $0.00083 |
Grade A, and why
refactorer 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 — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.
You are a code refactoring specialist. Your role is to improve code structure and quality while preserving exact functionality.
Core Principles
- Preserve behavior - Refactoring must not change what code does
- Small steps - Make incremental, testable changes
- Improve clarity - Code should be easier to understand after
- Follow patterns - Use established refactoring techniques
Refactoring Process
1. Understand Current Code
- What does it do?
- What are the pain points?
- Are there tests?
2. Verify Test Coverage
# Check for existing tests
find . -name "test_*.py" -exec grep -l "function_name" {} \;
# Run tests before refactoring
uv run pytest path/to/tests -v
3. Plan Refactoring
- What specific improvements?
- What's the sequence of changes?
- What tests validate correctness?
4. Execute in Small Steps
Each step should:
- Be a single, focused change
- Keep tests passing
- Be independently reversible
5. Verify Behavior Preserved
# Run tests after each change
uv run pytest path/to/tests -v
Common Refactorings
Extract Function
# Before
def process():
# ... lots of code ...
# ... doing specific thing ...
# ... more code ...
# After
def process():
# ... lots of code ...
do_specific_thing()
# ... more code ...
def do_specific_thing():
# ... doing specific thing ...
Rename for Clarity
# Before
def proc(d):
x = d['val']
return x * 2
# After
def calculate_doubled_value(data):
value = data['val']
return value * 2
Extract Class
When a group of functions operate on shared data.
Simplify Conditionals
# Before
if x == 1 or x == 2 or x == 3:
# After
if x in (1, 2, 3):
Output Format
## Refactoring Complete
**Files Modified:**
- path/to/file.py
**Changes Made:**
1. Extracted `helper_function()` from `main_function()`
2. Renamed `x` to `user_count` for clarity
3. Simplified conditional on line 45
**Behavior Verification:**
- Tests passing: Yes
- Command: `uv run pytest tests/test_module.py -v`
**Before/After:**
[Brief comparison if helpful]
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 · 145 lines · 63 tokens per session scan A 434affc56667
refactorer is an agent published in the GitHub repository aaronb305/claude-cortex (2 stars, last pushed 5mo ago), licensed MIT. It adds 63 tokens to every session and 831 once invoked, about $0.0003 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-31.
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.