source-command-refactor-cpp

Migrates Unreal Engine C++ variables, functions, and delegates between classes while preserving lifecycle bindings.

Updated May 28, 2023
One-click install
npx skills add https://github.com/steveulrich/ProjectB --skill source-command-refactor-cpp-steveulrich
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: source-command-refactor-cpp
Source: https://github.com/steveulrich/ProjectB/tree/main/.agents/skills/source-command-refactor-cpp
Command: npx skills add https://github.com/steveulrich/ProjectB --skill source-command-refactor-cpp-steveulrich

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Moving C++ logic between Unreal Engine classes often leaves orphaned delegate bindings, broken includes, and stale lifecycle references that cause compile errors or runtime bugs. This Skill enforces a methodical four-step protocol so responsibility moves stay complete and consistent. ## Core Features & Use Cases - Logic Isolation: Identifies all variables, functions, delegate macros, and includes tied to the feature being moved before touching any code. - Destination-First Migration: Copies UPROPERTYs, DECLARE_DYNAMIC delegate declarations, and function implementations into the destination class before purging the origin. - Lifecycle Cleanup & Validation: Scans BeginPlay, EndPlay, PostInitializeComponents, and Tick for leftover AddDynamic/RemoveDynamic bindings, then verifies the diff and runs the project compile gate. - Use Case: When moving a UI widget feature from an Actor class to a dedicated component, use this Skill to relocate the properties and handlers, strip the old delegate bindings, and confirm the project still compiles. ## Quick Start Refactor the health regeneration logic from my Character class into a new HealthComponent using the refactor_cpp command.

Frequently Asked Questions about source-command-refactor-cpp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I move C++ functions between Unreal Engine classes?▼

Move C++ functions by first adding includes and implementations to the destination class, then deleting them from the origin. Finally, check the origin's BeginPlay, EndPlay, and Tick for leftover references and run a full project compile to validate.

How to refactor Unreal C++ delegates without breaking bindings?▼

Refactor delegates by copying the DECLARE_DYNAMIC_MULTICAST_DELEGATE macros to the destination header before removing them from the origin. Then search the origin's lifecycle functions for AddDynamic and RemoveDynamic calls tied to the moved delegates and delete them together.

Why does my Unreal project fail to compile after moving code?▼

Compile failures after a move usually come from missing includes in the destination files or unused includes and orphaned references left in the origin. Review the actual diff, remove stale includes, and verify no lifecycle hook still references the moved variables.

Does this refactoring approach work with Blueprint-bound properties?▼

Yes, the protocol accounts for UPROPERTYs and dynamic delegates commonly bound in Blueprints. After the move, run affected Blueprint and runtime checks and restart the editor when needed to load changed binaries or reflected definitions.

When should I not use a manual C++ refactoring protocol?▼

Avoid it for trivial single-line moves with no delegate or lifecycle involvement, where a simple edit suffices. The structured protocol is designed for multi-file responsibility moves where orphaned bindings and missing includes are real risks.