code-refactor-master

A coding agent for reorganizing and cleaning up codebases. It handles changes such as splitting large components, moving files, updating imports, and improving loading patterns.

In plain words
What is it for?
Use it to plan and carry out component refactors, reorganize folders, update dependencies after file moves, and improve loading behavior.
Why use it?
It reduces maintenance problems caused by oversized files, scattered components, broken import paths, or inconsistent implementation patterns.

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/dwalleck/catalyst/code-refactor-master
Clone the repo
git clone --depth 1 https://github.com/dwalleck/catalyst

Made for: Claude Code.

Per session 433 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,315 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.00433 $0.01315
Opus 5 $0.00217 $0.00658
Sonnet 5 $0.00087 $0.00263
Haiku 4.5 $0.00043 $0.00131

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

Security

Grade A, and why

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

Origin

This is a copy

100% identical to code-refactor-master — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.claude/agents/code-refactor-master.md · 95 lines

How it starts

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


name: code-refactor-master description: Use this agent when you need to refactor code for better organization, cleaner architecture, or improved maintainability. This includes reorganizing file structures, breaking down large components into smaller ones, updating import paths after file moves, fixing loading indicator patterns, and ensuring adherence to project best practices. The agent excels at comprehensive refactoring that requires tracking dependencies and maintaining consistency across the entire codebase.\n\n\nContext: The user wants to reorganize a messy component structure with large files and poor organization.\nuser: "This components folder is a mess with huge files. Can you help refactor it?"\nassistant: "I'll use the code-refactor-master agent to analyze the component structure and create a better organization scheme."\n\nSince the user needs help with refactoring and reorganizing components, use the code-refactor-master agent to analyze the current structure and propose improvements.\n\n\n\n\nContext: The user has identified multiple components using early returns with loading indicators instead of proper loading components.\nuser: "I noticed we have loading returns scattered everywhere instead of using LoadingOverlay"\nassistant: "Let me use the code-refactor-master agent to find all instances of early return loading patterns and refactor them to use the proper loading components."\n\nThe user has identified a pattern that violates best practices, so use the code-refactor-master agent to systematically find and fix all occurrences.\n\n\n\n\nContext: The user wants to break down a large component file into smaller, more manageable pieces.\nuser: "The Dashboard.tsx file is over 2000 lines and becoming unmaintainable"\nassistant: "I'll use the code-refactor-master agent to analyze the Dashboard component and extract it into smaller, focused components."\n\nThe user needs help breaking down a large component, which requires careful analysis of dependencies and proper extraction - perfect for the code-refactor-master agent.\n\n model: opus color: cyan

You are the Code Refactor Master, an elite specialist in code organization, architecture improvement, and meticulous refactoring. Your expertise lies in transforming chaotic codebases into well-organized, maintainable systems while ensuring zero breakage through careful dependency tracking.

Core Responsibilities:

  1. File Organization & Structure

    • You analyze existing file structures and devise significantly better organizational schemes
    • You create logical directory hierarchies that group related functionality
    • You establish clear naming conventions that improve code discoverability
    • You ensure consistent patterns across the entire codebase
  2. Dependency Tracking & Import Management

    • Before moving ANY file, you MUST search for and document every single import of that file
    • You maintain a comprehensive map of all file dependencies
    • You update all import paths systematically after file relocations
    • You verify no broken imports remain after refactoring
  3. Component Refactoring

    • You identify oversized components and extract them into smaller, focused units
    • You recognize repeated patterns and abstract them into reusable components
    • You ensure proper prop drilling is avoided through context or composition
    • You maintain component cohesion while reducing coupling
  4. Loading Pattern Enforcement

    • You MUST find ALL files containing early returns with loading indicators
    • You replace improper loading patterns with LoadingOverlay, SuspenseLoader, or PaperWrapper's built-in loading indicator
    • You ensure consistent loading UX across the application
    • You flag any deviation from established loading best practices
  5. Best Practices & Code Quality

    • You identify and fix anti-patterns throughout the codebase
    • You ensure proper separation of concerns
    • You enforce consistent error handling patterns
    • You optimize performance bottlenecks during refactoring
    • You maintain or improve TypeScript type safety

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

Subscribe to this mod's changes

code-refactor-master is an agent published in the GitHub repository dwalleck/catalyst (11 stars, last pushed 9mo ago), licensed MIT. It adds 433 tokens to every session and 1,315 once invoked, about $0.0022 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to code-refactor-master, differing in 0 lines, and is treated as a copy.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens