tdd-refactorer

tdd-refactorer is an agent for Claude Code from kirillgreen/skills. It costs 37 tokens per session (1,553 once invoked), scanned A, original, CC0-1.0.

A coding agent for the refactor phase of test-driven development (TDD), after new code already makes the tests pass. It improves code quality while preserving the existing behavior.

In plain words
What is it for?
Use it to review and refactor implementation files after the GREEN phase, run the specified tests, and report when no refactoring is needed.
Why use it?
It helps clean up an implementation without changing what the tests require. It never edits tests or adds new behavior.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter; mentions CLAUDE.md; mentions AGENTS.md.

Good fit Use it to review and refactor implementation files after the GREEN phase, run the specified tests, and report when no refactoring is needed.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/kirillgreen/skills/tdd-refactorer
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/kirillgreen/skills

Made for: Claude Code.

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 tdd-refactorer

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

Your own site · 80×15
<a href="https://agentmods.dev/agents/kirillgreen/skills/tdd-refactorer"><img src="https://agentmods.dev/badge/agents/kirillgreen/skills/tdd-refactorer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 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,553 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.00037 $0.01553
Opus 5 $0.00018 $0.00776
Sonnet 5 $0.00007 $0.00311
Haiku 4.5 $0.00004 $0.00155

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

Security

Grade A, and why

tdd-refactorer 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 9d 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.

tdd/agents/tdd-refactorer.md · 185 lines

How it starts

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

TDD Refactorer Agent (REFACTOR Phase)

Evaluate implementation quality after GREEN phase and improve code while keeping all tests passing. NEVER modify test files. NEVER add new behavior.

Context Loading

When working on a specific project, look for project-level guidance and load it if present — a CLAUDE.md, AGENTS.md, or *_META.md file in the project root or immediate subfolders, a root README.md, or an index file in docs/. These often hold conventions or links to specs. Determine the project from file paths in the task. Skip if the project is unclear or the task is framework-agnostic.

Agent Spec

Input

type: object
properties:
  test_file_path:
    type: string
    description: Path to the test file (for running tests)
  implementation_files:
    type: array
    items: { type: string }
    description: Paths to implementation files from GREEN phase
  test_run_command:
    type: string
    description: Command to run tests
  refactoring_guideline:
    type: string
    required: false
    description: >
      Optional orchestrator guidance to check during evaluation
      (e.g., "Check dependency directions — lower layers must not
      import from higher layers.")
required: [test_file_path, implementation_files, test_run_command]

Output

type: object
properties:
  action:
    enum: [refactored, no_changes]
  changes:
    type: array
    items:
      type: object
      properties:
        file: { type: string }
        description: { type: string }
  reasoning:
    type: string
    description: Why changes were made or skipped
  test_success_output:
    type: string
    description: Test output proving tests still pass after refactoring
  status:
    enum: [complete, reverted]
required: [action, reasoning, test_success_output, status]

Success Metrics

  • All tests still PASS after changes
  • No test files modified
  • No new behavior added
  • Code quality improved or justified skip

Cost Considerations

  • Recommended model: Sonnet
  • Estimated tokens: ~5-15K per invocation

Read the full file on GitHub · 185 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. 9d ago First seen · 185 lines · 37 tokens per session scan A d7c34b7570c9

Subscribe to this mod's changes

tdd-refactorer is an agent published in the GitHub repository kirillgreen/skills (21 stars, last pushed 5d ago), licensed CC0-1.0. It adds 37 tokens to every session and 1,553 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.