Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Unreal Cpp Reflection?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tipoli5890-unreal-cpp-reflection)
---
name: unreal-cpp-reflection
description: >-
Unreal C++ reflection: UCLASS, UPROPERTY, UFUNCTION, USTRUCT, UENUM, GENERATED_BODY, specifiers,
TObjectPtr, garbage collection; a header lint.
---
# unreal-cpp-reflection — the macros, the specifiers, and what the collector can see
Reflected C++ is ordinary C++ plus macros that the header tool reads. The build tool runs the header
tool first and the compiler after it, so a macro mistake stops the build before any compiler line.
Most dangling objects come from an object pointer that reflection never saw.
## Load what the situation needs
| The situation | Read |
|---|---|
| Writing a `UCLASS`, `USTRUCT` or `UENUM` header | *A reflected header, line by line* below; `templates/ParcelRecord.h`, `templates/ParcelKind.h` |
| Which specifier, on which macro, spelt how; metadata keys | `reference/specifiers.md` |
| An object freed while in use, a dangling pointer, an object that never goes away | `reference/garbage-collection.md` |
| `NewObject`, `CreateDefaultSubobject`, constructors, the class default object, `TSubclassOf` | `reference/object-creation.md` |
| Checking headers before a build (or in CI) | *Lint before you build*; `scripts/reflection_lint.py` |
| A build error naming a `.generated.h`, `GENERATED_BODY` or a specifier | *Classic failures* below; `unreal-compile-loop` → `reference/reading-errors.md` |
| Which members a Blueprint sees, native and implementable events | `unreal-blueprint-boundary` |
| `Replicated`, `ReplicatedUsing`, RPC specifiers, `GetLifetimeReplicatedProps` | `unreal-replication` |
| The module API macro's module, Build.cs dependencies, link errors | `unreal-modules-build` |
| An API name not in these files | `unreal-project` → `reference/api-lookup.md` |
## A reflected header, line by line
```cpp
#pragma once
#include "CoreTypes.h"
#include "UObject/NameTypes.h" // what the members use, at the API page's include path
#include "ParcelKind.h"
#include "ParcelRecord.generated.h" // always the last include, named after this file
USTRUCT(BlueprintType)
struct COURIERRUN_API FParcelRecord // the module API macro, then the prefixed name
{
GENERATED_BODY() // first line of every UCLASS and USTRUCT body
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Parcel")
FName ParcelId;
UPROPERTY(EditAnywhere, Category = "Parcel")
EParcelKind Kind = EParcelKind::Standard;
};
```
1. `#pragma once`, then include what you use: `CoreTypes.h` first, the base class's header at the
path its API page gives (`GameFramework/Actor.h` for `AActor`), then each type the members use.
Never a monolithic header (`Engine.h`, `UnrealEd.h`). The `.cpp` includes its own header first.
2. `<File>.generated.h` is the last `#include`, spelt after the header's own file name. The header
tool writes it only for a header that declares a reflected type.
3. The macro sits directly above the type: `UCLASS(...)`, `USTRUCT(...)`, or `UENUM()` above
`enum class EName : uint8`.
4. `<MODULE>_API` (here `COURIERRUN_API` for module `CourierRun`) exports the type to other
modules. Leave it off and another module's use of it fails to link. `MinimalAPI` exports the
type information only.
5. `GENERATED_BODY()` opens the body. Every object pointer member carries `UPROPERTY()`, and members
use `TObjectPtr<T>` rather than a raw `T*`.
6. Functions a Blueprint or the network calls carry `UFUNCTION(...)`. Their specifiers are in
`reference/specifiers.md`.
## Names and prefixes
| Prefix | For | Example |
|---|---|---|
| `U` | classes derived from `UObject` (not actors) | `UParcelData`, `UParcelComponent` |
| `A` | classes derived from `AActor` | `ACourierCharacter`, `ASentry` |
| `F` | structs and other classes | `FParcelRecord`, `FRouteMath` |
| `E` | enums | `EParcelKind` |
| `I` | interfaces | `IAbilitySystemInterface` |
| `T` | templates | `TObjectPtr`, `TArray` |
| `S` | Slate widgets | `SWidget` |
| `b` | bool members | `bCarrying` |
A `UCLASS` takes the prefix of its base: an `A` class derives from an actor, a `U` class from any
other object. The header tool requires these prefixes in most cases; the lint fails a mismatch first.
## Lint before you build
```bash
python3 scripts/reflection_lint.py Source/CourierRun # every .h and .cpp below it
python3 scripts/reflection_lint.py Source Plugins --strict # CI: a WARN fails too
python3 scripts/reflection_lint.py --selftest
```
FAIL rules: the `.generated.h` include (missing, misnamed, not last, or with no reflected type);
`GENERATED_BODY()` missing; a prefix that does not match the base; an object pointer member
without `UPROPERTY`; `TStrongObjectPtr` as a `UPROPERTY`; a replicated property with no
`GetLifetimeReplicatedProps` in the header or its `.cpp`; `new` on an object type. WARN rules: a raw
`T*` `UPROPERTY` member; a `Public/` type without its module API macro; a specifier or metadata key
outside the lists it carries (it may still be valid: look it up); an exposed member without a
`Category`; `GENERATED_BODY()` not first in a struct; a bool without `b`; `CreateDefaultSubobject`
outside the constructor; a `.cpp` whose first include is not its own header. The lint reads text: it
does not expand macros or `#if` blocks. Exit 0 clean, 2 a FAIL, 3 nothing read, 1 usage.
## The pointer rules in one table
| Member | Collector sees it | Use when |
|---|---|---|
| `UPROPERTY()` `TObjectPtr<T>` | yes, keeps it alive | the member owns or needs the target |
| `TWeakObjectPtr<T>` | weakly, goes null | it watches what another object owns |
| `UPROPERTY()` `TSoftObjectPtr<T>` | as a path | it names an asset that is loaded later |
| `TStrongObjectPtr<T>` | yes | the owner is plain C++, never a `UPROPERTY` |
| raw `T*` member, no `UPROPERTY` | **no**: dangles, never nulled | never |
The rest, with structs, containers and destroyed actors: `reference/garbage-collection.md`.
## Classic failures
| What you see | Cause | Fix |
|---|---|---|
| The build stops before any compiler output, on a header line with a reflection macro | a header-tool error: it runs first, so nothing compiled | fix that header first; `reflection_lint.py` on it |
| The compiler cannot open `ParcelRecord.generated.h` | the header declares no reflected type, the include does not match the file name, or the header-tool step failed earlier | match the name; fix the first error in the log |
| Errors point at the `GENERATED_BODY()` line or into generated code | `GENERATED_BODY()` missing, or `.generated.h` not the last include | the lint's `generated-body` and `generated-include` rules |
| An unknown-specifier error from the header tool | a misspelt specifier, or one placed on the wrong macro | `reference/specifiers.md` |
| A clamp, condition or display name is silently ignored | a misspelt `meta` key: metadata is free text | compare with `reference/specifiers.md` §3, §4 |
| An unresolved external for a class of another module | no `<MODULE>_API` on it, or the module missing from Build.cs | `unreal-modules-build` → `reference/link-errors.md` |
| An unresolved `<Name>_Implementation` | a `BlueprintNativeEvent`, `Server` or `Client` function with no body | define `<Name>_Implementation` in the `.cpp` |
| A crash or garbage a while after start, in code that worked | an object pointer member without `UPROPERTY`, read after collection | `reference/garbage-collection.md` §5 |
| A struct shows no Break pins in Blueprint | no member is `BlueprintReadOnly` or `BlueprintReadWrite` | expose one; `BlueprintType` on the struct |
## Related skills
- `unreal-blueprint-boundary` → `reference/exposed-surface.md`: the Blueprint-facing subset of these
specifiers, and what belongs in C++.
- `unreal-modules-build` → `reference/build-cs.md`: the module that the API macro and each include
belong to.
- `unreal-compile-loop` → `reference/live-coding.md`: which header changes need a closed-editor rebuild.
- `unreal-replication` → `reference/properties.md`: replicated properties registered one by one.
- `unreal-gameplay-framework` → `reference/actor-lifecycle.md`: where constructors end and `BeginPlay` starts.