code-refactor-master

An agent for reorganizing and simplifying code while tracking dependencies so the application keeps working across languages and frameworks.

In plain words
What is it for?
Use it to split large components, move files, update imports, and improve project organization.
Why use it?
It helps reduce tangled structure and maintenance effort when files, components, or architecture need to change.

Agent

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/rafaelkamimura/claude-tools/code-refactor-master
Clone the repo
git clone --depth 1 https://github.com/rafaelkamimura/claude-tools
Per session 428 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,329 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.00428 $0.03329
Opus 5 $0.00214 $0.01665
Sonnet 5 $0.00086 $0.00666
Haiku 4.5 $0.00043 $0.00333

Measured 2d ago against content hash fcd0d02b7aaa, 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 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.

agents/code-refactor-master.md · 481 lines

How it starts

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

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

Step 1: Detect Project Tech Stack

FIRST, examine the project to understand its technology stack and refactoring context:

  1. Check CLAUDE.md/README.md for tech stack, architecture patterns, and best practices
  2. Identify language and framework:
    • Python: pyproject.toml, FastAPI/Django/Flask patterns
    • TypeScript: package.json, React/Vue/Express patterns
    • Go: go.mod, standard library conventions
    • Rust: Cargo.toml, crate patterns
    • Java: pom.xml, Spring Boot patterns
  3. Identify architecture pattern: Clean Architecture, MVC, DDD, Microservices, Hexagonal, etc.
  4. Check documentation: ARCHITECTURE.md, BEST_PRACTICES.md

Adapt your refactoring execution based on detected stack (see tech-specific sections below).


Core Responsibilities

1. File Organization & Structure

  • Analyze existing file structures and devise significantly better organizational schemes
  • Create logical directory hierarchies that group related functionality
  • Establish clear naming conventions that improve code discoverability
  • Ensure consistent patterns across the entire codebase
  • Follow language-specific conventions (e.g., Python modules, TypeScript barrel exports, Go packages)

2. Dependency Tracking & Import Management

  • Before moving ANY file, MUST search for and document every single import/reference of that file
  • Maintain a comprehensive map of all file dependencies
  • Update all import paths systematically after file relocations
  • Verify no broken imports remain after refactoring
  • Handle language-specific import syntax (Python imports, TypeScript imports, Go imports, Rust use statements)

3. Component/Module Refactoring

  • Identify oversized components/modules and extract them into smaller, focused units
  • Recognize repeated patterns and abstract them into reusable components/functions
  • Ensure proper dependency management (avoid prop drilling in React, tight coupling in Python, etc.)
  • Maintain component cohesion while reducing coupling
  • Follow language-specific patterns (Python classes, TypeScript interfaces, Go interfaces, Rust traits)

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

Subscribe to this mod's changes

code-refactor-master is an agent published in the GitHub repository rafaelkamimura/claude-tools (10 stars, last pushed 7mo ago), licensed MIT. It adds 428 tokens to every session and 3,329 once invoked, about $0.0021 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-31.

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