This skill provides best practices for coding in Luau, aimed at Roblox game developers. It emphasizes server authority, clear code intent, and efficient validations.
$ npx skills add https://github.com/dig1t/skills --skill luau-best-practicesThis skill provides production-quality patterns for Luau development on Roblox. It guides you through core principles like server authority, fail-fast validation, and explicit code intent, with concrete examples for naming conventions, file organization, module patterns, and error handling. The skill covers critical topics including pcall usage for external APIs, memory leak prevention with maids and weak references, and server-authoritative security practices with input validation and rate limiting. Use it when writing new modules, reviewing code quality, setting up project structure, implementing error handling, or refactoring existing code. It helps Roblox developers follow Roblox-specific conventions and avoid common anti-patterns like deprecated async functions and inefficient loops.
Install via npm using the command provided.
Improve code quality in Roblox games
Establish clear coding guidelines
Enhance collaboration among developers
$ npx skills add https://github.com/dig1t/skills --skill luau-best-practicesgit clone https://github.com/dig1t/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Provide Luau best practices for [ROBLOX_GAME] in [GAME_SECTION], focusing on [SPECIFIC_ISSUE]. Include examples of efficient validations and server authority patterns.
### Luau Best Practices for [ROBLOX_GAME] - [GAME_SECTION]
#### **1. Server Authority & Validation**
✅ **Do:** Use `ServerScriptService` for critical logic to prevent client exploits.
```lua
-- Server-side validation example
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if player.UserId == 123456789 then -- Admin check
player:SetAttribute("IsAdmin", true)
end
end)
```
❌ **Avoid:** Trusting client-side inputs for game-critical systems (e.g., currency, inventory).
#### **2. Clear Intent with Type Annotations**
✅ **Do:** Use Luau type checking to document and enforce expected data shapes.
```lua
type PlayerStats = {
Health: number,
Coins: number,
Inventory: { Item: string }
}
local function updateStats(player: Player, stats: PlayerStats)
-- Logic here
end
```
#### **3. Efficient Event Handling**
✅ **Do:** Debounce rapid events (e.g., clicks) to reduce server load.
```lua
local debounce = false
local function onClick(player: Player)
if debounce then return end
debounce = true
-- Process click
task.delay(0.5, function() debounce = false end)
end
```Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan