cosmic
Quick reference for cosmic-lua — language essentials, CLI commands, and project conventions
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Quick reference for cosmic-lua — language essentials, CLI commands, and project conventions
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | cosmic |
| description | Quick reference for cosmic-lua — language essentials, CLI commands, and project conventions |
cosmic is a batteries-included Lua distribution built on Cosmopolitan Libc. it produces fat-binary executables that run on Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD from a single file. the source language is Teal (typed Lua) compiled to Lua 5.4.
source files use the .tl extension. formatting is 2-space indent, LF line endings. all .tl files must be <=500 lines.
cosmic script.tl # run a Teal script
cosmic --check types file.tl # type check (strict)
cosmic --check fmt file.tl # check formatting
cosmic --format file.tl # format to stdout
cosmic --test <out> <cmd> # run test, capture output
cosmic --docs [query] # search documentation
naming: snake_case for functions/variables, PascalCase for record types. doc comments use --- prefix with @param and @return tags.
error handling: return value, string (nil + error message on failure). never throw from library code.
imports: use cosmic.* modules.
local json = require("cosmic.json")
local data, err = json.decode(input)
if not data then
io.stderr:write("error: " .. err .. "\n")
os.exit(1)
end
use proc.is_main() to write files that work as both scripts and importable modules:
local proc = require("cosmic.proc")
local function greet(name: string): string
return "hello, " .. name
end
if proc.is_main() then
print(greet(arg[1] or "world"))
end
return { greet = greet }
run cosmic --docs guide.<topic> or see the files below for deeper coverage:
cosmic --test, assert patterns)cosmic --check typescosmic --format / --check fmtcosmic --makecosmic.* modules)