Logo Ue Coding Standards

Ue Coding Standards

Cộng đồng
kevinpbuckley
ue-coding-standards

Write Unreal C++ that conforms to Epic's coding standard — type prefixes (U/A/F/E/I/T/S), PascalCase naming, the bBool prefix, enum class style, Allman braces, tab indentation, const correctness, nullptr/override/final usage, TEXT() string literals, include order with generated.h last, IWYU and forward declarations, API export macros (MODULE_API), UPROPERTY/UFUNCTION specifiers with Category, TObjectPtr for UObject members, and engine types over std containers. Use when writing or reviewing any UE C++, naming types or members, structuring headers, or making code consistent with the engine and surrounding project code.

Tổng quan

Nhà phát hànhkevinpbuckley
Kho mãunreal-engine-skills
Tên kỹ năngue-coding-standards
Sao
89
Bản fork
9
Tệp đi kèm
3
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được kevinpbuckley công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Ue Coding Standards trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-coding-standards
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kevinpbuckley/unreal-engine-skills.git /tmp/unreal-engine-skills
mkdir -p .claude/skills
cp -r /tmp/unreal-engine-skills/skills/core/ue-coding-standards .claude/skills/ue-coding-standards
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Ue Coding Standards trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Ue Coding Standards ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Ue Coding Standards với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Unreal coding standards

Match Epic's C++ conventions so code reads like the engine and the rest of the project. The overriding rule: match the surrounding code first; these are the defaults when nothing else is established.

Related skills: ue-cpp-fundamentals, ue-core-types-and-containers, ue-module-and-build-system.

When to use this skill

  • Writing any new UE C++ header or source file.
  • Reviewing or cleaning up code for style consistency.
  • Choosing names for types, members, functions, or files.
  • Structuring includes and forward declarations in a header.

Type prefixes (mandatory for reflected types)

UHT enforces prefixes for reflected types; mismatches are a compile error.

PrefixTypeEngine example
UUObject subclass (non-actor)UActorComponent (Components/ActorComponent.h:160)
AAActor subclassAActor (GameFramework/Actor.h:282)
FPlain struct or non-UObject classFAttachmentTransformRules (Engine/EngineTypes.h:75)
EEnum / enum classEAttachmentRule (Engine/EngineTypes.h:62)
IAbstract interface classIInterface_AssetUserData (Interfaces/Interface_AssetUserData.h:22)
TClass templateTArray (Containers/Array.h:767)
SSlate widgetSWidget, SCompoundWidget
bBoolean variablebReplicates (GameFramework/Actor.h:593)

The word after the prefix is PascalCase. The class name without its prefix must match the filename: AMyPawn → MyPawn.h. Typedefs take the prefix appropriate to their underlying type.

Full prefix rules, interface pairing, enum value style, and template parameter conventions: references/naming-conventions.md.

Naming

  • PascalCase for every identifier — types, functions, member variables, local variables, and parameters. No m_ prefix, no camelCase, no snake_case.
  • Booleans carry the b prefix: bIsDead, bHasKey, bReplicates.
  • Functions with a bool return ask a question: IsAlive(), ShouldClearBuffer().
  • Output reference parameters carry Out: void GetItems(TArray<FItem>& OutItems).
  • Type and variable names are nouns; function names are verb phrases.
  • Be descriptive; avoid abbreviations except established ones (AI, HUD, LOD, GC).
  • Macros are UE_ALL_CAPS_WITH_UNDERSCORES.

Formatting

Allman braces — opening brace on its own line for every construct. Always brace single-statement blocks:

cpp
void AMyActor::BeginPlay()
{
    Super::BeginPlay();
    if (bIsReady)
    {
        DoThing();
    }
}
  • Tabs (4-character width) for indentation; spaces only for alignment within a line.
  • One statement per line.
  • Pointer/reference spacing: FType* Ptr; and const FType& Ref; — */& bind to the type.
  • No variable shadowing across scopes.

Switch statements must have an explicit default: branch and document intentional fall-through with // falls through.

Full formatting rules, switch style, and namespace rules: references/formatting-and-includes.md.

Language conventions

  • nullptr — never NULL or 0 for pointers.
  • override on every overriding virtual. Add final where the class or function should not be further overridden.
  • const correctness — const member functions for non-mutating methods; const& for non-trivial parameters not being copied; never const a by-value return.
  • TEXT("...") around every string literal that constructs an FString or FName.
  • enum class over plain enums; back with uint8 if exposed to Blueprints. Values are PascalCase. Use ENUM_CLASS_FLAGS(EFoo) for bitfield enums with a None = 0 sentinel.
  • Engine containers (TArray, TMap, TSet, FString, FName) over std:: equivalents in engine-facing code.
  • auto only where the type is either a lambda, a verbose iterator, or genuinely indiscernible from context. Always apply const, &, or * explicitly with auto.
  • Range-based for is preferred. For TMap, iterate as for (TPair<K,V>& Kvp : Map).
  • Move semantics — use MoveTemp(X) (UE's std::move) when transferring ownership of containers or FString into a member or return.
  • Lambdas — prefer explicit captures over [=] or [&]. Captured UObject* pointers are invisible to the GC. Use CreateWeakLambda / BindWeakLambda for deferred lambdas.
  • UObjects via pointer — pass by pointer, not reference. Null is the signal for "absent".
  • Portable integer types: int32, uint32, uint8, float, double, TCHAR; avoid bare int in serialized or replicated data.

Headers and includes

Header structure (in order)

cpp
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"          // 1. CoreMinimal (or fine-grained core headers)
#include "GameFramework/Actor.h"  // 2. Engine / module headers this type needs
#include "MyActor.generated.h"   // 3. generated.h — ALWAYS LAST

Source file structure

cpp
#include "MyActor.h"                        // matching header first
#include "Components/StaticMeshComponent.h" // then any implementation deps
  • #pragma once at the top of every header (all target compilers support it).
  • generated.h must be the last include — UHT requires it. Missing it or putting it in the middle causes broken generated code.
  • IWYU (Include What You Use) — include every header you directly depend on; do not rely on transitive includes through another header.
  • Forward declare in headers where you only need a pointer or reference. In .cpp, include the full header. This reduces compile times and dependency coupling.
cpp
// Header — forward declare only
class UStaticMeshComponent;

UCLASS()
class MYGAME_API AMyActor : public AActor
{
    GENERATED_BODY()
    UPROPERTY(VisibleAnywhere) TObjectPtr<UStaticMeshComponent> Mesh;
};

// Source — full include
#include "Components/StaticMeshComponent.h"

Engine evidence: Actor.h lines 5–32 use IWYU-style fine-grained includes ending with "Actor.generated.h" at line 32; Character.h lines 5–19 show CoreMinimal.h first and "Character.generated.h" at line 19.

Reflection style

Every reflected class or struct needs GENERATED_BODY() as its first body member. Every public class in a module needs the module *_API export macro:

cpp
UCLASS(Blueprintable, BlueprintType, config=Game)
class MYGAME_API AWeapon : public AActor
{
    GENERATED_BODY()
public:
    UFUNCTION(BlueprintCallable, Category="Weapon")
    void Fire();

    UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Stats",
              meta=(ClampMin="0"))
    float Damage = 25.f;

protected:
    UPROPERTY(VisibleAnywhere, Category="Components")
    TObjectPtr<UStaticMeshComponent> Mesh;
};

Key rules:

  • Always set a Category on any UPROPERTY/UFUNCTION the editor will show. Without it, properties land in an uncategorized root group.
  • Put meta=(...) last in the specifier list.
  • Use TObjectPtr<T> for UPROPERTY members holding UObject-derived pointers (UE5+ modern form). Raw T* still works and appears in older code.
  • The *_API macro (e.g. MYGAME_API, ENGINE_API) must appear between class and the class name for any non-inline public API. UBT expands it to __declspec(dllexport/import).

See references/reflection-and-uht.md for the full specifier reference, USTRUCT/UENUM/UFUNCTION details, and common UHT errors.

Comments and documentation

  • // for inline comments; /** ... */ JavaDoc-style comments on public API declarations — these surface as tooltips for Blueprint-exposed members and in the generated API docs.
  • Comment why, not what. Keep comments accurate and current with the code.
  • Class comments describe the problem the class solves. Multi-line method comments document purpose, parameter units/ranges, return value, and any @warning/@see/@deprecated.
cpp
/** Maximum health this actor can have. Modified by difficulty at BeginPlay. */
UPROPERTY(EditDefaultsOnly, Category="Health", meta=(ClampMin="1"))
float MaxHealth = 100.f;

Logging and errors

  • Log through a named category with UE_LOG (ue-logging-and-assertions).
  • check(Condition) for invariants — aborts in all builds if violated. Never put side effects inside a check.
  • ensure(Condition) for recoverable "shouldn't happen" — fires once in non-shipping builds, returns bool so you can handle the failure.
  • Remove debug prints before submitting.

Gotchas

  • Wrong or missing type prefix — UHT build error; check U/A/F/E/I/T/S.
  • generated.h not last — UHT mis-generates or fails outright.
  • Missing GENERATED_BODY() — compile errors from undefined generated symbols.
  • Missing Category on editor-exposed properties — unorganized Details panel.
  • m_ prefix or snake_case — not Unreal style; use PascalCase.
  • Missing b on booleans — style violation; also breaks naming-based tooling.
  • std:: containers in engine-facing code — use TArray/TMap/FString instead.
  • Omitting override — silent non-override when a virtual signature drifts.
  • Bare NULL/0 for pointers — use nullptr.
  • No TEXT() around string literals — produces an undesirable narrow-to-wide conversion.
  • auto overuse — hide types from readers; use only for lambdas, verbose iterators, or template-context expressions where the type is genuinely unwriteable.
  • [=]/[&] lambda captures — UObject pointers captured by [=] are invisible to the GC; deferred [&] lambdas dangle. Use explicit captures and weak wrappers.

References and source material

Engine source (UE 5.8, under Engine/Source/):

  • Runtime/Engine/Classes/GameFramework/Actor.h:281–282, 288, 306, 593, 891, 1019, 1024
  • Runtime/Engine/Classes/GameFramework/Character.h:3, 5, 19, 337–338
  • Runtime/Engine/Classes/Components/ActorComponent.h:3, 23, 27–38, 159–162, 177, 340
  • Runtime/Engine/Classes/Engine/EngineTypes.h:62, 75
  • Runtime/Engine/Classes/Interfaces/Interface_AssetUserData.h:3, 16–22
  • Runtime/CoreUObject/Public/UObject/Object.h:97–100, 106, 129
  • Runtime/Core/Public/Containers/Array.h:767
  • Runtime/Core/Public/Windows/WindowsPlatform.h:209–210
  • Runtime/Core/Public/HAL/Platform.h:1063–1065

Official docs (UE 5.8):

Deep-dive references in this skill:

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Ue Coding Standards làm được gì?

Write Unreal C++ that conforms to Epic's coding standard — type prefixes (U/A/F/E/I/T/S), PascalCase naming, the bBool prefix, enum class style, Allman braces, tab indentation, const correctness, nullptr/override/final usage, TEXT() string literals, include order with generated.h last, IWYU and forward declarations, API export macros (MODULE_API), UPROPERTY/UFUNCTION specifiers with Category, TObjectPtr for UObject members, and engine types over std containers. Use when writing or reviewing any UE C++, naming types or members, structuring headers, or making code consistent with the engine a...

Vì sao nên dùng Ue Coding Standards trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Ue Coding Standards là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Ue Coding Standards trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-coding-standards. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Ue Coding Standards?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Ue Coding Standards với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Ue Coding Standards với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Ue Coding Standards có miễn phí không?

Kỹ năng này được kevinpbuckley phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇