|
| 1 | +<!-- markdownlint-disable MD025 --> |
| 2 | +# Tool Rules (compose-agentsmd) |
| 3 | + |
| 4 | +- **Session gate**: before responding to ANY user message, run `compose-agentsmd` from the project root. AGENTS.md contains the rules you operate under; stale rules cause rule violations. If you discover you skipped this step mid-session, stop, run it immediately, re-read the diff, and adjust your behavior before continuing. |
| 5 | +- `compose-agentsmd` intentionally regenerates `AGENTS.md`; any resulting `AGENTS.md` diff is expected and must not be treated as an unexpected external change. |
| 6 | +- If `compose-agentsmd` is not available, install it via npm: `npm install -g compose-agentsmd`. |
| 7 | +- To update shared/global rules, use `compose-agentsmd edit-rules` to locate the writable rules workspace, make changes only in that workspace, then run `compose-agentsmd apply-rules` (do not manually clone or edit the rules source repo outside this workflow). |
| 8 | +- If you find an existing clone of the rules source repo elsewhere, do not assume it is the correct rules workspace; always treat `compose-agentsmd edit-rules` output as the source of truth. |
| 9 | +- `compose-agentsmd apply-rules` pushes the rules workspace when `source` is GitHub (if the workspace is clean), then regenerates `AGENTS.md` with refreshed rules. |
| 10 | +- Do not edit `AGENTS.md` directly; update the source rules and regenerate. |
| 11 | +- `tools/tool-rules.md` is the shared rule source for all repositories that use compose-agentsmd. |
| 12 | +- Before applying any rule updates, present the planned changes first with an ANSI-colored diff-style preview, ask for explicit approval, then make the edits. |
| 13 | +- These tool rules live in tools/tool-rules.md in the compose-agentsmd repository; do not duplicate them in other rule modules. |
| 14 | + |
| 15 | +Source: github:metyatech/agent-rules@HEAD/rules/domains/unreal/unreal-engine-core-guidelines.md |
| 16 | + |
| 17 | +# Unreal Engine project rules |
| 18 | + |
| 19 | +## Baseline |
| 20 | + |
| 21 | +- Implement in C++ when possible; avoid Blueprint Event Graphs. |
| 22 | +- Use Slate for widgets. |
| 23 | +- Follow the UE coding standard and the C++ Core Guidelines: |
| 24 | + - [Epic C++ Coding Standard for Unreal Engine](https://dev.epicgames.com/documentation/en-us/unreal-engine/epic-cplusplus-coding-standard-for-unreal-engine) |
| 25 | + - [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) |
| 26 | + |
| 27 | +## Architecture and design |
| 28 | + |
| 29 | +- Apply SOLID proportionally to context; enforce strictly for public |
| 30 | + APIs/plugins. |
| 31 | +- Keep layers clean: business logic does not depend on infra; depend on |
| 32 | + abstractions. |
| 33 | +- Separate plugins/modules by feature; do not mix unrelated features. |
| 34 | +- Separate interface modules from implementation modules. |
| 35 | +- Keep tests in a separate module. |
| 36 | +- Strictly separate Runtime vs Editor; Editor dependencies only in Editor |
| 37 | + modules. |
| 38 | +- Prefer components over deep inheritance; avoid dynamic-cast heavy designs; use |
| 39 | + UInterface. |
| 40 | +- Avoid global state and service-locator patterns; inject dependencies via |
| 41 | + interfaces/factories. |
| 42 | +- Use Gameplay Tags for extensible categories; consider GAS for generic |
| 43 | + buffs/debuffs. |
| 44 | +- Use UDeveloperSettings for config; define cvars in module namespaces; avoid |
| 45 | + hardcoded values. |
| 46 | +- Save with USaveGame and versioning when needed. |
| 47 | + |
| 48 | +## C++/UE coding practices |
| 49 | + |
| 50 | +- Do not use C++ exceptions. |
| 51 | +- Prefer forward declarations and IWYU; include \*.generated.h last. |
| 52 | +- Use explicit return types; avoid template/macro overuse. |
| 53 | +- Use FName for identifiers, FText for UI, FString for transient text. |
| 54 | +- Compare floats with tolerances (e.g., KINDA_SMALL_NUMBER). |
| 55 | +- UObject references use UPROPERTY with TObjectPtr; non-UObject use |
| 56 | + TUniquePtr/TSharedPtr; non-null shared refs use TSharedRef. |
| 57 | +- Avoid raw pointers; use TWeakObjectPtr/TWeakPtr for non-owning references. |
| 58 | +- Create UObjects with NewObject/CreateDefaultSubobject, not direct |
| 59 | + constructors. |
| 60 | +- Avoid GWorld/GEngine direct access; use GetWorld/WorldContext. |
| 61 | + |
| 62 | +## Error handling and logging |
| 63 | + |
| 64 | +- Use checkf only for fatal invariants; use ensureMsgf for recoverable |
| 65 | + anomalies. |
| 66 | +- Log errors/warnings and return early; do not use LogTemp. |
| 67 | +- Define module-specific log categories; keep logging appropriate for Shipping. |
| 68 | +- Failure logs must include actionable context (e.g., url/path/status). |
| 69 | + Debug-only noise goes to `VeryVerbose`. |
| 70 | + |
| 71 | +## Networking and security |
| 72 | + |
| 73 | +- Server authoritative: validate client inputs; do not trust client state. |
| 74 | +- Use appropriate RPC reliability; implement replication correctly; optimize |
| 75 | + with FastArray/COND\_\*/dormancy. |
| 76 | +- Never ship secrets to clients; store keys in secure storage; gate dev-only |
| 77 | + features in editor/shipping guards. |
| 78 | + |
| 79 | +## Performance and async |
| 80 | + |
| 81 | +- Minimize Tick; prefer timers/delegates; avoid blocking I/O on the game thread. |
| 82 | +- Pre-allocate hot paths; profile with TRACE_CPUPROFILER. |
| 83 | +- Use AssetManager and soft references for assets; avoid hardcoded paths. |
| 84 | +- Use Enhanced Input and centralized mapping contexts. |
| 85 | +- Use UE5Coro for async; keep UObject access on the game thread and marshal |
| 86 | + results back. |
| 87 | +- Avoid synchronous subprocess execution (e.g., `FPlatformProcess::ExecProcess`) |
| 88 | + in gameplay/async paths; prefer UE-native APIs (e.g., `FHttpModule`) and keep |
| 89 | + the game thread responsive. |
| 90 | +- When dynamically creating components/layers and binding delegates, ensure |
| 91 | + teardown runs on all failure paths and on EndPlay/cancel. |
| 92 | + |
| 93 | +## Build and tests |
| 94 | + |
| 95 | +- UnrealBuildRunTestScript and UE5Coro are required when relevant; install |
| 96 | + before use. |
| 97 | +- Build with UnrealBuildRunTestScript\\Fire-Build.ps1.bat --no-pause (add |
| 98 | + configuration/platform as needed). |
| 99 | +- Add and run AutomationSpec/Functional Tests for important features. |
| 100 | +- Run tests after relevant changes; record repro steps for issues. |
| 101 | +- Use Fire-BuildAndTest.ps1.bat --no-pause -TestFilter "filter-pattern" |
| 102 | + for test runs. |
| 103 | +- Tests should avoid Engine internal/private headers/APIs; prefer public `U*` |
| 104 | + APIs. If internals are unavoidable, isolate and document why. |
0 commit comments