Purpose
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.Prerequisites
- Node.js 18+ installed
- npm, yarn, or pnpm
- Lua CLI installed:
npm install -g lua-cli - Authentication configured (see below)
High-Level Workflow
lua init, the CLI surfaces a suggested build loop: compile → test → chat (sandbox) → push and deploy. Treat that sequence as your default checklist before iterating on agent code. Once the agent has release history, prefer lua version create + lua version promote as your release step instead of lua deploy — see §7 for the full distinction.
1. Authentication (PREREQUISITE)
Must authenticate before running any other CLI command.
Option A: API Key (Fully Non-Interactive)
If the user already has an API key:Option B: Email OTP (Semi Non-Interactive, 2 Steps)
If the user doesn’t have an API key yet: Step 1 - Request OTP:Workflow for AI Agents:
- Ask user if they have an API key
- If yes:
lua auth configure --api-key <key> - If no:
- Get user’s email
- Run
lua auth configure --email <email> - Ask user for the OTP they received via email
- Run
lua auth configure --email <email> --otp <code>
- Continue with
lua initonce authenticated
2. Initialization (lua init)
Two Modes
New Agent (--agent-name)
Creates a brand new agent from scratch:
Existing Agent (--agent-id)
Links to an agent that already exists:
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.
Non-Interactive Flags
Project Structure Created
3. Debugging with lua logs (read this BEFORE you write tools)
This section is promoted to the top because every AI builder needs the post-deploy loop in their head before they write a single tool. All
console.log, console.error, etc. output from your tool code shows up in lua logs. The CLI also prints a ✨ Tip: line at the end of every push/deploy/chat/sync/compile/test pointing at the right lua logs --type X --limit N command for what you just ran. Follow it.The “post-test-always-check” pattern
After everylua chat -m "test", immediately run:
agent_error probe automatically after every lua chat turn — when new errors fire, you’ll see:
LUA_NO_HINTS=1 to silence all post-action hints.
Post-deploy verification recipe
After deploying, always run this 3-line check:lua logs quick reference
Filter types
4. Agent Configuration (LuaAgent)
The main configuration lives insrc/index.ts:
Key Properties
5. Building Components
Skills & Tools
A Skill is a collection of related tools:Webhooks
HTTP endpoints for external events:Jobs
Scheduled cron tasks:PreProcessors & PostProcessors
6. Testing Strategy
This is one of the most important sections. Understanding when to use
lua test vs lua chat is critical.lua test - Isolated Component Testing
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
executefunction - Fast - no network latency, no AI processing time
inputSchema exactly
lua chat - Live Agent Testing
Purpose: Real agent requests involving AI
How it works:
- HTTP requests for streaming/generating responses
- Full integration - multiple components may execute (skills, tools, pre/post-processors)
Key Difference
Thread Isolation for Testing
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.--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.
--thread flags:
Concurrent Testing
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:
Clearing Conversation History (lua chat clear)
lua chat clear vs --thread:
Recommended Development Workflow
7. Push, Deploy, and Agent Versions
There are three commands involved in getting code live, and they do three different things:lua push - Upload Code to Server
- Compiles local code and uploads to Lua platform server/database
- Mints a new immutable version of that one primitive
- Code now exists on server, not just locally
- Activates nothing. Does NOT make it live yet.
lua version create + lua version promote - Recommended Release Flow
lua version createsnapshots the latest pushed version of every primitive (skills, webhooks, jobs, processors, triggers, persona, voice, MCP config, model) into a single agent version.lua version promote <N>atomically activates that snapshot — every primitive switches at once, with no window where some are old and some are new.- This is the recommended way to ship a release, especially when a change touches more than one primitive.
lua version status (shows what’s pushed but not yet live), lua version diff, and lua version list.
lua deploy - Legacy Single-Primitive Activation
- Makes a previously pushed version of one primitive live/active.
- Still fully supported, and still the fastest path for a one-off, single-primitive fix.
- Behavior depends on the agent’s history:
- If the agent has promoted at least one agent version already,
lua deployperforms a scoped promote: it creates and promotes a new agent version identical to the current one except for the primitive you just deployed. The change is live immediately, and it still appears inlua version list(tagged with adeploy …message) — so agent-version history stays consistent even when you use the legacy command. - If the agent has never created or promoted an agent version,
lua deployactivates the primitive directly, as before.
- If the agent has promoted at least one agent version already,
Key Difference
After
lua push without --auto-deploy, code is staged, not live. The CLI says so explicitly — for example:
lua push … --auto-deploy, run lua deploy explicitly, or run lua version create + lua version promote before validating in production.
Execution guarantee: once
lua deploy or lua version promote reports success, that exact code serves the very next invocation of the agent (allow up to roughly a minute for edge caches to catch up globally). Sandbox testing (lua chat, lua test) never touches what’s live, and deactivating a primitive (e.g. a webhook) stops it serving immediately regardless of version history.8. Environment Variables
Sandbox vs Production
Commands
9. Sandbox Overrides
When usinglua chat -e sandbox, the following can be overridden with local compiled code without needing to push/deploy:
This allows testing changes instantly without the push/deploy cycle.
10. Compilation Gotchas
The CLI uses esbuild to bundle eachexecute function:
What Works
- Standard TypeScript code
- Imports from
package.jsondependencies - Relative imports within your project
What May Not Work
- Not all Node.js file structures are supported
- Each execute function’s code is extracted and bundled separately
lua-cliimports are stripped - APIs likeUser,Products,Data,Agentsare sandbox globals
Warning Signs
Debug Mode
Run with--debug for verbose compilation output:
11. Platform APIs Available at Runtime
These are available as globals in the VM sandbox (don’t import from lua-cli):User: Per-User Persistent Storage
Critical for AI agents building stateful workflows. The
User API is the primary way to maintain state across conversations. It is a schemaless, persistent key-value store scoped to each end-user — not just a profile reader.- Onboarding flows — track
user.onboardingStep,user.completedSteps - Multi-step workflows — accumulate data across tool calls with
user.collectedData - Session state — store
user.lastIntent,user.pendingAction - User preferences — persist
user.theme,user.language,user.notificationSettings
user.onboardingStep (or any field) to track where the user is in a multi-step flow, then resume from that point in any future conversation:
update(), save(), send(), clear()).
12. Third-Party Integrations (POWERFUL FEATURE)
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.
Why This Matters
Instead of:- Writing API integration code
- Managing OAuth tokens and refresh logic
- Building tools for each third-party service
- Handling rate limits and error handling
- Tools like
linear_create_issue,linear_list_projects,linear_update_task, etc. - Triggers that wake up your agent when events occur (e.g., when a new issue is created)
How It Works
- Connect - Authenticate with the third-party service via OAuth or API token
- Auto-MCP - An MCP (Model Context Protocol) server is automatically created
- Instant Tools - Your agent can immediately use tools from that integration
- Triggers - Optionally enable triggers to wake up your agent on events
Discovery Commands (For AI Agents)
Before connecting, use discovery commands to understand what’s available:- Available OAuth scopes with friendly descriptions
- Available trigger events with friendly descriptions
- Webhook types (native vs virtual)
Connecting an Integration
Triggers: Event-Driven Agent Wake-Up
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.- 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 - The agent can respond based on what happened
Testing Integration Tools
After connecting, test immediately. Use--thread to keep each test isolated:
Available Integrations (250+)
Common integrations include:
Run
lua integrations available to see all available integrations for your workspace.
Managing MCP Servers for Integrations
Each integration creates an MCP server. You can manage them:Integration Workflow Example
Key Points for AI Agents
13. Complete Workflow Example
Quick Reference: Non-Interactive Commands
Related Documentation
Debugging Loop
Canonical post-deploy debug loop and the active
agent_error probeCLI Commands Reference
Complete CLI command documentation
Non-Interactive Mode
All non-interactive flags and CI/CD examples
Integrations Command
Connect 250+ third-party services
LuaAgent API
Complete LuaAgent configuration reference
Platform APIs
User, Data, Products, and other runtime APIs
MCP Servers
Manage MCP servers for external tools
Version Command
Atomic agent versions, promote, rollback, and version status

