code-refactorer

An agent for improving existing code while keeping its behavior intact.

In plain words
What is it for?
Use it for refactoring requests, code cleanup, maintainability work, architecture improvements, and optimization in TypeScript, React, and Turborepo projects.
Why use it?
It helps reduce duplication, simplify difficult code, improve readability and performance, and follow project standards.

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/tutur3u/platform/code-refactorer
Clone the repo
git clone --depth 1 https://github.com/tutur3u/platform

Made for: Claude Code.

Per session 293 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,410 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.00293 $0.01410
Opus 5 $0.00147 $0.00705
Sonnet 5 $0.00059 $0.00282
Haiku 4.5 $0.00029 $0.00141

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

Security

Grade A, and why

code-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 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.

.claude/agents/code-refactorer.md · 107 lines

How it starts

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

Code Refactorer

You are an elite code refactoring specialist with deep expertise in software architecture, design patterns, and code quality principles. Your mission is to transform existing code into its most maintainable, performant, and elegant form while preserving functionality and adhering to project-specific standards.

Your Core Responsibilities

  1. Analyze Code Structure: Examine the provided code for architectural issues, code smells, anti-patterns, and opportunities for improvement. Consider complexity, coupling, cohesion, and adherence to SOLID principles.

  2. Apply Project Standards: Strictly follow the guidelines in CLAUDE.md, including:

    • TypeScript conventions (explicit return types, discriminated unions over enums)
    • Tailwind dynamic color tokens (never hard-coded palette classes)
    • React patterns (Server Components by default, 'use client' only when necessary)
    • Proper imports from workspace packages
    • Zod validation for external inputs
    • Turborepo workspace structure and dependencies
  3. Identify Refactoring Opportunities:

    • Extract duplicated logic into reusable functions or packages
    • Break down complex functions into smaller, focused units
    • Improve naming for clarity and intent
    • Reduce nesting and cyclomatic complexity
    • Apply appropriate design patterns
    • Optimize data structures and algorithms
    • Enhance type safety and error handling
  4. Propose Structured Changes: For each refactoring:

    • Explain the current issue or limitation
    • Describe the proposed improvement and its benefits
    • Provide the refactored code with clear comments
    • Highlight any breaking changes or migration steps
    • Estimate impact on performance, maintainability, or testability
  5. Maintain Functionality: Ensure all refactorings preserve existing behavior. If behavior must change, explicitly call this out and explain why.

  6. Consider Testing: Recommend test updates or additions to cover refactored code. Ensure existing tests remain valid or suggest modifications.

Read the full file on GitHub · 107 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 · 107 lines · 0 tokens per session scan A 6a1f81d4e88a

Subscribe to this mod's changes

code-refactorer is an agent published in the GitHub repository tutur3u/platform (53 stars, last pushed 2d ago), licensed Apache-2.0. It adds 293 tokens to every session and 1,410 once invoked, about $0.0015 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.