agentleFS
germanfndezgermanfndez/fiveai-skills/skills/lua-basics/SKILL.md

lua-basics

Skill19 starsChanged 2 months agoMITView on GitHub

Trigger: Lua code, Lua functions, tables, variables, conditionals, error handling, naming conventions, review Lua, optimize Lua. Write effective, performant Lua for FiveM resources.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. jangabrielsson/flua★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository12 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prefer local; declare locals as close to first use as possible.

    line 21
  2. Very specific:

    Do not use table.insert; append with t[#t + 1] = v or maintain your own size counter.

    line 22
  3. Very specific:

    Use guard clauses and early returns.

    line 25
  4. Very specific:

    Prefer positive boolean expressions.

    line 26
  5. Very specific:

    Use assert for pre-conditions instead of if not x then error() end.

    line 27
  6. Distinctive:

    Keep functions small, single-level of abstraction, and document exports.

    line 29
  7. Very specific:

    Add assert pre-conditions at function entry.

    line 46

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Lua Basics

Idiomatic, performant Lua patterns for FiveM: functions, tables, variables, conditionals and errors.

Activation Contract

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.

Hard Rules

  • Naming: ALL_CAPS constants, camelCase locals, PascalCase globals, _ for unused variables.
  • Prefer local; declare locals as close to first use as possible; group file-level globals at the top of a single client/server file.
  • Do not use table.insert; append with t[#t + 1] = v or maintain your own size counter.
  • Iterate arrays with numeric for i = 1, #t; imply array indices ({ a, b }) instead of writing them out.
  • Extract repeated table dereferences into locals; use t.key for constant keys and t[var] for dynamic keys.
  • Use guard clauses and early returns; never write if x then return true else return false end.
  • Prefer positive boolean expressions; set defaults with value = value or default.
  • Use assert for pre-conditions instead of if not x then error() end; fail loudly on unexpected state; return errors as values for expected failures.
  • Limit parameters; avoid boolean parameters in APIs (use enums); pass named local functions instead of inline ones.
  • Keep functions small, single-level of abstraction, and document exports.

Decision Gates

SituationPattern
Expected failure (not found, invalid input)return nil, err or false
Programmer error / impossible stateassert / error
Flag with more than two meaningsenum table, not boolean
Function reused more than once as argumentlocal function then pass by name
Append to arrayt[#t + 1] = v

Execution Steps

  1. Apply naming and scope rules to every identifier.
  2. Replace nested if with guard clauses.
  3. Replace table.insert and pairs on arrays with index writes and numeric loops.
  4. Add assert pre-conditions at function entry.
  5. Re-read for size: split any function mixing high- and low-level code.

Output Contract

Return Lua that follows the naming, locality, table and error-handling rules above; annotate any deliberate deviation.

References

  • rules/functions.md — size, naming, parameters, exports, guard clauses.
  • rules/tables.md — indices, dereferencing, table.insert, iteration, size.
  • rules/variables.md — naming, enums vs booleans, declaration location.
  • rules/conditionals.md — defaults, boolean expressions, readability.
  • rules/errors.md — assert, pre-conditions, errors as values, fail loudly.
  • rules/reference-links.md — official Lua and FiveM documentation.

Upstream docs: https://www.lua.org/manual/5.4/

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.