lang-lua

Standardize Lua code style, scoping, error handling, and metatable-based OOP.

Updated Mar 19, 2026
One-click install
npx skills add https://github.com/dragoscirjan/opencode-config --skill lang-lua
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lang-lua
Source: https://github.com/dragoscirjan/opencode-config/tree/main/skills/lang-lua
Command: npx skills add https://github.com/dragoscirjan/opencode-config --skill lang-lua

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you produce consistent, maintainable Lua code by enforcing clear style rules, disciplined scoping, and predictable error handling.

Core Features & Use Cases

  • Style Guidance: Follows the Lua Style Guide to keep code readable and idiomatic.
  • Tooling Alignment: Supports StyLua formatting, luacheck linting, and busted testing for a cohesive quality workflow.
  • Safe Runtime Patterns: Encourages local-only scope, nil-and-error returns for expected failures, and pcall or xpcall for unexpected failures.
  • Lua OOP Patterns: Uses metatables and __index for object-oriented design in modules and application code.
  • Use Case: Apply this Skill when reviewing or authoring Lua plugins, scripts, or game logic that must stay clean, testable, and free of global namespace pollution.

Quick Start

Ask the assistant to review my Lua file for style, local scoping, error handling, and metatable-based object orientation.

Frequently Asked Questions about lang-lua

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce local-only variables and avoid global namespace pollution in Lua?

To enforce local-only variables in Lua, apply strict scoping rules that require explicit local declarations for all variables and functions. This approach prevents global namespace pollution and maintains predictable module behavior.

What is the best way to handle errors in Lua scripts using pcall and xpcall?

The best way to handle Lua errors is using nil-and-error returns for expected failures, and pcall or xpcall for unexpected failures. This pattern ensures safe runtime execution and predictable script behavior.

How do I set up object-oriented design in Lua modules using metatables?

Object-oriented design in Lua modules is set up using metatables and the __index metamethod. This pattern allows you to create classes and inheritance structures while keeping your application code clean and maintainable.

Does StyLua formatting work with luacheck linting and busted testing workflows?

Yes, StyLua formatting works seamlessly with luacheck linting and busted testing. Aligning these tools creates a cohesive quality workflow that standardizes Lua code style, verifies scoping, and validates module behavior.

Why does my Lua code fail style checks when using metatables for object-oriented patterns?

Lua code fails style checks when metatable implementations ignore local scoping or idiomatic style guide rules. Aligning metatable-based object-oriented design with local-only function definitions and StyLua formatting resolves these style violations.