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 oyi77/1ai-skills --skill refactor-agentgit clone --depth 1 https://github.com/oyi77/1ai-skillsWrote 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/oyi77/1ai-skills/refactor-agent)<a href="https://agentmods.dev/skills/oyi77/1ai-skills/refactor-agent"><img src="https://agentmods.dev/badge/skills/oyi77/1ai-skills/refactor-agent/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/oyi77/1ai-skills/refactor-agent"><img src="https://agentmods.dev/badge/skills/oyi77/1ai-skills/refactor-agent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
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.00022 | $0.01276 |
| Opus 5.5 | $0.00009 | $0.00510 |
| Sonnet 5.5 | $0.00004 | $0.00255 |
| Haiku 4.5 | $0.00002 | $0.00128 |
Grade A, and why
refactor-agent 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 2mo 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 — 149 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Overview
This agent restructures code to improve readability, maintainability, and extensibility without changing observable behavior. Use it when a module has grown past the point where it can be extended safely. It preserves contracts and verifies behavior after every move.
Refactor Agent
Quick Reference — see parent for full agent ecosystem.
The Refactor Agent restructures code to improve readability, maintainability, and extensibility without changing external behavior. It systematically identifies high-complexity functions, duplicated logic, dead code, and tightly coupled modules; then applies targeted refactorings (extract method, split module, introduce interface, remove duplication) with verification that all existing tests still pass. Its mantra: make the change easy, then make the easy change.
When Not to Use
- Simple or one-off tasks — if the task is straightforward, direct execution is faster than structured methodology.
- Already established workflows — follow existing team conventions rather than introducing new frameworks.
- When automation overhead exceeds benefit — for very small scopes, the setup cost may not be justified.
Dependencies
- Python 3.8+ or Node.js 18+
- Access to relevant APIs/services for your specific use case
- Basic understanding of the domain concepts
Commands
# Refer to the skill's usage section for specific commands
# Adapt these to your workflow
Key Responsibilities
- Measure complexity: Calculate cyclomatic complexity, cognitive complexity, and coupling metrics to identify the files that need refactoring most
- Apply pattern-driven refactors: Extract methods, split monoliths, introduce abstractions, remove dead code — each with a defined before/after signature
- Preserve behavior: Run the full test suite before and after every refactoring step to confirm zero behavioral changes
Code Example
"""Minimal refactor agent pattern — analyze and restructure."""
import json, sys
from pathlib import Path
def analyze_complexity(file_path: str) -> dict:
"""Analyze a file for refactoring candidates."""
content = Path(file_path).read_text()
lines = content.split("\n")
functions = []
current_fn = None
fn_lines = 0
branch_count = 0
for i, line in enumerate(lines):
stripped = line.strip()
if stripped.startswith("def ") or stripped.startswith("async def "):
if current_fn:
functions.append({
"name": current_fn, "lines": fn_lines,
"branches": branch_count, "line": i - fn_lines + 1
})
current_fn = stripped.split("(")[0].replace("def ", "").replace("async ", "")
fn_lines = 1
branch_count = 0
elif current_fn:
fn_lines += 1
if any(kw in stripped for kw in ["if ", "elif ", "for ", "while ", "and ", "or "]):
branch_count += 1
if current_fn:
functions.append({
"name": current_fn, "lines": fn_lines,
"branches": branch_count, "line": len(lines) - fn_lines + 1
})
candidates = [f for f in functions if f["branches"] > 10 or f["lines"] > 50]
return {
"file": file_path, "total_lines": len(lines),
"functions": functions,
"candidates": candidates,
"recommendations": [
f"Extract method: {c['name']} ({c['branches']} branches, {c['lines']} lines)"
for c in candidates
]
}
if __name__ == "__main__":
result = analyze_complexity(sys.argv[1])
print(json.dumps(result, indent=2))
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.
- 2mo ago Changed · +11 lines 832c73f46200
- 3mo ago First seen · 138 lines · 22 tokens per session scan A bbee8736d733
refactor-agent is a skill published in the GitHub repository oyi77/1ai-skills (19 stars, last pushed today), licensed MIT. It adds 22 tokens to every session and 1,276 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.
refactor-agent compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| refactor-agentoyi77/1ai-skills | Skill | 19 | today | MIT | A | 22 | Claude Code |
| coderaiskillstore/marketplace | Skill | 509 | today | none | A | 36 | Claude Code, Codex |
| adk-unit-designgoogle/adk-python | Skill | 22k | today | Apache-2.0 | A | 181 | Claude Code, Codex |
| artifact-deploykirodotdev/KiroCrew | Skill | 5.2k | today | Apache-2.0 | A | 74 | Claude Code, Codex |
| explain-forkirodotdev/KiroCrew | Skill | 5.2k | today | Apache-2.0 | A | 71 | Claude Code, Codex |
| session-summarieskirodotdev/KiroCrew | Skill | 5.2k | today | Apache-2.0 | A | 53 | Claude Code, Codex |
| choosing-swarm-patternsAgentWorkforce/relay | Skill | 1.2k | today | Apache-2.0 | A | 76 | Claude Code, Codex |