Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add TabooHarmony/roblox-brain --skill roblox-luau-patterns -a claude-code
Open on GitHub

What 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-code

2Manually: put the files in place

~/.claude/skills/roblox-luau-patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/roblox-luau-patterns/

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

Similar skills

Everything for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set28

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor