OverviewHistoryStatsSecurity
npx skills add ...
Documentation
SKILL.md
npx skills add germanfndez/fiveai-skills --skill lua-basics
Trigger: Lua code, Lua functions, tables, variables, conditionals, error handling, naming conventions, review Lua, optimize Lua. Write effective, performant Lua for FiveM resources.
npx skills add germanfndez/fiveai-skills --skill lua-basics
Idiomatic, performant Lua patterns for FiveM: functions, tables, variables, conditionals and errors.
Load this skill when writing or reviewing any Lua in a FiveM resource, or when the user asks about Lua naming, structure, performance, tables or error handling.
ALL_CAPS constants, camelCase locals, PascalCase globals, _ for unused variables.local; declare locals as close to first use as possible; group file-level globals at the top of a single client/server file.table.insert; append with t[#t + 1] = v or maintain your own size counter.for i = 1, #t; imply array indices ({ a, b }) instead of writing them out.t.key for constant keys and t[var] for dynamic keys.if x then return true else return false end.value = value or default.assert for pre-conditions instead of if not x then error() end; fail loudly on unexpected state; return errors as values for expected failures.| Situation | Pattern |
|---|---|
| Expected failure (not found, invalid input) | return nil, err or false |
| Programmer error / impossible state | assert / error |
| Flag with more than two meanings | enum table, not boolean |
| Function reused more than once as argument | local function then pass by name |
| Append to array | t[#t + 1] = v |
if with guard clauses.table.insert and pairs on arrays with index writes and numeric loops.assert pre-conditions at function entry.Return Lua that follows the naming, locality, table and error-handling rules above; annotate any deliberate deviation.
Upstream docs: https://www.lua.org/manual/5.4/