larvance/craft/scripting-automation
Claude Code and agent skill by larvance/craft
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install larvance/craft/scripting-automationSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as larvance/craft/scripting-automation.
Embedded Lua Scripting Runtime, Automation & Lifecycle Hooks Skill Guide
Domain: Embedded Lua 5.4 VM, Event-Driven Lifecycle Bus, Headless Automation & ModalX TUIPrimary Location:crates/scripting/,crates/daemon/,crates/cli/src/commands/script.rs
1. Lua 5.4 Runtime Architecture & Isolation
Craft embeds Lua 5.4 via mlua 0.12 to provide sandboxed, high-performance scripting capabilities for dedicated server orchestration, automation pipelines, and reactive lifecycle event processing.
1.1. Execution Guardrails & Timeout Enforcement
To prevent rogue Lua scripts from entering infinite loops or exhausting supervisor resources, the runtime enforces an instruction-counting deadline hook:
2. Standard Library API Reference (craft.*)
All Lua scripts executed under Craft have access to the sandboxed craft.* namespace:
2.1. Logging (craft.log)
craft.log.info(msg: string): Log informational message with[INFO]prefix.craft.log.warn(msg: string): Log warning message with[WARN]prefix.craft.log.error(msg: string): Log error message with[ERROR]prefix.craft.log.debug(msg: string): Log debug message with[DEBUG]prefix.
2.2. Host Platform & Environment (craft.platform)
craft.platform.os() -> string: Current operating system ("linux","windows","macos").craft.platform.arch() -> string: Architecture string ("x86_64","aarch64").craft.platform.is_windows() -> boolean: True if running on Windows.craft.platform.is_linux() -> boolean: True if running on Linux.craft.platform.is_macos() -> boolean: True if running on macOS.craft.platform.env(var_name: string) -> string|nil: Read environment variable.
2.3. Safe Filesystem Operations (craft.fs)
craft.fs.exists(path: string) -> boolean: Check if file or directory exists.craft.fs.is_file(path: string) -> boolean: Check if path is a regular file.craft.fs.is_dir(path: string) -> boolean: Check if path is a directory.craft.fs.read_string(path: string) -> string: Read text file contents.craft.fs.write_string(path: string, content: string) -> boolean: Write text file contents.craft.fs.copy(src: string, dst: string) -> boolean: Copy file or directory.craft.fs.remove(path: string) -> boolean: Remove file or directory.craft.fs.size(path: string) -> integer: Get file size in bytes.
2.4. Fleet Server Management (craft.servers)
craft.servers.list() -> table: Returns array of server tables{ name, path, software, game, port, running, pid }.craft.servers.get(name: string) -> table|nil: Returns server metadata table.craft.servers.start(name: string) -> boolean, string: Dispatches server startup via daemon IPC.craft.servers.stop(name: string) -> boolean, string: Dispatches server shutdown via daemon IPC.craft.servers.command(name: string, command: string) -> boolean, string: Injects stdin console command.
2.5. Hot Backup Operations (craft.backup)
craft.backup.list(server_name: string) -> table: Returns array of backup objects{ filename, size_bytes, modified_epoch }.craft.backup.create(server_name: string, note?: string) -> table: Dispatches hot backup and returns summary table{ filename, size_bytes, path }.
2.6. Binary Protocol Network Ping (craft.net)
craft.net.ping(host: string, port: integer) -> table: Queries remote game server via SLP/RakNet/A2S_INFO. Returns{ online: boolean, motd: string, players_online: integer, players_max: integer, version: string, latency_ms: integer }.
2.7. Outbound HTTP Networking (craft.http)
craft.http.get(url: string, headers?: table) -> table: Synchronous HTTP GET. Returns{ status: integer, body: string, ok: boolean }.craft.http.post(url: string, body: string, headers?: table) -> table: Synchronous HTTP POST. Returns{ status: integer, body: string, ok: boolean }.
2.8. Immutable Cryptographic Audit Log (craft.audit)
craft.audit.log(action: string, details?: string, server?: string) -> boolean: Appends an entry into Craft's HMAC-SHA256 verified audit ledger.
2.9. Command Execution (craft.exec)
craft.exec.run(command: string, args: table) -> table: Executes host process with captured output. Returns{ exit_code: integer, stdout: string, stderr: string }.
3. Server Lifecycle Hook Bus
The supervisor daemon triggers asynchronous lifecycle hooks at critical state transitions.
3.1. Supported Lifecycle Triggers
ServerStart: Dispatched when a server process is spawned and detached.ServerStop: Dispatched when an intentional stop command is executed.ServerCrash: Dispatched when a child process exits abnormally with a non-zero code.CircuitTrip: Dispatched when rapid crash loops trigger the daemon circuit breaker.BackupStart: Dispatched immediately prior to atomic snapshot creation.BackupComplete: Dispatched upon successful backup archive generation.StorageLow: Dispatched when free disk space falls below critical thresholds (<5 GB).PlayerJoin: Dispatched upon player network handshake or proxy login.
3.2. Script Discovery Hierarchy
Hooks are automatically discovered and executed in the following order:
- Global Unified Hook:
~/.craft/hooks/hooks.lua(matches function name corresponding to event). - Global Event-Specific Hook:
~/.craft/hooks/<event_name>.lua(e.g.on_server_crash.lua). - Per-Server Hook:
<server_dir>/hooks.lua(scoped exclusively to the target server).
3.3. Hook Context Table (context)
Every hook script receives an injected global table context with the following schema:
3.4. Logging and Audit Trail
Every hook invocation is recorded to ~/.craft/logs/hooks.log with timestamp, event kind, duration in milliseconds, success flag, and any runtime error traces.
4. Headless CLI Automation Suite
5. ModalX Interactive Studio Submenu
Craft's interactive dashboard incorporates the Lua Automation & Lifecycle Hooks panel:
- Hook Catalog: Visualizes registered global and per-server hooks with status indicators (
[GLOBAL],[LOCAL]). - Event Simulator: Interactive wizard to simulate lifecycle events (
ServerStart,BackupComplete,StorageLow) with real-time feedback and execution duration. - Headless Runner: Execute any
.luafile interactively with stdout modal replay. - Inline Expression Evaluator: Interactive REPL to evaluate Lua expressions and view typed return values.
- Scaffolding Wizard: Generates production-ready Lua templates in
~/.craft/scripts/or per-server directories.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinganalysis/scripting-automation/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/larvance/craft/scripting-automation)