Lua Coding Practices
Application skill for Lua style learning (from the archived awesome-guidelines style capsules). For Luau/Roblox or OpenResty-specific rules, after current project code and any project-local references, consult applicable stack capsules in skills/*-foundation.
Core Principle
Lua quality is local scope + explicit modules, return a table, require into locals, document the exported surface.
When to Use / NOT
- Lua 5.x libraries, Neovim/Redis/OpenResty scripts, embedded game logic (non-Luau).
- Setting up luacheck, LDoc, busted/luaunit in CI.
NOT when:
- Luau-typed Roblox code, use project Luau guide.
- Generated
.lua stubs, validate generators.
Workflow
- Layout, indent, spacing, blocks (
lua-style-formatting-layout.md).
- Modules, names, return M (
lua-style-naming-modules.md).
- Functions, local, guards, calls (
lua-style-functions-scope.md).
- Tables/docs, literals, LDoc (
lua-style-tables-docs.md).
- Verify, luacheck, LDoc (if applicable), tests on changed modules.
Red Flags
- Globals without explicit
_G discipline
module(..., package.seeall)
- Missing
local on bindings
- Semicolons as statement separators
local x = function() instead of local function
- Ambiguous omitted-paren string calls
- Broken
x and y or z when y may be false
- debug library in production paths
- Deprecated 5.0 APIs
- Undocumented exported functions
- dot vs
[] misuse on static keys
- No trailing comma in multiline tables
- Deep nesting without
end comments
table.insert for simple append only
Verification
luacheck . (project .luacheckrc)
- LDoc build for documented modules
- busted/luaunit test run (project harness)
- Capsule checklist on
return M module pattern
References
awesome-guidelines/references/lua-style-learning-note.md
awesome-guidelines/references/lua-style-formatting-layout.md
awesome-guidelines/references/lua-style-naming-modules.md
awesome-guidelines/references/lua-style-functions-scope.md
awesome-guidelines/references/lua-style-tables-docs.md
1---2name: lua-coding-practices3description: Use when authoring or reviewing Lua, local-first modules, 2–4 space layout, snake_case/CamelCase naming, return-M pattern, guard returns, table/LDoc idioms, and luacheck/LDoc in CI.4---56# Lua Coding Practices78Application skill for Lua style learning (from the archived `awesome-guidelines` style capsules). For Luau/Roblox or OpenResty-specific rules, after current project code and any project-local references, consult applicable stack capsules in `skills/*-foundation`.910## Core Principle1112Lua quality is **local scope + explicit modules**, return a table, require into locals, document the exported surface.1314## When to Use / NOT1516- Lua 5.x libraries, Neovim/Redis/OpenResty scripts, embedded game logic (non-Luau).17- Setting up luacheck, LDoc, busted/luaunit in CI.1819**NOT when:**2021- Luau-typed Roblox code, use project Luau guide.22- Generated `.lua` stubs, validate generators.2324## Workflow25261. **Layout**, indent, spacing, blocks (`lua-style-formatting-layout.md`).272. **Modules**, names, return M (`lua-style-naming-modules.md`).283. **Functions**, local, guards, calls (`lua-style-functions-scope.md`).294. **Tables/docs**, literals, LDoc (`lua-style-tables-docs.md`).305. **Verify**, luacheck, LDoc (if applicable), tests on changed modules.3132## Red Flags3334- Globals without explicit `_G` discipline35- `module(..., package.seeall)`36- Missing `local` on bindings37- Semicolons as statement separators38- `local x = function()` instead of `local function`39- Ambiguous omitted-paren string calls40- Broken `x and y or z` when y may be false41- debug library in production paths42- Deprecated 5.0 APIs43- Undocumented exported functions44- dot vs `[]` misuse on static keys45- No trailing comma in multiline tables46- Deep nesting without `end` comments47- `table.insert` for simple append only4849## Verification5051- `luacheck .` (project `.luacheckrc`)52- LDoc build for documented modules53- busted/luaunit test run (project harness)54- Capsule checklist on `return M` module pattern555657## References5859- `awesome-guidelines/references/lua-style-learning-note.md`60- `awesome-guidelines/references/lua-style-formatting-layout.md`61- `awesome-guidelines/references/lua-style-naming-modules.md`62- `awesome-guidelines/references/lua-style-functions-scope.md`63- `awesome-guidelines/references/lua-style-tables-docs.md`