roblox-luau-patterns — Claude Code skill: Luau patterns for Roblox
A skill for writing and refactoring Roblox Luau modules: object lifecycles, signals, task scheduling, pcall and cleanup.
npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a claude-codeWhat roblox-luau-patterns does
The skill loads when you write or refactor Roblox modules in Luau. It walks through module shape: plain functions for stateless transformation, a module with private state when one subsystem owns it, an object with a metatable when several independent values share behavior. Constructors use ., instance methods use :, and mutable fields sit on the instance rather than the class table.
Ownership gets its own section. Signal connections, instances and tasks need an owner that disconnects or cancels them at teardown. The skill advises configuring an object before parenting it so partial state never shows, and exporting typed signal payloads as Signal<T...>. Failure semantics matter too: the pcall example keeps a successful call that returned nil separate from a failed one. Retry only when the operation is safe to repeat.
For scheduling, it asks you to pick task.defer, task.spawn, task.delay and task.cancel on purpose, and to drop legacy wait() plus polling with no justification. If you do poll, choose an explicit cadence and measure it. A review checklist closes things out: clear owner, narrow public API, no circular require, success and missing-data states still distinct. Client input is routed to the companion roblox-networking skill, while semantics, types and startup live in other skills of the set.
What it helps with
- pick a module shape instead of adding a manager class just to namespace functions
- find signal connections that nobody disconnects
- tell a successful pcall returning nil apart from a real failure
- stop duplicate handlers from piling up after respawn
- replace legacy wait() and needless polling with task functions
Example prompts for the agent
- Review this Roblox Luau module for memory leaks and tell me who owns the connections
- Rewrite the respawn handler so duplicate handlers don't appear after the player respawns
- Check the task scheduling in this script and remove the unnecessary polling
How to install roblox-luau-patterns
1Skills CLI (Vercel)
npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a claude-code2Manually: put the files in place
~/.claude/skills/roblox-luau-patterns/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/roblox-luau-patterns/
1Skills CLI (Vercel)
npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a codex2Manually: put the files in place
.agents/skills/roblox-luau-patterns/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a cursor2Manually: put the files in place
.cursor/skills/roblox-luau-patterns/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install TabooHarmony/roblox-brain roblox-luau-patterns2Manually: put the files in place
.github/skills/roblox-luau-patterns/SKILL.md1Skills CLI (Vercel)
npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a gemini-cli2Platform CLI
gemini skills install https://github.com/TabooHarmony/roblox-brain --path skills/core/roblox-luau-patternsManually: put the files in place
.devin/skills/roblox-luau-patterns/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about roblox-luau-patterns
How do I install roblox-luau-patterns in Claude?
Run npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a claude-code. The skill lands at ~/.claude/skills/roblox-luau-patterns/SKILL.md.
What does roblox-luau-patterns do?
It guides writing and refactoring Roblox Luau modules: choosing a module shape, owning signals and tasks, keeping pcall failure semantics straight, and scheduling with task functions.
Which skills does it work alongside?
roblox-luau-core covers Luau semantics, roblox-luau-types covers types, roblox-architecture covers startup, and client input goes to roblox-networking.
Source text
SKILL.md · MIT
---
name: roblox-luau-patterns
description: "Use when writing or refactoring Roblox Luau modules, object lifecycles, signals, task scheduling, pcall, and cleanup."
when_to_use: "Also for memory leaks, connections never disconnected, duplicate handlers after respawn, task.spawn/defer/delay misuse, retries, and reviewing module structure."
last_reviewed: 2026-10-14
sources:
- https://luau-lang.org/
- https://luau.org/library
- https://create.roblox.com/docs/reference/engine/classes/ObjectValue
- https://create.roblox.com/docs/reference/engine/classes/StringValue
- https://create.roblox.com/docs/reference/engine/classes/CFrameValue
- https://devforum.roblox.com/t/studio-beta-reference-instances-directly-with-attributes/4753441
- https://raw.githubusercontent.com/Kampfkarren/kampfkarren-luau-guidelines/main/README.md
- original
---
# Luau Patterns
## When to Load
Load for module shapes, resource ownership, scheduling, and failure contracts. See `roblox-luau-core` for semantics, `roblox-luau-types` for types, `roblox-architecture` for startup.
## Quick Reference
### Choose a shape
- **Plain functions:** default for stateless transformation or validation.
- **Module with private state:** one explicit subsystem owner. Do not create a manager class merely to namespace functions.
- **Object with metatable:** multiple independent values need shared behavior and lifecycle.
- **Existing library abstraction:** follow it when the project already uses it consistently. Do not add Promise, signal, cleanup, or framework dependencies for one call site.
Constructors use `.`, instance methods use `:`, and mutable fields belong on the instance, not the class table.
### Make ownership visible
Signal connections, instances, and tasks need cleanup owners. Disconnect/cancel at teardown. Export typed custom signal payloads (`Signal<T...>`).
Configure before parenting to hide partial state. Parent earlier only when ancestry is required; explain why. This does not guarantee replication ordering.
### Preserve failure semantics
```luau
local ok, value = pcall(dataStore.GetAsync, dataStore, key)
if not ok then
return nil, `read failed: {value}`
end
return value, nil -- value may legitimately be nil
```
Do not collapse "call succeeded and returned nil" into "call failed." Retry only when the domain operation is safe to repeat. Persistence, HTTP, purchases, and remotes belong to their domain skills.
### Naming and return contracts
Practitioner conventions: mark yielding functions `Async`, keep return counts consistent, and prefer named module exports. Respect existing project contracts; details in full.md.
### Schedule deliberately
Use `task.defer`, `task.spawn`, `task.delay`, and `task.cancel` deliberately. Avoid legacy `wait()` and unjustified polling. Prefer a real state-change signal; otherwise choose and measure an explicit cadence.
### Review
Clear owner, narrow public API, no circular require, no accidental concurrent startup, success and missing-data states remain distinct, connections/tasks cleaned up, client input routed to `roblox-networking`.
> Details: [references/full.md](references/full.md)
© TabooHarmony · MIT · TabooHarmony/roblox-brain