Skip to main content

Overview

LuaSkill is the main class for defining a skill - a collection of related tools that your AI agent can use.
import { LuaSkill } from 'lua-cli';

const skill = new LuaSkill({
  name: "my-skill",
  description: "Brief description of the skill",
  context: "Detailed instructions for the AI",
  tools: [new MyTool1(), new MyTool2()]
});

Constructor

new LuaSkill(config)

Creates a new skill instance.
config
LuaSkillConfig
required
Skill configuration object

Configuration Parameters

config.name
string
default:"unnamed-skill"
Unique identifier for the skillFormat: lowercase, alphanumeric, hyphens onlyExamples: "weather-skill", "product-catalog-skill"
config.description
string
required
Brief description (1-2 sentences) of what the skill doesThis appears in skill listings and helps users understand the skill’s purpose.
config.context
string
required
Detailed instructions for the AI on when and how to use the toolsThis is critical for proper tool selection! Write it like instructions to a smart assistant.
config.tools
LuaTool[]
Array of tool instances to include in the skillCan be empty initially and tools added later with addTool() or addTools().

Methods

addTool()

Adds a single tool to the skill.
skill.addTool(tool: LuaTool): void
tool
LuaTool
required
Tool instance to add
Example:
const skill = new LuaSkill({
  name: "my-skill",
  description: "My skill",
  context: "..."
});

skill.addTool(new GetWeatherTool());
skill.addTool(new CreateOrderTool());
Validation:
  • Tool name must be unique within the skill
  • Tool name must only contain: a-z, A-Z, 0-9, -, _
  • Throws error if validation fails

addTools()

Adds multiple tools to the skill at once.
skill.addTools(tools: LuaTool[]): void
tools
LuaTool[]
required
Array of tool instances to add
Example:
skill.addTools([
  new GetWeatherTool(),
  new CreateOrderTool(),
  new SearchProductsTool()
]);
Validation:
  • All tools validated before adding
  • Atomic operation (all or nothing)
  • Throws error if any validation fails

Examples

Basic Skill

import { LuaSkill, LuaTool } from 'lua-cli';
import { z } from 'zod';

class HelloTool implements LuaTool {
  name = "say_hello";
  description = "Say hello to a user";
  inputSchema = z.object({
    name: z.string()
  });

  async execute(input: any) {
    return { message: `Hello, ${input.name}!` };
  }
}

const helloSkill = new LuaSkill({
  name: "hello-skill",
  description: "A simple greeting skill",
  context: "Use say_hello when users want to be greeted",
  tools: [new HelloTool()]
});

Weather Skill

import { LuaSkill } from 'lua-cli';
import GetWeatherTool from './tools/GetWeatherTool';
import GetForecastTool from './tools/GetForecastTool';

const weatherSkill = new LuaSkill({
  name: "weather-skill",
  description: "Provides weather information for any city worldwide",
  context: `
    This skill provides weather information.
    
    - Use get_weather for current conditions
    - Use get_forecast for 7-day predictions
    
    Always include the city name in responses.
    Mention temperature in user's preferred units.
  `,
  tools: [
    new GetWeatherTool(),
    new GetForecastTool()
  ]
});

E-commerce Skill

import { LuaSkill } from 'lua-cli';
import {
  SearchProductsTool,
  CreateProductTool,
  UpdateProductTool
} from './tools/ProductTools';

const ecommerceSkill = new LuaSkill({
  name: "ecommerce-skill",
  description: "Complete e-commerce product management",
  context: `
    This skill manages an e-commerce product catalog.
    
    Tool Usage:
    - search_products: When users describe what they're looking for
    - create_product: When adding new items (admin only)
    - update_product: When modifying prices, stock, or details
    
    Guidelines:
    - Always show prices with currency
    - Mention stock availability
    - Suggest related products when relevant
    - Confirm changes before updating
  `,
  tools: [
    new SearchProductsTool(),
    new CreateProductTool(),
    new UpdateProductTool()
  ]
});

Adding Tools Dynamically

const skill = new LuaSkill({
  name: "dynamic-skill",
  description: "Skill with dynamically added tools",
  context: "Tools will be added based on configuration"
});

// Add tools conditionally
if (config.enableWeather) {
  skill.addTool(new GetWeatherTool());
}

if (config.enableOrders) {
  skill.addTools([
    new CreateOrderTool(),
    new TrackOrderTool()
  ]);
}

Writing Good Context

The context field is critical for AI tool selection. Follow these guidelines:

Structure

context: `
  [What this skill does - 1 sentence]
  
  Tool Usage:
  - tool_1: [When to use] [What it returns]
  - tool_2: [When to use] [What it returns]
  
  Guidelines:
  - [Important rules]
  - [Edge cases]
  - [User experience tips]
`

Good Context Example

context: `
  This skill manages customer orders for a coffee shop.

  Tool Usage:
  - show_menu: Use when customers ask what's available. Returns drinks and food.
  - create_order: Use when taking an order. Confirm items and sizes first.
  - modify_order: Use to add/remove items. Ask which item to modify.
  - finalize_order: Use when confirmed. Returns total and estimated time.

  Guidelines:
  - Always ask about drink sizes (small/medium/large)
  - Mention daily special when showing menu
  - Confirm total before finalizing order
  - Ask about dietary restrictions for food
`

Poor Context Example

context: "A skill with tools for stuff"  // ❌ Too vague

Best Practices

// ✅ Good
name: "weather-skill"
name: "product-catalog-skill"
name: "customer-support-skill"

// ❌ Bad
name: "skill1"
name: "my_skill"
name: "test"
// ✅ Good
description: "Provides real-time weather information and 7-day forecasts for cities worldwide"

// ❌ Bad
description: "Weather stuff"
The context field should include:
  • Overview of skill purpose
  • When to use each tool
  • Important guidelines
  • Edge cases to handle
Think of it as training documentation for the AI.

Multi-Skill Projects

You can define multiple skills in one project:
// Product browsing
const catalogSkill = new LuaSkill({
  name: "catalog-skill",
  description: "Product browsing and search",
  tools: [new SearchProductsTool(), new GetProductTool()]
});

// Shopping cart
const cartSkill = new LuaSkill({
  name: "cart-skill",
  description: "Shopping cart management",
  tools: [new CreateBasketTool(), new AddItemTool()]
});

// Order processing
const orderSkill = new LuaSkill({
  name: "order-skill",
  description: "Order creation and tracking",
  tools: [new CreateOrderTool(), new TrackOrderTool()]
});
Each skill gets its own skillId in lua.skill.yaml and can be deployed independently.

Type Definitions

interface LuaSkillConfig {
  name?: string;
  description: string;
  context: string;
  tools?: LuaTool[];
}

class LuaSkill {
  constructor(config: LuaSkillConfig);
  addTool(tool: LuaTool): void;
  addTools(tools: LuaTool[]): void;
}

Next Steps