This guide is specifically designed for AI Agents and AI Coding IDEs (Cursor, Windsurf, GitHub Copilot, etc.) to build agents on the Lua platform using non-interactive CLI commands.All commands in this guide use flags and arguments that work without interactive prompts, enabling full automation.
# Create agent in existing organizationlua init --agent-name "My Agent" --org-id org_abc123# Create agent + new organizationlua init --agent-name "My Agent" --org-name "My Company"# With example code includedlua init --agent-name "My Agent" --org-id org_abc123 --with-examples
Important limitation: Existing code/primitives on the server CANNOT be pulled down to local codebase. Bundling is one-way only (local → server). Use this mode to start fresh development on an existing agent.
import { LuaAgent, LuaSkill } from 'lua-cli';export const agent = new LuaAgent({ name: 'my-agent', persona: `You are a helpful assistant.Your role:- Help users with their tasks- Provide accurate informationCommunication style:- Friendly and professional- Clear and concise`, skills: [mySkill], // Optional components: // webhooks: [myWebhook], // jobs: [myJob], // preProcessors: [myPreProcessor], // postProcessors: [myPostProcessor],});
import { LuaSkill } from 'lua-cli';const mySkill = new LuaSkill({ name: 'my-skill', description: 'Brief description of the skill', context: `Detailed instructions for when to use these tools. - Use tool_a when user asks about X - Use tool_b when user wants to do Y`, tools: [new ToolA(), new ToolB()]});
A Tool is a single function the AI can call:
Copy
import { LuaTool } from 'lua-cli';import { z } from 'zod';class GetWeatherTool implements LuaTool { name = 'get_weather'; description = 'Get current weather for a city'; inputSchema = z.object({ city: z.string().describe('City name'), units: z.enum(['metric', 'imperial']).optional().default('metric') }); async execute(input: z.infer<typeof this.inputSchema>) { const { city, units } = input; // Implementation here return { temperature: 22, condition: 'sunny', city }; }}
Purpose: Unit test for individual blocks (tools, jobs, webhooks, processors)How it works:
Creates a local VM and executes code directly
No AI involved - just runs the execute function
Fast - no network latency, no AI processing time
Use for: Quick testing, quick debugging, building components in isolationInput format: Must match the tool’s inputSchema exactly
Copy
# Test a toollua test skill --name get_weather --input '{"city": "London"}'# Test a webhooklua test webhook --name payment-webhook --input '{"query": {}, "headers": {}, "body": {"type": "payment.completed"}}'# Test a joblua test job --name daily-report# Test a preprocessorlua test preprocessor --name profanity-filter --input '{"message": "hello", "channel": "web"}'# Test a postprocessorlua test postprocessor --name add-disclaimer --input '{"message": "hi", "response": "hello", "channel": "web"}'
Purpose: Real agent requests involving AIHow it works:
HTTP requests for streaming/generating responses
Full integration - multiple components may execute (skills, tools, pre/post-processors)
Two modes:
Mode
Description
sandbox
Free, unbilled, can override local code without push/deploy
production
Uses pushed and deployed versions
Copy
# Test in sandbox (uses local code)lua chat -e sandbox -m "What's the weather in London?"# Test in production (uses deployed code)lua chat -e production -m "What's the weather in London?"
Recommended for AI agents running automated tests. Use --thread to scope each chat session to an isolated conversation context. This prevents test state from leaking between runs — no need to call lua chat clear between tests.
Each --thread creates a completely independent conversation context. This also means multiple tests can run concurrently (5-10 at a time) without interfering with each other.
Copy
# Scope to an explicit thread IDlua chat -e sandbox -m "Test scenario A" --thread scenario-a# Auto-generate a UUID thread (printed at start so you can log/reuse it)lua chat -e sandbox -m "Test scenario B" --thread# Isolated test with automatic cleanup after responselua chat -e sandbox -m "Test scenario C" -t scenario-c --clear# Run 10 isolated tests sequentially, each with a clean contextfor i in $(seq 1 10); do lua chat -e sandbox -m "test scenario $i" -t "test-$i" --cleardone
--thread flags:
Flag
Description
-t, --thread [id]
Scope to a named thread. Omit the ID to auto-generate a UUID. Thread ID is printed at session start.
--clear, --clear-thread
Clear the thread’s history when the session ends (interactive: on exit, non-interactive: after response). Requires --thread.
Because each --thread is a fully isolated conversation, you can run multiple lua chat invocations in parallel without any state collision. This is especially useful for AI agents that need to validate multiple conversation scenarios at once:
Compiles local code and uploads to Lua platform server/database
Creates a version on the server
Code now exists on server, not just locally
Does NOT make it live yet
Copy
# Push a specific skill with versionlua push skill --name mySkill --set-version 1.0.0 --force# Push all componentslua push all --force# Push and immediately deploylua push all --force --auto-deploy
This is one of the most powerful features of the Lua platform. With a single command, you can give your agent access to 250+ third-party services (Linear, Discord, Google Calendar, HubSpot, Slack, GitHub, and more) - without writing any code.
Before connecting, use discovery commands to understand what’s available:
Copy
# List all available integrationslua integrations available# Get detailed info about an integration (scopes and triggers)lua integrations info linear# Get info as JSON (for parsing)lua integrations info linear --json# List available trigger eventslua integrations webhooks events --integration linearlua integrations webhooks events --integration linear --json
JSON output is especially useful for AI coding assistants to programmatically discover:
Available OAuth scopes with friendly descriptions
Available trigger events with friendly descriptions
# View available integrationslua integrations available# Connect with OAuth and triggers (recommended)lua integrations connect --integration linear --auth-method oauth --scopes all \ --triggers task_task.created,task_task.updated# Connect with all available triggerslua integrations connect --integration linear --auth-method oauth --scopes all --triggers all# Connect with specific scopes only (no triggers)lua integrations connect --integration linear --auth-method oauth --scopes "task_task_read,task_task_write"# Connect with API tokenlua integrations connect --integration linear --auth-method token# List connected integrationslua integrations list# Update scopes on existing connectionlua integrations update --integration linear --scopes all# Disconnectlua integrations disconnect --connection-id <id>
Triggers are one of the easiest ways to make your agent reactive. When enabled, your agent automatically wakes up when events occur in connected services.
Copy
# Enable triggers during connectionlua integrations connect --integration linear --auth-method oauth --scopes all \ --triggers task_task.created,task_task.updated# Or add triggers after connectionlua integrations webhooks create --connection <id> --object task_task --event created# List active triggerslua integrations webhooks list# Delete a triggerlua integrations webhooks delete --webhook-id <id>
What happens when a trigger fires:
An event occurs in the connected service (e.g., a new Linear issue is created)
Unified.to sends a webhook to your agent
Your agent wakes up with the event data in runtimeContext
After connecting, test immediately. Use --thread to keep each test isolated:
Copy
# Test integration tools in isolated threads (can run concurrently)lua chat -e sandbox -m "Create a Linear issue titled 'Test from Lua' in my default project" -t test-linear --clearlua chat -e sandbox -m "List my upcoming Google Calendar events" -t test-gcal --clearlua chat -e sandbox -m "Send a message to the #general channel on Discord" -t test-discord --clear
# 1. Discover available integrations and their capabilitieslua integrations availablelua integrations info linear --json# 2. Connect Linear with triggerslua integrations connect --integration linear --auth-method oauth --scopes all \ --triggers task_task.created,task_task.updated# (Complete OAuth in browser)# 3. Verify connection and triggerslua integrations listlua integrations webhooks list# 4. Test the integration in isolated threadslua chat -e sandbox -m "List all Linear projects I have access to" -t test-list --clearlua chat -e sandbox -m "Create a task in Linear: Review documentation updates" -t test-create --clear# 5. The agent now has full Linear capabilities and reacts to events!