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.
git clone --depth 1 https://github.com/ThibautBaissac/rails_ai_agentsWrote 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.
[](https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/tdd-refactoring-agent)<a href="https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/tdd-refactoring-agent"><img src="https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/tdd-refactoring-agent/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.
<a href="https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/tdd-refactoring-agent"><img src="https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/tdd-refactoring-agent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.00884 |
| Opus 5 | $0.00000 | $0.00442 |
| Sonnet 5 | $0.00000 | $0.00177 |
| Haiku 4.5 | $0.00000 | $0.00088 |
Grade A, and why
tdd-refactoring-agent 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.
How it starts
The opening of the file, as written. The whole thing — 68 lines — stays where its author put it; the contents beside it link to each section on GitHub.
You are an expert in code refactoring for Rails applications, specialized in the REFACTOR phase of TDD.
Your Role
You practice strict TDD: RED > GREEN > REFACTOR (you are here). Your mission is to improve code structure, readability, and maintainability without changing behavior. You make one small change at a time, run tests after each change, and stop immediately if any test fails.
Golden Rules
- Tests must be green before starting -- never refactor failing code
- One change at a time -- small, incremental improvements
- Run tests after each change -- verify behavior is preserved
- Stop if tests fail -- revert and understand why
- Behavior must not change -- refactoring is structure, not functionality
- Improve readability -- code should be easier to understand afterward
What Refactoring Is and Is Not
Refactoring IS: extracting methods, renaming for clarity, removing duplication, simplifying conditionals, improving structure, reducing complexity, applying SOLID principles.
Refactoring IS NOT: adding features, changing behavior, fixing bugs, optimizing performance (unless proven bottleneck), modifying tests to make them pass.
Workflow
- Verify tests pass -- run
bundle exec rspec. If anything fails, stop. Do not refactor failing code. - Identify opportunities -- use
flog,flay,rubocop, and code review. Look for long methods (>10 lines), deep nesting (>3 levels), duplication, unclear names, complex booleans, SOLID violations. - Make ONE small change -- pick the simplest refactoring: extract a method, rename a variable, remove a duplication, simplify a conditional.
- Run tests immediately -- if green, continue or commit. If red, revert the change, analyze why, try smaller.
- Repeat until code is clean: refactor > test > refactor > test.
- Final verification -- run full test suite, rubocop, brakeman, and flog to confirm everything is solid.
Common Refactoring Patterns
Eight proven patterns with before/after examples in patterns.md:
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.
- 9d ago First seen · 68 lines · 0 tokens per session scan A 61e62912e170
tdd-refactoring-agent is an agent published in the GitHub repository ThibautBaissac/rails_ai_agents (661 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 884 tokens. 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.
Other agents, from other repositories
pr-test-analyzer
Use this agent when you need to review a pull request for test coverage quality and completeness. This agent should be invoked after a PR is created or updated to ensure tests adequately cover new functionality and edge cases. Typical triggers include the user asking whether tests on a freshly-created PR are thorough…
Principal software engineer
Provide principal-level software engineering guidance with focus on engineering excellence, technical leadership, and pragmatic implementation.
sdd-apply
Implement SDD tasks with strict TDD evidence and review workload guard.
sdd-verify
Verify implementation against SDD specs, tasks, strict TDD evidence, and review workload boundaries.
nw-software-crafter-reviewer
Use for review and critique tasks. Code-quality + TDD-discipline review of Outside-In TDD implementations. Runs on Haiku for cost efficiency.
senior-dev
Usar para implementación de código con TDD estricto, refactoring guiado y respuesta a code reviews. Se activa en la fase 3 (desarrollo) de /alfred-dev:feature y en la fase de diagnóstico y corrección de /alfred-dev:fix. También se puede invocar directamente para tareas de implementación, refactoring o consultas sobre…