if SERVER / if CLIENT blocks. Calling an API that does not exist in that realm is reported where you write it.
How realms are assigned
Path first, filename prefix as a hint.Path-based assignment
Filename prefix conventions
The prefix is informational — the directory decides, because plenty of projects break the convention.
Narrowing with conditionals
Insideif SERVER then, everything on that branch is treated as serverside. if CLIENT then does the same for the client.
What it catches
Cross-realm API misuse
A serverside-only function called from a clientside file is reported where the call is written:Completion filtering
Serverside-only functions are hidden from completion in a clientside file, and the reverse.Player:Kick will not turn up in a cl_ file or under lua/autorun/client/.
Realm certainty
A directory realm is certain —lua/autorun/server/ is serverside, and no filename prefix changes that.
A filename prefix (cl_, sv_) is informational. It sets the initial guess but never overrides a conflicting directory, which is what stops false positives when a cl_ file is included from a shared context.
A
cl_ file included serverside from a shared file looks clientside by its path, and there is no way to tell otherwise. If you share a prefixed file on purpose, put ---@realm shared at the top of it.