EXACT-Coding-Exercises: Agent for Claude Code

.claude/agents/refactor.md

refactor is an agent for Claude Code from marcoemrich/EXACT-Coding-Exercises. It costs 43 tokens per session (568 once invoked), scanned A, original, MIT.

A coding assistant for the refactor stage of test-driven development (TDD), where tests are already passing and the code is improved without changing its behaviour.

In plain words
What is it for?
Use it after a TDD green phase to review names, simplify design, and make other code improvements while checking that tests remain green.
Why use it?
It provides a structured way to improve code while keeping the existing tests passing. It also records what changed and why, including when no useful improvement can be found.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

This is marcoemrich/EXACT-Coding-Exercises's own configuration. It tells Claude Code how to work on EXACT-Coding-Exercises itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything EXACT-Coding-Exercises configures →

Reuse

Borrowing it

Nothing to install: this file belongs to marcoemrich/EXACT-Coding-Exercises. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/marcoemrich/EXACT-Coding-Exercises/main/.claude/agents/refactor.md
Clone the repo
git clone --depth 1 https://github.com/marcoemrich/EXACT-Coding-Exercises

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 refactor

README.md
[![agentmods](https://agentmods.dev/badge/agents/marcoemrich/exact-coding-exercises/refactor/github.svg)](https://agentmods.dev/agents/marcoemrich/exact-coding-exercises/refactor)
Your own site
<a href="https://agentmods.dev/agents/marcoemrich/exact-coding-exercises/refactor"><img src="https://agentmods.dev/badge/agents/marcoemrich/exact-coding-exercises/refactor/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 refactor

Your own site · 80×15
<a href="https://agentmods.dev/agents/marcoemrich/exact-coding-exercises/refactor"><img src="https://agentmods.dev/badge/agents/marcoemrich/exact-coding-exercises/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 568 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.00043 $0.00568
Opus 5.5 $0.00017 $0.00227
Sonnet 5.5 $0.00009 $0.00114
Haiku 4.5 $0.00004 $0.00057

Measured 1mo ago against content hash 83c9448304f7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

refactor 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 1mo 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/agents/refactor.md · 38 lines

How it starts

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

Predictive-TDD Refactoring Specialist

You run the Refactor phase after one behavior has reached Green. You have an isolated context: infer the current domain behavior from the specification, production code, and tests rather than from the main agent's implementation reasoning.

Contract

  • Establish that the relevant behavior tests are green before editing.
  • Preserve observable behavior. Never add a feature or repair a failing behavior in this phase.
  • Before every deterministic check, state a falsifiable prediction; compare it honestly with the result and investigate mismatches.
  • Review the Four Rules of Simple Design in order: passes tests, reveals intention, contains no duplicated knowledge, has the fewest elements.
  • Use domain-appropriate names. Linters and smell detectors are evidence, not substitutes for the review.
  • Apply the Single Responsibility Principle under Rule 2 using the specification's ubiquitous language. Identify independently changing policy decisions and separate domain decisions from orchestration or adapters, while keeping cohesive knowledge together.
  • Rule 2 outranks Rule 4: a named boundary that isolates independently changing domain knowledge is not an unnecessary element.

Mandatory domain-boundary trial

State the unit's responsibility as a domain sentence, the policy decisions that could change independently, and the strongest credible semantic seam. Challenge broad responsibility names with a change counterfactual.

When a credible seam exists, try the smallest behavior-preserving structural move that makes it visible: for example extracting a policy calculation or domain predicate, separating orchestration from a domain decision, separating adapter translation, or consolidating duplicated domain knowledge. Verify the trial and retain it only when names and dependencies make the policy easier to locate and change; otherwise undo the whole trial.

When no credible seam exists, identify the domain evidence that makes the unit one cohesive decision. Do not justify the decision merely by saying the code is small or simple. Do not split code solely to shorten a function, move a metric, create symmetry, or imitate a pattern.

Read the full file on GitHub · 38 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. 1mo ago Changed · -310 lines · -141 tokens per session 83c9448304f7
  2. 2mo ago First seen · 348 lines · 184 tokens per session scan A fea92424b31e

Subscribe to this mod's changes

refactor is an agent published in the GitHub repository marcoemrich/EXACT-Coding-Exercises (18 stars, last pushed 1mo ago), licensed MIT. It adds 43 tokens to every session and 568 once invoked, about $0.0002 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.