/unreal-skills:refactorfrom Unreal Harness Skills
Runs a disciplined, document-driven refactoring loop for game or Bun/TS code — DRY extraction, widget consolidation, service de-duplication, or asset restructuring. Behavior-preserving only, no feature additions.
Ships in Unreal Harness Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A repeatable, net-zero-behavior improvement loop. You find one clean unit of duplication or misplacement, prove it is real, extract it to the nearest sensible home, migrate every call site, verify nothing changed, and record it — then repeat until no eligible candidate remains. The discipline is the point: the default is to leave code alone, and the loop exists to make the rare, unambiguous win safe and reviewable, not to manufacture churn.
Genericized from a production UE reference project's refactor loops (refactor_general / refactor_typescript / refactor-ui / refactor-structure). It hardcodes none of that project's paths or classes — it derives roots from the project you point it at.
Refactoring is per-target. Pick the target from the request:
projects/<Name>/ — its Source/ (C++) and Content/ (assets).src/server/, tools/, scripts/, or a game's service/ / web/.The worklist document lives next to what it tracks, under that target's docs/loops/:
<target>/docs/loops/refactor-<mode>.md (e.g. projects/hoverball/docs/loops/refactor-functional.md, src/server/docs/loops/refactor-ts.md). Create it on first use from the template below. It is the loop's memory — read it first every run; never start a pass without it.
Invoke /refactor <mode> (default functional). Each mode shares the same loop engine and the same purity law (below); they differ only in what counts as a candidate and how you verify.
| Mode | Target | Hunts for |
|---|---|---|
functional (default) | C++ game source | Pure logic (math/physics/queries/predicates) embedded in a class that should not own it; re-implemented DRY violations → free functions in a local namespace |
ts | Bun/TS (server, service, web, tools) | Logic duplicated across services, cross-service coupling, type drift, route/handler shape, logger normalization, test placement |
ui | UMG/Slate widgets | Identical widget-construction sequences (backgrounds, dividers, buttons, rows, modals) → a shared component |
structure | Content/ + project layout | Feature-first violations: vendor-path references, type-first organization, gibberish names, files in the wrong folder, 600-LOC files |
These are the non-negotiables. If a candidate violates any of them, it is not a candidate.
ts: same HTTP status, JSON shape, DB writes, event emissions, and log field names — a change a curl probe or a log consumer can see is a feature, not a refactor. If a refactor reveals a behavior worth improving, that is a separate change — never bundle it.// Intentionally … — see X so the next pass does not re-investigate. If you cannot tell whether a difference is intentional, investigate the history or ask — never silently force it into the shared pattern.The doc is the loop. It has exactly three living sections (plus an optional plan/cursor for systematic sweeps):
# Refactor loop — <mode> · <target>
Scratch-pad + ledger for the <mode> refactor loop. ONE logically distinct refactor per iteration,
net-zero behavior change. Design intent lives in CLAUDE.md / docs/architecture — this file is the worklist.
Read THE LAW in the /refactor skill before each pass.
## TODO
Candidates found but not yet enacted, and "observations for the architect" (a behavior question or
latent bug you noticed but must NOT fix here — flag it, do not touch it). One bullet each.
## DONE
Completed refactors, newest first. Each entry: what was duplicated, what was extracted, where it
lives now, the call sites migrated, the intentional divergences left at sites, ~LOC removed, and the
verification (build/test result). This is the audit trail — be specific enough that it is reviewable
without re-reading the diff.
## DEFERRED
Investigated and REJECTED, with the one-line reason (so future passes don't re-litigate the same
decision). "REJECTED — <pattern>: <why it's the readable form / why the abstraction is worse>."
For a large codebase, prepend a PLAN: an ordered list of domain clusters (highest-duplication-risk first) and a cursor noting which pass you are on, so the sweep is systematic and resumable across runs.
Run this once per invocation. It maps to Scan → Investigate → Decide → Execute → Verify → Record.
<target>/docs/loops/refactor-<mode>.md (create from template if absent). Pick up the cursor / ## TODO. Re-read THE LAW.## TODO.## DEFERRED line and report that no actionable candidate was found. Do not loop into weaker work.functional/ui): it must compile. Prefer Live Coding (editor_live_coding_compile, or scripts/build-editor.ps1 for reflection changes) — and respect the harness build-coordination + multi-agent rules in the root CLAUDE.md (don't stop a shared editor or take the build lock without permission; pre-existing errors in files you didn't touch are HANDS-OFF). No business logic added or removed.ts: bun test green (failures must be unrelated + pre-existing), bun run typecheck, the server boots, and a representative route returns byte-identical wire format. If the area has no test, write the test first, confirm it passes against current behavior, then refactor.structure: references still resolve (run asset_fixup_redirectors after a move/rename); the editor still loads the asset; no dangling vendor paths.## DONE with the rationale + verification. Tick the cursor. If the refactor created/renamed/moved/deleted a file, sync the docs: invoke /docs (or update the project's TAXONOMY.md/architecture doc) so the index never drifts.Completion is a real, reportable state. "I found nothing worth doing" is success, not failure.
The LAW is shared; these are the per-mode act/pass tests. Read the matching reference-project source loop for worked examples if you want depth — but the criteria below are the contract.
functional — DRY/functional C++ extractionHunt: pure logic a class shouldn't own (a bow computing projectile intermediates; an ellipse area inside grenade code; a repeated game-state query; copy-pasted collision/equip logic; a chain re-implemented across siblings).
F…Result) for multi-value returns; TOptional<T> over bool out-params.TActorIterator, FSlateBrush setup) · extraction needs a new abstraction. Put a new <Domain>Math/<Domain>Rules header in the same folder only when no existing namespace fits.ts — Bun/TypeScript service de-duplicationHunt (in priority order): logic duplicated across services → a lib/ free function only if cross-service, else stays in the service; cross-service coupling (services/X importing services/Y — the biggest structural regression; fix via lib//types/ or the event bus); type drift between routes.ts and service.ts/types.ts; inline route handlers doing real work; console.*/JSON.stringify logs that should be structured logger fields (never rename fields); *.test.ts living under services/ (move to tests/ mirroring the path); 600-LOC files (Module_Concern.ts, re-export unchanged); inline DDL that belongs in schema.ts.
as any/@ts-ignore when you can prove the invariant; else leave it with a one-line comment.ui — UMG/Slate widget consolidationHunt: identical widget-tree construction (backgrounds, dividers, buttons, tab bars, rows, modals) built the same across files.
DrawAs vs TintColor).structure — feature-first project/asset layoutHunt: assets referenced from a vendor path instead of a project copy; type-first organization instead of feature-first; vendor-gibberish names instead of descriptive PascalCase with standard prefixes (SM_/SK_/M_/T_/…); a file in the wrong folder; a 600-LOC source file to split (ClassName_Concern.cpp, header unchanged, UBT auto-discovers).
<Project>/{Feature}/{Type}/ with a clean name, repoint references, asset_fixup_redirectors.## TODO as an "observation for the architect" — flagged, not fixed./architect. It does not invent new layers; it consolidates within the existing one (granular typed primitives stay primitive; composites stay in the server layer — see docs/ARCHITECTURE.md)./docs owns the taxonomy.CLAUDE.md — shared editors and the build lock are not yours to seize.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub oliver-io/unreal-harness --plugin unreal-skills22 skills in this plugin
/architectWrite or update an architecture document for an Unreal Engine system — a conceptual spec a senior engineer can build from. Use when someone wants to "document this system", "write an architecture doc", "spec a feature before building it", "describe how X works for the team", or "update the docs to match the code". Plan-only and code-free: it researches the live editor, Blueprints, and source, then writes a Design-level document about intent, boundaries, contracts, and invariants — no implementation, no builds, no editor mutation. Works in any UE project, not one studio's house style./automated-testerSet up an automated, agent-observed end-to-end test (or a guarded dev loop) for an Unreal feature in this harness. Use when someone wants to "add a test", "test this feature end-to-end", "verify X works in PIE", "build a verification harness", "guard this feature with a test", or "make a guardrail loop for an agent building X". Opinionated: the engine constructs the scenario via typed C++ primitives, the agent observes the behaviour it controls through a DIFFERENT read primitive, no mocks, headless-first. Encodes docs/TESTING.md./bootstrapCreate a new Unreal Engine project under projects/ wired to this repo's UnrealMCP plugin and pre-configured with the recommended engine built-in plugins (Niagara, Water, GeometryScripting, GAS, StateTree, animation, runtime mesh, etc.), and give the project its own agent-facing CLAUDE.md. Use when someone wants to "bootstrap a project", "make a new UE project", "scaffold a test/sandbox project", get a fresh project to drive with the MCP, or "write a CLAUDE.md for this game". Produces a minimal C++ host project that loads the plugin from this repo (no copy) and builds against the engine at UNREAL_ENGINE_ROOT. Asks the intended architecture (C++-first vs Blueprint-first, single- vs multiplayer) and writes a project CLAUDE.md tuned to the answers; can also adopt an existing project by exploring it and writing a CLAUDE.md that describes it.