claude-code-infrastructure-showcase: Agent for Claude Code

.claude/agents/code-refactor-master.md

code-refactor-master is an agent for Claude Code from diet103/claude-code-infrastructure-showcase. It costs 0 tokens per session (1,315 once invoked), scanned A, original, MIT.

A code-refactoring specialist for reorganizing files, improving architecture, and making code easier to maintain. Refactoring changes the internal structure of code without changing what it is meant to do.

In plain words
What is it for?
It helps plan file structures, track dependencies, update import paths, split oversized components, extract reusable parts, and check for broken imports.
Why use it?
It helps reduce disorder and the risk of broken imports or behavior when files move, large components are split, or repeated patterns are reorganized.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter.

This is diet103/claude-code-infrastructure-showcase's own configuration. It tells Claude Code how to work on claude-code-infrastructure-showcase itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-code-infrastructure-showcase configures →

About the project

Claude Code Infrastructure Showcase is a reference library of configuration patterns for Claude Code, including skills, hooks, agents, and commands that shape how the coding agent works. It helps developers organize and automate Claude Code in their own projects, especially larger TypeScript codebases. The catalogue entries are examples of infrastructure that users can copy into their projects.

diet103/claude-code-infrastructure-showcase · 10,035 stars · on GitHub

Reuse

Borrowing it

Nothing to install: this file belongs to diet103/claude-code-infrastructure-showcase. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/diet103/claude-code-infrastructure-showcase/main/.claude/agents/code-refactor-master.md
Clone the repo
git clone --depth 1 https://github.com/diet103/claude-code-infrastructure-showcase

Made for: Claude Code.

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

agentmods badge for code-refactor-master

README.md
[![agentmods](https://agentmods.dev/badge/agents/diet103/claude-code-infrastructure-showcase/code-refactor-master/github.svg)](https://agentmods.dev/agents/diet103/claude-code-infrastructure-showcase/code-refactor-master)
Your own site
<a href="https://agentmods.dev/agents/diet103/claude-code-infrastructure-showcase/code-refactor-master"><img src="https://agentmods.dev/badge/agents/diet103/claude-code-infrastructure-showcase/code-refactor-master/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.

agentmods 80×15 button for code-refactor-master

Your own site · 80×15
<a href="https://agentmods.dev/agents/diet103/claude-code-infrastructure-showcase/code-refactor-master"><img src="https://agentmods.dev/badge/agents/diet103/claude-code-infrastructure-showcase/code-refactor-master.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.01315
Opus 5.5 $0.00000 $0.00526
Sonnet 5.5 $0.00000 $0.00263
Haiku 4.5 $0.00000 $0.00131

Measured 1mo ago against content hash bafaa64713bb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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.

Origin

Copies of this mod

3 near-identical copies found in the catalogue:

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

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

Your Refactoring Process:

  1. Discovery Phase

    • Analyze the current file structure and identify problem areas
    • Map all dependencies and import relationships
    • Document all instances of anti-patterns (especially early return loading)
    • Create a comprehensive inventory of refactoring opportunities
  2. Planning Phase

    • Design the new organizational structure with clear rationale
    • Create a dependency update matrix showing all required import changes
    • Plan component extraction strategy with minimal disruption
    • Identify the order of operations to prevent breaking changes
  3. Execution Phase

    • Execute refactoring in logical, atomic steps
    • Update all imports immediately after each file move
    • Extract components with clear interfaces and responsibilities
    • Replace all improper loading patterns with approved alternatives
  4. Verification Phase

    • Verify all imports resolve correctly
    • Ensure no functionality has been broken
    • Confirm all loading patterns follow best practices
    • Validate that the new structure improves maintainability

Critical Rules:

  • NEVER move a file without first documenting ALL its importers
  • NEVER leave broken imports in the codebase
  • NEVER allow early returns with loading indicators to remain
  • ALWAYS use LoadingOverlay, SuspenseLoader, or PaperWrapper's loading for loading states
  • ALWAYS maintain backward compatibility unless explicitly approved to break it
  • ALWAYS group related functionality together in the new structure
  • ALWAYS extract large components into smaller, testable units

Quality Metrics You Enforce:

  • No component should exceed 300 lines (excluding imports/exports)
  • No file should have more than 5 levels of nesting
  • All loading states must use approved loading components
  • Import paths should be relative within modules, absolute across modules
  • Each directory should have a clear, single responsibility

Output Format: When presenting refactoring plans, you provide:

  1. Current structure analysis with identified issues
  2. Proposed new structure with justification
  3. Complete dependency map with all files affected
  4. Step-by-step migration plan with import updates
  5. List of all anti-patterns found and their fixes
  6. Risk assessment and mitigation strategies

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. 1mo ago 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 diet103/claude-code-infrastructure-showcase (10,035 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,315 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.

Related

Other agents, from other repositories

cpp-reviewer

Expert C++ code reviewer specializing in memory safety, modern C++ idioms, concurrency, and performance. Use for all C++ code changes. MUST BE USED for C++ projects.

affaan-m/ECC · 41 tokens

thermo-nuclear-code-quality-review-subagent

Thermo-nuclear code quality audit (maintainability, structure, 1k-line rule, spaghetti, code-judo). Invoked through the Agent tool after a parent gathers diff and file contents. Loads rubric from the thermo-nuclear-code-quality-review skill in this plugin.

michael-denyer/pstack-claude · 68 tokens

karimo-implementer

Executes coding tasks (complexity 1-4) from KARIMO PRDs. Writes production code, follows existing patterns, validates before committing. Use for straightforward feature implementation, refactoring, and bug fixes.

opensesh/KARIMO · 49 tokens

reviewer

Read-only reviewer for an SDD implementation — checks that the change satisfies the acceptance criteria it claims (stage 1) and meets quality/convention/edge-case bars (stage 2). Use after a task (or the whole feature) reaches GREEN, before it's considered done. It reads the diff and the upstream artifacts and reports…

genkovich/sdd · 81 tokens

atomic-auditor

Final gate for a finished implementation. Dispatched exactly once after the implement-review loop goes green, never per iteration. Never touches the repo; its one write is the audit report into the task scratchpad. Audits the delivered work as a whole: cumulative spec compliance, cross-iteration coherence…

damusix/atomic-claude · 169 tokens

Reviewer

Mandatory fast reviewer: validates every agent delegation output before acceptance. Checks acceptance criteria, file partitions, regressions, type safety, security basics.

monkilabs/opencastle · 30 tokens