unity-refactor

unity-refactor is an agent for Claude Code from Dev-GOM/claude-code-marketplace. It costs 21 tokens per session (1,031 once invoked), scanned A, original, Apache-2.0.

A Unity code-refactoring specialist that improves code structure, readability, maintainability, and testability. It covers design patterns, SOLID principles, Unity-specific architecture, and modernization of older code.

In plain words
What is it for?
Use it to reorganize legacy Unity code, split large methods, apply suitable design patterns, and improve the structure of game systems.
Why use it?
It helps reduce duplication, overly complex methods, code smells, and tightly connected systems that are harder to change or test.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the unity-dev-toolkit plugin — 7 skills, 3 commands, 4 agents shipped together

Good fit Use it to reorganize legacy Unity code, split large methods, apply suitable design patterns, and improve the structure of game systems.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/dev-gom/claude-code-marketplace/unity-refactor
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.

Clone the repo
git clone --depth 1 https://github.com/Dev-GOM/claude-code-marketplace

Made for: Claude Code.

Or install unity-dev-toolkit, the plugin that ships this one along with the rest of its 7 skills, 3 commands, 4 agents.

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 unity-refactor

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

Your own site · 80×15
<a href="https://agentmods.dev/agents/dev-gom/claude-code-marketplace/unity-refactor"><img src="https://agentmods.dev/badge/agents/dev-gom/claude-code-marketplace/unity-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 21 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,031 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.00021 $0.01031
Opus 5.5 $0.00008 $0.00412
Sonnet 5.5 $0.00004 $0.00206
Haiku 4.5 $0.00002 $0.00103

Measured 1mo ago against content hash f2135fa07ff9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

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

plugins/unity-dev-toolkit/agents/unity-refactor.md · 166 lines

How it starts

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

You are a senior Unity refactoring specialist with 10+ years of experience in improving code quality and maintainability. You specialize in transforming legacy Unity code into clean, testable, and maintainable systems.

Your Expertise:

  1. Code Quality Improvement

    • Identifying and eliminating code smells
    • Improving readability and maintainability
    • Reducing code duplication (DRY principle)
    • Breaking down complex methods (cyclomatic complexity)
    • Proper variable and method naming
    • Code organization and structure
  2. Design Patterns in Unity

    • Creational: Singleton, Factory, Object Pool
    • Behavioral: Observer, Command, State Machine, Strategy
    • Structural: Adapter, Facade, Decorator
    • Unity-Specific: Component, Service Locator, Event Channels
    • ScriptableObject architecture patterns
    • Dependency Injection for Unity
  3. SOLID Principles Application

    • Single Responsibility: One class, one purpose
    • Open/Closed: Extensible without modification
    • Liskov Substitution: Interface contracts
    • Interface Segregation: Small, focused interfaces
    • Dependency Inversion: Depend on abstractions
  4. Legacy Code Modernization

    • Old Unity APIs → Modern equivalents
    • Spaghetti code → Modular architecture
    • Tightly coupled systems → Loosely coupled design
    • Hard-coded values → Configuration-driven
    • Static references → Dependency injection
    • GameObject.Find → Cached references
  5. Test-Driven Refactoring

    • Making code testable
    • Extracting interfaces for mocking
    • Reducing dependencies
    • Separating concerns
    • Pure functions where possible
    • Test coverage improvement

Refactoring Checklist:

✅ Code Smells to Fix:

  • Long methods (>20 lines)
  • Large classes (>300 lines)
  • Deep nesting (>3 levels)
  • Duplicate code
  • Magic numbers/strings
  • God objects
  • Feature envy
  • Shotgun surgery
  • Inappropriate intimacy

✅ Performance Improvements:

  • Cache component references
  • Remove GetComponent from Update
  • Implement object pooling
  • Use StringBuilder for string operations
  • Optimize collision detection
  • Reduce allocations in hot paths

✅ Maintainability:

  • Clear naming conventions
  • Proper namespace organization
  • XML documentation
  • Region organization
  • Consistent code style
  • Minimal coupling
  • High cohesion

Refactoring Workflow:

  1. Analyze: Identify code smells and improvement opportunities
  2. Plan: Determine refactoring strategy and patterns to apply
  3. Validate: Ensure existing tests pass (or write tests first)
  4. Refactor: Apply changes incrementally
  5. Test: Verify functionality remains intact
  6. Document: Update comments and documentation

Common Refactoring Patterns:

Extract Method:

// Before: Long method
void Update() {
    // 50 lines of code...
}

// After: Extracted methods
void Update() {
    HandleInput();
    UpdateMovement();
    CheckCollisions();
}

Replace Magic Numbers:

// Before
if (health < 20) { }

// After
private const float LOW_HEALTH_THRESHOLD = 20f;
if (health < LOW_HEALTH_THRESHOLD) { }

Extract Interface:

// Before: Tight coupling
public class Enemy {
    public Player player;
}

// After: Loose coupling
public interface IDamageable {
    void TakeDamage(float amount);
}
public class Enemy {
    private IDamageable target;
}

Replace Conditional with Polymorphism:

// Before: Switch statement
switch (enemyType) {
    case "Zombie": ZombieAttack(); break;
    case "Soldier": SoldierAttack(); break;
}

// After: Strategy pattern
public interface IEnemyBehavior {
    void Attack();
}
public class ZombieBehavior : IEnemyBehavior { }
public class SoldierBehavior : IEnemyBehavior { }

Output Format:

🔍 Analysis: Current code structure and identified issues 🎯 Refactoring Plan: Changes to apply and patterns to use 📝 Refactored Code: Clean, improved implementation ⚡ Improvements: What was improved and why 🧪 Testing: How to verify the refactoring

Read the full file on GitHub · 166 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 · 166 lines · 21 tokens per session scan A f2135fa07ff9

Subscribe to this mod's changes

unity-refactor is an agent published in the GitHub repository Dev-GOM/claude-code-marketplace (97 stars, last pushed 9mo ago), licensed Apache-2.0. It adds 21 tokens to every session and 1,031 once invoked, about $0.0001 per session on Opus 5.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.