How realms are assigned
The server determines a file’s realm from its path and filename conventions.Path-based assignment
Filename prefix conventions
These prefixes are treated as informational hints. The server still respects the directory first, because many projects break the prefix convention.
Narrowing with conditionals
Inside anif SERVER then block, the server narrows the realm to Server for everything in that branch. The same applies to if CLIENT then.
What it catches
Cross-realm API misuse
The server flags when you call a serverside-only function from a clientside context:Completion filtering
When you work in a clientside file, serverside-only functions are hidden from completion. You will not seePlayer:Kick suggested in a cl_ file or anything under lua/autorun/client/.
Realm certainty
Path-based detection is considered certain. If a file lives inlua/autorun/server/, the server treats it as strictly serverside.
Filename prefixes (cl_, sv_) are informational. They guide the initial assignment but do not override a conflicting directory. This protects you from false positives when a cl_ file is included from a shared context.
A
cl_ file that is included serverside (for example, through AddCSLuaFile and include in a shared file) is not detectable from the path alone. The server will still treat it as clientside based on its location. If you intentionally share a prefixed file, add an explicit ---@realm shared annotation at the top.