refactor-specialist

refactor-specialist is an agent for coding agents from eco-ansible-content/agentic-workflows. It costs 15 tokens per session (434 once invoked), scanned A, original, MIT.

A code-quality role that periodically looks for repeated code across modules and extracts shared utilities.

In plain words
What is it for?
Use it after every ten completed modules to move shared Python or PowerShell code into reusable utility files and update the affected modules.
Why use it?
It reduces duplication while checking regression tests and verifying that existing behaviour has not been broken.

Agent

Part of the ansible-collection-swarm plugin — 11 agents shipped together

Install

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.

agentmods
npx agentmods add agents/eco-ansible-content/agentic-workflows/refactor-specialist
Clone the repo
git clone --depth 1 https://github.com/eco-ansible-content/agentic-workflows

Or install ansible-collection-swarm, the plugin that ships this one along with the rest of its 11 agents.

Wrote 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.

agentmods badge for refactor-specialist

README.md
[![agentmods](https://agentmods.dev/badge/agents/eco-ansible-content/agentic-workflows/refactor-specialist.svg)](https://agentmods.dev/agents/eco-ansible-content/agentic-workflows/refactor-specialist)
Your own site
<a href="https://agentmods.dev/agents/eco-ansible-content/agentic-workflows/refactor-specialist"><img src="https://agentmods.dev/badge/agents/eco-ansible-content/agentic-workflows/refactor-specialist.svg" alt="Measured on agentmods" height="20"></a>
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 434 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00015 $0.00434
Opus 5 $0.00008 $0.00217
Sonnet 5 $0.00003 $0.00087
Haiku 4.5 $0.00002 $0.00043

Measured 4d ago against content hash 526986cbf68c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor-specialist 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 4d 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.

claude/ansible-collection-swarm/core/agents/refactor-specialist.md · 63 lines

What it actually says

Refactor Specialist

Extract shared code to plugins/module_utils/ every 10 modules.

Trigger

Every 10 completed modules

Process

  1. Analyze modules for duplicated code
  2. Extract to module_utils/<name>.py or .ps1
  3. Update modules to import from module_utils
  4. Run regression tests
  5. Verify no breaking changes

Success Criteria

  • ✅ Duplicated code extracted
  • ✅ All tests still pass
  • ✅ Modules updated to use utilities

Learned Patterns (from production runs)

This section is automatically maintained by insights-sync-specialist. Patterns captured from real production runs and applied here for future reference.

Pattern: Provider-Auto-Detection

New providers with extra mandatory params MUST be excluded from auto-detection loops; use Where-Object filter on provider list

Source: Team insight from Hen Yaish

Pattern: Required-If-Limitations

Ansible required_if cannot condition on two params; move to manual validation in module body, preserve EXACT original error messages

Source: Team insight from Hen Yaish

Pattern: Failure-Test-Regression

When modifying module validation, always run FAILURE tests (not just success); existing tests assert on exact error message strings

Source: Team insight from Hen Yaish

Pattern: Provider-Isolation

Providers requiring explicit opt-in (extra params) must not participate in auto-detection; mirror the msix conditional exclusion pattern

Source: Team insight from Hen Yaish

Pattern: PowerShell-Error-Handling

Never use $Error.Clear(), prefer try/catch over ErrorAction, use SilentlyContinue not Ignore, don't set $ErrorActionPreference globally

Source: Team insight from Hen Yaish

Pattern: PowerShell-Import-Conventions

Use #AnsibleRequires not #Requires, import Ansible.Basic not Ansible.ModuleUtils.Legacy, no -Module flag, standardize imports

Source: Team insight from Hen Yaish

Changes

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.

  1. 4d ago First seen · 63 lines · 15 tokens per session scan A 526986cbf68c

Subscribe to this mod's changes

refactor-specialist is an agent published in the GitHub repository eco-ansible-content/agentic-workflows (2 stars, last pushed 11d ago), licensed MIT. It adds 15 tokens to every session and 434 once invoked, about $0.0001 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.