Logo van Luau Expert

Luau Expert

Community
afrxo
luau-expert

Modern, strictly-typed Luau. Use whenever writing, reviewing, or fixing Luau code (ModuleScripts, ServerScripts, LocalScripts) — language layer only, not Roblox APIs. Covers strict mode, type system, idioms, asserts, modules, and anti-patterns.

Overzicht

Uitgeverafrxo
Repositoryroblox-agent-skills
Skillnaamluau-expert
Sterren
21
Forks
4
Meegeleverde bestanden
9
LicentieMIT
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 9

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door afrxo op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Luau Expert in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/afrxo/roblox-agent-skills/tree/main/skills/luau-expert
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/afrxo/roblox-agent-skills.git /tmp/roblox-agent-skills
mkdir -p .claude/skills
cp -r /tmp/roblox-agent-skills/skills/luau-expert .claude/skills/luau-expert
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Luau Expert in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Luau Expert automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Luau Expert niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

Luau Language

Write modern, strictly-typed Luau. Source: luau.org.

For deep dives see:

Further reading: references/type-functions-api.md (analysis-time types library), references/type-patterns.md (branded/recursive types, overloads, read-only tables).


Integration Policy

This skill describes preferred patterns; it does not authorize rewriting existing code. Apply rules to new code and code the user explicitly asks to refactor. Match the codebase's existing style (casing, indentation, quote style, module shape) before applying skill defaults. Don't weaken stricter files; don't introduce tooling the project doesn't already use; surface conflicts once and default to the existing pattern.

Full rules: ../../shared/integration-policy.md.


Principles

  • Strictly typed. New files use --!strict. Migrate legacy code; never weaken a file that was strict.
  • Bugs caught at analysis time beat runtime asserts. A typed parameter is worth more than assert(typeof(x) == "number").
  • Simple over clever. Small functions, obvious intent.
  • Prefer immutability. Mutating shared state under yields breaks everything; with React-style libraries it's non-negotiable.
  • Type public APIs fully; skip trivial locals. Annotate anything other modules can call. Don't annotate local n = item.attack(p) — inference handles it.

Mode Header

luau
--!strict      -- default for new files; flags anything that *might* fail at runtime
--!nonstrict   -- legacy migration; infers any when type unknown
--!nocheck     -- generated/third-party only

Project-wide: .luaurc with { "languageMode": "strict" }.


Modern Syntax

luau
-- String interpolation (not string.format / not concat)
print(`Player {name} scored {score} points`)

-- if-then-else expression (not `a and b or c`)
local label = if score >= 100 then "Winner" else "Try again"

-- Generalized iteration (not pairs/ipairs)
for k, v in t do ... end

-- Compound assignments
count += 1
path ..= "/suffix"

-- Continue
for _, item in items do
    if not item.active then continue end
    process(item)
end

-- Floor division
local q = 7 // 2

-- Const bindings (binding immutable; value still mutable)
const MAX_PLAYERS = 16

-- Number separators
local big = 1_000_000

-- Function attributes
@native
local function hotPath(x: number): number
    return x * x + x
end

ipairs only when you specifically need stop-at-first-nil semantics on a sparse array.


Idioms

Early Return / Continue

Guard clauses over pyramids — when the function logically can't keep going, return early.

luau
local function dealDamage(humanoid: Humanoid, damage: number)
    if damage <= 0 then return end
    humanoid.Health -= damage
end

Explicit nil Checks

Most "truthy" checks really mean "not nil". Write what you mean:

luau
if x.Parent ~= nil then ...   -- ✅
if x.Parent then ...          -- ❌ ambiguous

Two exceptions where truthy is fine: if-expressions (if x then a else b reads better than the inverted form) and or defaults.

or for Defaults; Never x and y or z

luau
soundClone.Volume = volume or 0.5

-- Never simulate ternary with and/or — silently wrong when middle value is falsy
local goldAmount = if gamemode == "arena" then nil else 100   -- ✅
-- local goldAmount = gamemode == "arena" and nil or 100      -- ❌ returns 100 even on arena

Don't Hide Builtins

luau
local insert = table.insert    -- ❌
table.insert(items, sword)     -- ✅

No Call-Sugar

luau
call("string")    -- ✅
call({ ... })     -- ✅
call "string"     -- ❌
call { ... }      -- ❌ (StyLua reformats)

Async Suffix on Yielding Functions

luau
local function fetchPlayerDataAsync(userId: number): PlayerData
    -- yields here
end

React (and similar render libraries) does not expect yields — a re-render that hits a yielding call silently corrupts component state. Naming yielding functions makes it visible at the call site.

pcall Method-Shorthand

luau
pcall(part.Destroy, part)                       -- ❌ reads as nonsense
pcall(function() part:Destroy() end)            -- ✅
pcall(saveMoney, player, 100)                   -- ✅ function-shorthand reads naturally

Requires

  • No dynamic requires. require(Modules.X) keeps types; require(child) in a loop erases them.
  • One alphabetical block. No sectioning by package vs local. Use Luau LSP auto-require + StyLua sort_requires (covered in roblox-tooling).

Type System (essentials)

luau
-- Optional
type Maybe<T> = T?              -- T | nil

-- Tagged union (preferred for results)
type Result<T> = { ok: true, value: T } | { ok: false, err: string }

-- Indexed maps where misses are expected
local playerPoints: { [Player]: number? } = {}    -- ✅ checker forces nil-handling
-- { [Player]: number }                            -- ❌ hides bugs on missing keys

-- Optional argument typing — ? at outer position
local function f(default: (boolean | () -> boolean)?) end    -- ✅
-- local function f(default: boolean? | () -> boolean) end   -- ❌

unknown for untrusted input; narrow before use. any for nothing — always reach for unknown first.

Full tour in references/type-system.md.

nil ≠ Nothing

luau
local function returnsNothing() end          -- zero values
local function returnsNil() return nil end   -- one value: nil

print(returnsNothing())   -- (blank)
print(returnsNil())       -- nil

Keep return shape consistent across branches. If a function returns T?, the no-value branch must return nil, not bare return.

String Enums + exhaustiveMatch

The only enum form to use:

luau
type Color = "red" | "green" | "blue"

local function exhaustiveMatch(value: never): never
    error(`Unknown value in exhaustive match: {value}`)
end

local function setColor(color: Color)
    if color == "red" then ...
    elseif color == "green" then ...
    elseif color == "blue" then ...
    else exhaustiveMatch(color)   -- type error if a branch is missed
    end
end

No makeEnum({...}) libraries, no Color = { red = "red" :: Color } wrappers. They give nothing string unions don't.

See examples/exhaustive-match.luau.


Asserts

  • Always pass an error message. Bare assert(cond) produces useless assertion failed!.
  • Constant messages only. assert evaluates its message every call. For formatting use if not cond then error(\...`) end`.
  • Don't assert(typeof(x) == ...) to patch types. If your code is strictly typed, that line never trips except via untyped callers — fix the upstream type instead.
  • At trust boundaries (RemoteEvents, JSON, plugin input) type the input as unknown and narrow:
luau
HurtMe.OnServerEvent:Connect(function(player, damage: unknown)
    if typeof(damage) ~= "number" or damage < 0 then return end
    -- damage: number from here
    dealDamage(player, damage)
end)

Typing the parameter as number makes the runtime check look statically valid even when an exploiter sends a string. unknown forces the check.

See examples/remote-validation.luau.


Modules

luau
--!strict
local OtherModule = require("./OtherModule")

export type Config = { timeout: number, retries: number }

const DEFAULT_CONFIG: Config = { timeout = 30, retries = 3 }

local MyModule = {}

function MyModule.connect(cfg: Config?): ()
    local c = cfg or DEFAULT_CONFIG
    -- ...
end

return table.freeze(MyModule)
  • Always assign and return a named local. No return function() ... end — breaks Ctrl-Shift-F across web/rg.
  • One file per utility. No TableUtil mega-modules; flatten.luau, reverse.luau separately. Luau LSP auto-requires bare names. Project-structure rationale lives in roblox-systems.
  • table.freeze the returned module table to catch accidental mutations.
  • Cyclic deps: cast the imported module to any to break the cycle — and document why.

Shallow Copy, Not Deep

For immutable updates, clone only the path you're touching:

luau
items = table.clone(items)
items[1] = table.clone(items[1])
items[1].durability -= 10

Deep copy is always wasted work under immutability — unrelated subtrees keep their identity, which is exactly what == checks across renders want.

See examples/module-pattern.luau.


OOP — Default to Free Functions

Plain data + free functions over classes. Metatables fight the type checker, hurt grep, and surprise readers.

luau
type Slide = { length: number }
type Video = { slides: { Slide } }

-- videoLength.luau
local function videoLength(video: Video): number
    local total = 0
    for _, slide in video.slides do
        total += slide.length
    end
    return total
end

return videoLength

Aside from __index and __tostring (and __mode for the rare weak table), avoid every metamethod. No __call, no __add, no operator overloads — they don't autocomplete and they fight inference.

When a class is genuinely warranted, see references/typed-class-recipe.md.


Verification Rules

  • Don't assume Lua APIs exist in Luau. Several were removed or relocated:
    • setfenv / getfenv — removed.
    • unpack (global) — moved to table.unpack.
    • loadstring — removed; use loadstring-equivalent only via loadstring if explicitly enabled, otherwise unavailable.
    • bit32 — present, but consider native bitwise operators where possible.
    • goto / labels — not in Luau.
  • Don't invent syntax. If you're unsure whether a feature (e.g. const, @native, type functions, default generics) exists or is stable, check luau.org before using it. State the uncertainty in your reply rather than guessing.
  • Stable concepts beat brittle signatures. If you can express the rule as "use the type system to prevent the bug" rather than "this exact stdlib function takes these exact arguments", do that — Luau's stdlib evolves; the typing principles don't.
  • Roblox APIs are out of scope here. For RemoteEvent, DataStore, Instance, services, etc., defer to the roblox-dev skill. This skill covers the language only.

Anti-Patterns

❌ Don't✅ Do
pairs(t) / ipairs(t)for k, v in t do
string.format(...)`interpolated {value}`
a and b or cif a then b else c
if x.Parent thenif x.Parent ~= nil then
local insert = table.insertInline table.insert
call "x" / call { ... }call("x") / call({ ... })
Reassignable constantsconst MAX = 100
Globalslocal / const
anyunknown + narrowing
Trivial local annotationsLet inference work
Untyped public functionAnnotate params + return
assert(typeof(x) == "T") to patch typesFix the upstream type
assert(cond) no message / formatted messageConstant message; if … then error(…) for formatted
pcall(part.Destroy, part)pcall(function() part:Destroy() end)
{ [K]: V } when keys may be missing{ [K]: V? }
Bare return from a T? functionExplicit return nil
for _, m in c:GetChildren() do require(m)Static require(c.X)
Sectioned require blocksOne alphabetical block
Yielding fn missing Async suffixSuffix Async
makeEnum({"red","green"})type Color = "red" | "green" + exhaustiveMatch
__call / __add / operator metamethodsPlain functions
Anonymous module returnlocal foo = ...; return foo
TableUtil mega-modulesOne function per file
Deep copy for immutable updateClone only the touched path
math.floor(a / b)a // b
Mutating module tabletable.freeze the return
Pyramid nestingEarly returns + continue

Examples

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Luau Expert?

Modern, strictly-typed Luau. Use whenever writing, reviewing, or fixing Luau code (ModuleScripts, ServerScripts, LocalScripts) — language layer only, not Roblox APIs. Covers strict mode, type system, idioms, asserts, modules, and anti-patterns.

Waarom Luau Expert gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Luau Expert bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Luau Expert in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/afrxo/roblox-agent-skills/tree/main/skills/luau-expert. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Luau Expert gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Luau Expert gebruiken?

Zoveel als je wilt. Je kunt Luau Expert gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Luau Expert gratis?

Ja. Deze skill is door afrxo op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇