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 skills add asgarovf/locusai --skill refactoringgit clone --depth 1 https://github.com/asgarovf/locusaiWrote 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/skills/asgarovf/locusai/refactoring)<a href="https://agentmods.dev/skills/asgarovf/locusai/refactoring"><img src="https://agentmods.dev/badge/skills/asgarovf/locusai/refactoring/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/skills/asgarovf/locusai/refactoring"><img src="https://agentmods.dev/badge/skills/asgarovf/locusai/refactoring.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.00031 | $0.01441 |
| Opus 5.5 | $0.00012 | $0.00576 |
| Sonnet 5.5 | $0.00006 | $0.00288 |
| Haiku 4.5 | $0.00003 | $0.00144 |
Grade A, and why
refactoring 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 1mo 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 — 215 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactoring
When to use this skill
- Code is hard to read or understand
- Duplicated logic across multiple places
- Functions or classes are too large
- Adding a feature requires touching too many files
- Code smells identified during review
- Preparing code for a new feature
Golden rule
Refactoring must not change behavior. Tests should pass before and after. If no tests exist, write them first.
# Run tests before starting
npm test # or pytest, go test, etc.
# Make refactoring changes
# Run tests after every change
npm test
Common refactoring patterns
Extract function
When a block of code does one distinct thing:
// Before
function processOrder(order: Order) {
// validate
if (!order.items.length) throw new Error('Empty order');
if (order.items.some(i => i.quantity <= 0)) throw new Error('Invalid quantity');
if (!order.customerId) throw new Error('No customer');
// calculate total
let total = 0;
for (const item of order.items) {
total += item.price * item.quantity;
}
const tax = total * 0.1;
const finalTotal = total + tax;
// save
db.save({ ...order, total: finalTotal });
}
// After
function validateOrder(order: Order): void {
if (!order.items.length) throw new Error('Empty order');
if (order.items.some(i => i.quantity <= 0)) throw new Error('Invalid quantity');
if (!order.customerId) throw new Error('No customer');
}
function calculateTotal(items: OrderItem[]): number {
const subtotal = items.reduce((sum, i) => sum + i.price * i.quantity, 0);
return subtotal * 1.1; // includes 10% tax
}
function processOrder(order: Order) {
validateOrder(order);
const total = calculateTotal(order.items);
db.save({ ...order, total });
}
Replace conditional with polymorphism
// Before: switch on type
function calculateShipping(order: Order): number {
switch (order.shippingType) {
case 'standard': return order.weight * 1.5;
case 'express': return order.weight * 3.0 + 10;
case 'overnight': return order.weight * 5.0 + 25;
default: throw new Error('Unknown shipping type');
}
}
// After: strategy pattern
const shippingStrategies: Record<string, (weight: number) => number> = {
standard: (weight) => weight * 1.5,
express: (weight) => weight * 3.0 + 10,
overnight: (weight) => weight * 5.0 + 25,
};
function calculateShipping(order: Order): number {
const strategy = shippingStrategies[order.shippingType];
if (!strategy) throw new Error('Unknown shipping type');
return strategy(order.weight);
}
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.
- 1mo ago First seen · 215 lines · 31 tokens per session scan A d7b74ef53d3d
refactoring is a skill published in the GitHub repository asgarovf/locusai (23 stars, last pushed 7mo ago), licensed MIT. It adds 31 tokens to every session and 1,441 once invoked, about $0.0001 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.
Other skills, from other repositories
refactoring-patterns
Apply safe refactoring patterns to improve code structure without changing behavior. Use when cleaning up code, reducing technical debt, or improving maintainability.
refactoring-workflow
Improve the structure of existing code without changing its behaviour, in small verified steps under a green test suite. Use when the user asks to refactor, clean up, restructure or simplify code, wants to reduce duplication or coupling, is preparing a codebase for a feature it cannot currently accommodate, or when…
code-quality-review
A code-review guide for judging whether software stays easy to understand, change, test, and extend.
code-refactor
A guide for changing existing code while keeping its observable behavior the same. It covers tasks such as splitting files, extracting methods, renaming, removing unused code, and reducing duplication.
arch-optimize
A software architecture review workflow that scans a codebase for structural risks and measures code quality. It checks issues such as overly complex code, repeated knowledge, changes spreading across many files, circular dependencies, and distorted domain models.
refactor-agent
Safe, systematic code refactoring — extract functions, reduce complexity, eliminate duplication, improve naming. Use when improving code structure without changing behavior.