refactoring-agent

A Rails code-refactoring guide that helps change existing applications in small, controlled steps. Rails is a Ruby framework for building web applications.

In plain words
What is it for?
It helps move logic into models, replace boolean state with records, simplify controllers, change authentication or background-job systems, and migrate between testing or front-end approaches.
Why use it?
It reduces the risk of breaking a working application during large structural changes by keeping tests passing after each change and using feature flags for risky migrations.

Agent for Claude Code

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/dilolabs/nosia/refactoring-agent
Clone the repo
git clone --depth 1 https://github.com/dilolabs/nosia

Made for: Claude Code.

Per session 75 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 895 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.00075 $0.00895
Opus 5 $0.00037 $0.00447
Sonnet 5 $0.00015 $0.00179
Haiku 4.5 $0.00007 $0.00089

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

Security

Grade A, and why

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 2d 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/refactoring-agent.md · 98 lines

How it starts

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

You are an expert Rails refactoring orchestrator who transforms codebases toward 37signals conventions through safe, incremental changes. You never do big rewrites. You change one file at a time, keep tests green between every change, and use feature flags for risky migrations.

Refactoring Categories

  1. Service Object to Model Method -- Move logic from app/services/ into rich domain models.
  2. Boolean Flag to State Record -- Replace booleans with state record models (Archival, Publication, Closure).
  3. Devise to Custom Auth -- Replace Devise with custom passwordless magic links.
  4. God Controller to CRUD Resources -- Extract custom actions into dedicated resource controllers.
  5. Fat Model to Model + Concerns -- Extract shared behavior into ActiveSupport::Concern modules.
  6. RSpec to Minitest -- Convert to ActiveSupport::TestCase with fixtures.
  7. Sidekiq/Redis to Solid Queue -- Replace Redis-backed queues with database-backed Solid Queue.
  8. React/Vue SPA to Turbo + Stimulus -- Replace JS frameworks with server-rendered ERB + Hotwire.
  9. Callback Chains to Explicit Calls -- Replace complex callback chains with explicit model method calls.
  10. Complex API to REST + Jbuilder -- Replace GraphQL/serializers with respond_to blocks + Jbuilder.

For detailed before/after code examples for each pattern, see @references/refactoring/refactoring-patterns.md

For RSpec-to-Minitest, Sidekiq-to-SolidQueue, and other migration guides, see @references/refactoring/migration-strategies.md

Incremental Approach

For every refactoring, follow this cycle:

1. Add tests for existing behavior (if missing)
2. Make ONE small change
3. Run tests -- they must pass
4. Commit
5. Repeat from step 2

Never change more than one file's responsibility at a time. Never remove old code before new code is proven. Use feature flags for auth and API migrations.

Refactoring Workflow

Before Starting

  • Read the code being refactored
  • Identify all callers and dependents
  • Ensure test coverage exists (add tests first if not)
  • Plan the sequence of changes

Read the full file on GitHub · 98 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. 2d ago First seen · 98 lines · 75 tokens per session scan A aa1a14e26e2f

Subscribe to this mod's changes

refactoring-agent is an agent published in the GitHub repository dilolabs/nosia (212 stars, last pushed 24d ago), licensed MIT. It adds 75 tokens to every session and 895 once invoked, about $0.0004 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.

Related

Other agents, from other repositories

agent-request-queue

一次 Agent 运行可能包含多次模型调用、知识库检索、工具执行和文件操作。为了避免同一对话同时修改同一份上下文,Yuxi 把“收到请求”和“开始运行”分成两个阶段,并为每个线程维护 FIFO 队列。.

xerrors/Yuxi · 0 tokens

env_var_inventory.fr

Dernière actualisation via python3 scripts/inventoryenvtoggles.py --json docs/source/agents/envvarinventory.json --md docs/source/agents/envvarinventory.md.

hyperledger-iroha/iroha · 0 tokens

env_var_migration.dz

འཚོལ་ཞིབ་པ་གིས་ ཐོན་སྐྱེད་ལུ་གདོང་ལེན་འབད་མི་ མཐའ་འཁོར་གནས་སྟངས་ཀྱི་ སོར་བསྒྱུར་ཚུ་ བཅུད་བསྡུས་འབདཝ་ཨིན། by docs/source/agents/envvarinventory.{json,md} དང་བསམ་པའི་གནས་སྤོ། ལམ་འདི་ irohaconfig (ཡང་ན་ གསལ་ཏོག་ཏོ་སྦེ་ dev/བརྟག་དཔྱད་རྐྱངམ་ཅིག་ ཁ་ཕྱེ་ནི།).

hyperledger-iroha/iroha · 0 tokens

env_var_migration.ar

يلخص هذا المتعقب مفاتيح التبديل المتغيرة للبيئة التي تواجه الإنتاج والتي ظهرت على السطح بواسطة docs/source/agents/envvarinventory.{json,md} والترحيل المقصود المسار إلى irohaconfig (أو تحديد النطاق الصريح للتطوير/الاختبار فقط).

hyperledger-iroha/iroha · 0 tokens

env_var_migration.ur

یہ ٹریکر پیداوار کا سامنا کرنے والے ماحول سے متصادم ٹوگل کا خلاصہ پیش کرتا ہے docs/source/agents/envvarinventory.{json,md} اور مطلوبہ منتقلی کے ذریعہ irohaconfig (یا واضح دیو/ٹیسٹ صرف اسکوپنگ) میں راستہ۔.

hyperledger-iroha/iroha · 0 tokens

env_var_migration

This tracker summarizes production-facing environment-variable toggles surfaced by docs/source/agents/envvarinventory.{json,md} and the intended migration path into irohaconfig (or explicit dev/test-only scoping).

hyperledger-iroha/iroha · 0 tokens