code-refactor-master

A code-refactoring agent that reorganizes software and improves its structure while tracking dependencies. Refactoring means changing how code is arranged without changing what it does.

In plain words
What is it for?
Use it to reorganize folders, rename or move files, split large components, extract reusable code, and update references safely.
Why use it?
It helps make messy or hard-to-maintain code easier to understand while reducing the risk of broken imports, moved files, or inconsistent 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/wislertt/bakefile/code-refactor-master
Clone the repo
git clone --depth 1 https://github.com/wislertt/bakefile

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 7285b8cd7310, 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 — 77 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 · 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 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

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. yesterday First seen · 98 lines · 0 tokens per session scan A 7285b8cd7310

Subscribe to this mod's changes

code-refactor-master is an agent published in the GitHub repository wislertt/bakefile (5 stars, last pushed 4d ago), licensed Apache-2.0. 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 77 lines, and is treated as a copy.

Related

Other agents, from other repositories

design-review

Expert design reviewer for web UI. Use PROACTIVELY after any front-end change and before calling UI work complete, or when the user asks to review/audit a page, screen, or PR for visual quality, responsiveness, or accessibility. Drives a real browser (Playwright MCP) across viewports, checks WCAG 2.1 AA, and returns…

nextlevelbuilder/ui-ux-pro-max-skill · 82 tokens

docs-reviewer

Use this agent during PR review to answer two docs questions about any PR. Coverage, on every diff - does the change alter user-facing behavior that astro-docs documents in prose, without updating those docs? Compliance, when the diff touches docs content (astro-docs/src/content/ or astro-docs/sidebar.mts) - do the…

nrwl/nx · 171 tokens

security-analyzer

Use this agent during PR review to hunt injection-class vulnerabilities in a PR's changes - command injection, zip-slip and path traversal, prototype pollution, SSRF, credential leakage, and unsafe deserialization. It reports a finding only when untrusted data actually crosses a trust boundary into a dangerous sink…

nrwl/nx · 89 tokens

alternative-approach

Use this agent during PR review to independently design alternative solutions to the problem a PR solves and contrast them with the PR's chosen approach. It reports a finding only when an alternative is materially better (root-cause vs symptom fix, reuse of an existing utility, large complexity reduction) or when the…

nrwl/nx · 96 tokens

security-reviewer

Review an Nx PR for real trust-boundary vulnerabilities. Use during review-pr.

nrwl/nx · 20 tokens

verification-reviewer

Review an Nx PR's tests, ticket grounding, source comments, and user documentation. Use during review-pr.

nrwl/nx · 26 tokens