LuaSkill is the main class for defining a skill - a collection of related tools that your AI agent can use.
Copy
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()]});
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.
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() ]});
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() ]});
const skill = new LuaSkill({ name: "dynamic-skill", description: "Skill with dynamically added tools", context: "Tools will be added based on configuration"});// Add tools conditionallyif (config.enableWeather) { skill.addTool(new GetWeatherTool());}if (config.enableOrders) { skill.addTools([ new CreateOrderTool(), new TrackOrderTool() ]);}
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`
// ✅ Gooddescription: "Provides real-time weather information and 7-day forecasts for cities worldwide"// ❌ Baddescription: "Weather stuff"
Provide Detailed Context
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.
Organize Related Tools
Group tools that work together:
Copy
// ✅ Good - Related tools togetherconst orderSkill = new LuaSkill({ tools: [ new CreateOrderTool(), new UpdateOrderTool(), new CancelOrderTool(), new TrackOrderTool() ]});// ❌ Bad - Unrelated tools mixedconst messySkill = new LuaSkill({ tools: [ new GetWeatherTool(), new CreateOrderTool(), new SendEmailTool() ]});