← ClaudeAtlas

roblox-luau-patternslisted

Writing idiomatic typed Luau for Roblox. Use when creating or refactoring any .luau module, adding type annotations, deciding between a plain table module and a metatable class, or fixing luau-lsp diagnostics. Covers --!strict and the language modes, type aliases and exported types, generics and type packs, the metatable class idiom with correct self typing, Instance typing and the nil-safety that strict mode forces, the differences between Luau and Lua 5.1 that break copied code (continue, compound assignment, string interpolation, no goto, no setfenv, bit32 instead of bitwise operators), and the performance-relevant idioms around allocation, iteration and the task library.
ibrohim1234567881717/game-dev-ai-skills · ★ 0 · AI & Automation · score 71
Install: claude install-skill ibrohim1234567881717/game-dev-ai-skills
# Roblox Luau Patterns ## Purpose Luau is not Lua 5.1 with a new name. It has a gradual type system, its own syntax additions (`continue`, `+=`, backtick string interpolation, `if-then-else` expressions), deliberate removals (`setfenv`, `getfenv`, `goto`, bitwise operators, `loadstring` off by default), and a compiler that optimises specific shapes and pessimises others. Code copied from a Lua tutorial usually runs, then fails in a way the author did not expect: `--!strict` rejects it, `getfenv` deoptimises the whole enclosing function, or a class written with `self` untyped produces no completion and no type checking at any call site. This skill is the set of idioms that make a Luau module type-check cleanly, read like the rest of the ecosystem, and stay cheap. ## When to use - Writing a new `ModuleScript`, or converting an untyped one to `--!strict`. - Deciding how to model something: plain table of functions, metatable class, closure-based object, or just data. - Fixing `luau-lsp` or Studio script-analysis diagnostics you do not understand. - Reviewing Luau for correctness or for allocation in a hot path. - Porting code written for Lua 5.1, LÖVE, or another Lua host. ## When NOT to use - Deciding *where* the module lives in the DataModel, or whether the project is Rojo or Studio-only — use `roblox-project-conventions` first. - Designing the boundary between client and server — use `roblox-client-server-architecture`. - Validating attacker-controlled input — ty