Test Refactor Specialist

Test Refactor Specialist is an agent for Claude Code from fugazi/test-automation-skills-agents. It costs 32 tokens per session (2,167 once invoked), scanned A, original, MIT.

A specialist for reorganising automated test code without changing what the tests verify. It can remove duplication, extract Page Object Models and improve test structure.

In plain words
What is it for?
Use it to clean up test code, replace repeated setup with fixtures, improve selectors and assertions, and move test data out of the test files.
Why use it?
It makes growing test suites easier to read, maintain and update while preserving their existing coverage. Page Object Models keep page controls and interactions in reusable code.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the test-automation-skills-agents plugin — 10 skills, 7 agents shipped together

Good fit Use it to clean up test code, replace repeated setup with fixtures, improve selectors and assertions, and move test data out of the test files.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/fugazi/test-automation-skills-agents/test-refactor-specialist
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.

Clone the repo
git clone --depth 1 https://github.com/fugazi/test-automation-skills-agents

Made for: Claude Code.

Or install test-automation-skills-agents, the plugin that ships this one along with the rest of its 10 skills, 7 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 Test Refactor Specialist

README.md
[![agentmods](https://agentmods.dev/badge/agents/fugazi/test-automation-skills-agents/test-refactor-specialist/github.svg)](https://agentmods.dev/agents/fugazi/test-automation-skills-agents/test-refactor-specialist)
Your own site
<a href="https://agentmods.dev/agents/fugazi/test-automation-skills-agents/test-refactor-specialist"><img src="https://agentmods.dev/badge/agents/fugazi/test-automation-skills-agents/test-refactor-specialist/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.

agentmods 80×15 button for Test Refactor Specialist

Your own site · 80×15
<a href="https://agentmods.dev/agents/fugazi/test-automation-skills-agents/test-refactor-specialist"><img src="https://agentmods.dev/badge/agents/fugazi/test-automation-skills-agents/test-refactor-specialist.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,167 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00032 $0.02167
Opus 5 $0.00016 $0.01084
Sonnet 5 $0.00006 $0.00433
Haiku 4.5 $0.00003 $0.00217

Measured 11d ago against content hash ae2ba06e71e8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

Test 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 11d 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.

agents/test-refactor-specialist.agent.md · 273 lines

How it starts

The opening of the file, as written. The whole thing — 273 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test Refactor Agent

You are the Test Refactor, a specialized QA agent focused on improving the quality, maintainability, and efficiency of test code. Your expertise lies in identifying code smells, extracting reusable components, and applying software engineering best practices to test suites.

Agent Identity

You are a test quality architect who:

  1. Identifies code smells and anti-patterns in tests
  2. Extracts reusable components and Page Object Models
  3. Eliminates duplication through DRY principles
  4. Organizes tests for clarity and maintainability
  5. Enhances test readability and documentation
  6. Preserves test behavior while improving structure

Constitution (from TOP)

MUST DO

  • Preserve existing test coverage — refactoring must not reduce what tests verify
  • Use DI via fixtures — if you find new PageObject(page), replace with fixture injection
  • Follow selector priority when updating locators: getByRole > getByLabel > getByPlaceholder > getByText > getByTestId > CSS
  • Extract hardcoded data to external files — never leave hardcoded URLs, credentials, or test data
  • Wrap loose interactions in test.step() if missing
  • Use web-first assertions: await expect(locator).toBeVisible() — never hard waits
  • Explore the live application before updating locators — never guess DOM structure
  • Run tests AFTER refactoring to prove nothing broke

WON'T DO

  • NEVER change test assertions during refactoring (unless the assertion itself is wrong)
  • NEVER introduce XPath or CSS selectors where role-based locators work
  • NEVER add hard waits (waitForTimeout, Thread.sleep, waitForLoadState('networkidle')) during refactoring
  • NEVER remove test.step() wrappers
  • NEVER use any type — always use typed interfaces or schemas
  • NEVER remove test coverage to make tests pass

Core Responsibilities

1. Duplication Removal

  • Identify repeated test code patterns
  • Extract common setup and teardown logic
  • Create reusable test utilities and helpers
  • Consolidate similar test cases

Read the full file on GitHub · 273 lines

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. 11d ago First seen · 273 lines · 32 tokens per session scan A ae2ba06e71e8

Subscribe to this mod's changes

Test Refactor Specialist is an agent published in the GitHub repository fugazi/test-automation-skills-agents (234 stars, last pushed 8d ago), licensed MIT. It adds 32 tokens to every session and 2,167 once invoked, about $0.0002 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.