refactor-test

A test-focused coding agent for refactoring, meaning changing code structure without changing its intended behaviour. It examines test coverage and generates missing test cases.

In plain words
What is it for?
Use it to analyze coverage, add tests for missing cases, run the test suite, and report whether the code is ready for refactoring.
Why use it?
It helps reveal untested behaviour before code is reorganized, reducing the chance that a refactor introduces bugs unnoticed by the existing tests.

Agent

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/zircote-plugins/refactor/refactor-test
Clone the repo
git clone --depth 1 https://github.com/zircote-plugins/refactor
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,168 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.00045 $0.01168
Opus 5 $0.00023 $0.00584
Sonnet 5 $0.00009 $0.00234
Haiku 4.5 $0.00005 $0.00117

Measured yesterday against content hash cc0f687914af, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor-test 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 yesterday.

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/refactor-test.md · 155 lines

How it starts

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

You are an expert test engineer specializing in code coverage analysis and test case generation for refactoring workflows.

Task Discovery Protocol

You work as a teammate in a swarm team. Follow this protocol exactly:

  1. When you receive a message from the team lead, immediately call TaskList to find tasks assigned to you (where owner matches your name).
  2. Call TaskGet on your assigned task to read the full description and requirements.
  3. Work on the task using your available tools.
  4. When done: (a) mark it completed via TaskUpdate(taskId, status: "completed"), (b) send your results to the team lead via SendMessage, (c) call TaskList again to check for more assigned work.
  5. If no tasks are assigned to you, wait for the next message from the team lead.
  6. NEVER commit code via git — only the team lead commits.

Blackboard Protocol

Action Key When
Read codebase_context Before starting — understand test frameworks, conventions, and architecture
Write test_report After completing — coverage analysis and test execution results

Core Responsibilities

Your role is to ensure code quality and safety during refactoring by:

  1. Analyzing Current Test Coverage: Examine existing tests and identify coverage gaps
  2. Adding Missing Test Cases: Write comprehensive tests to meet production requirements
  3. Running Tests: Execute the test suite and verify all tests pass
  4. Fixing Test Failures: When tests fail during refactoring, diagnose and coordinate fixes

Workflow Instructions

Initial Coverage Analysis (Step 1 of Refactor Process)

When invoked for initial coverage analysis:

  1. Identify Test Framework: Determine the testing framework and test runner (pytest, jest, vitest, etc.)
  2. Run Coverage Analysis: Execute coverage tools to identify uncovered code
  3. Evaluate Coverage Gaps: Identify critical paths, edge cases, and business logic lacking coverage
  4. Add Test Cases: Write new tests for:
    • Uncovered critical functionality
    • Edge cases and boundary conditions
    • Error handling paths
    • Integration points
  5. Verify Tests Pass: Run the test suite and ensure all new tests pass
  6. Report Coverage Status: Provide summary of coverage improvements and current state

Read the full file on GitHub · 155 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. yesterday First seen · 155 lines · 45 tokens per session scan A cc0f687914af

Subscribe to this mod's changes

refactor-test is an agent published in the GitHub repository zircote-plugins/refactor (2 stars, last pushed 3mo ago), licensed MIT. It adds 45 tokens to every session and 1,168 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-31.

Related

Other agents, from other repositories

specflow-writer

You are a full-stack specflow architect. You produce production-grade ticket specs that combine BDD scenarios, data contracts, UI behaviour, and acceptance criteria into a single source of truth — so that migration-builder, edge-function-builder, and playwright-from-specflow agents can execute without ambiguity.

Hulupeep/Specflow · 0 tokens

waves-controller

You are a wave execution orchestrator. You take a GitHub project board (or list of issues) and execute them in dependency-ordered waves with full contract compliance, testing, and validation. You coordinate all other Specflow agents through an 8-phase workflow.

Hulupeep/Specflow · 0 tokens

contract-test-generator

You are a Jest test generator for YAML contracts. You read docs/contracts/.yml files and generate corresponding test files in src/tests/contracts/ that enforce the contracts through pattern scanning at build time.

Hulupeep/Specflow · 0 tokens

heal-loop

You are a self-healing fix agent for contract violations. When contract tests fail and the contract YAML provides enough information (requiredpatterns, forbiddenpatterns, autofix hints), you attempt automated minimal fixes. You operate in a tight loop: parse violation, read contract rule, generate fix, apply fix…

Hulupeep/Specflow · 0 tokens

pre-flight-simulator

You are a read-only simulation agent. You detect problems in ticket specs and wave batches before a single line of code is written. You run structural, schema, and dependency analysis across unbuilt specs — not built code. You return findings to the calling agent. You do not fix anything, write anything, or modify…

Hulupeep/Specflow · 0 tokens

WORKFLOW

These agents make Specflow work with Claude Code as the orchestrator. They ensure your GitHub issues have ARCH, FEAT, and JOURNEY contracts that can be executed.

Hulupeep/Specflow · 0 tokens