| name | simple-skill |
| version | 1.0.0 |
| description | A minimal example demonstrating how to create skills with Skill Engine |
| author | Skill Engine Team |
| allowed-tools | ["hello","echo","calculate"] |
Simple Skill
A minimal example demonstrating how easy it is to create skills with Skill Engine. This skill showcases the basic patterns for defining tools, handling parameters, and returning results - perfect for learning or as a template for new skills.
Overview
This skill requires no build steps - just write JavaScript and run! The runtime automatically compiles to WASM on first run and caches the result for fast subsequent executions.
When to Use This Skill
Use this skill to:
- Learn the basics of Skill Engine development
- Test skill execution and parameter handling
- Understand the skill.js file structure
- Use as a template for creating new skills
Use this skill as a reference when:
- Starting a new skill from scratch
- Understanding parameter types and validation
- Learning error handling patterns
- Setting up tool metadata
Features
- No build steps required - Just write JavaScript and run
- Auto-compilation - Runtime compiles to WASM on first run (~2-3 seconds) and caches
- Fast execution - Subsequent runs use cached WASM (<100ms startup)
- Auto-recompile - Modifications to skill.js trigger automatic recompilation
- Simple API - Export functions matching the skill interface
- Type-safe - Tool definitions provide schema for arguments
Tools
hello
Greet someone with a friendly message.
| Parameter | Type | Required | Default | Description |
|---|
| name | string | Yes | - | Name of the person to greet |
| greeting | string | No | Hello | Custom greeting message |
Example:
skill run simple-skill hello name=World
skill run simple-skill hello name=Alice greeting="Hi"
skill run ./examples/wasm-skills/simple-skill hello name=Bob
echo
Echo back the provided message, optionally repeating it multiple times.
| Parameter | Type | Required | Default | Description |
|---|
| message | string | Yes | - | Message to echo back |
| repeat | number | No | 1 | Number of times to repeat the message |
Example:
skill run simple-skill echo message="Hello World"
skill run simple-skill echo message="Testing" repeat=3
skill run simple-skill echo message="Skills are great!" repeat=2
calculate
Perform basic arithmetic operations on two numbers.
| Parameter | Type | Required | Description |
|---|
| operation | string | Yes | Operation: add, subtract, multiply, divide |
| a | number | Yes | First number |
| b | number | Yes | Second number |
Example:
skill run simple-skill calculate operation=add a=10 b=5
skill run simple-skill calculate operation=subtract a=20 b=8
skill run simple-skill calculate operation=multiply a=7 b=6
skill run simple-skill calculate operation=divide a=100 b=4
skill run simple-skill calculate operation=divide a=22 b=7
How It Works
First Run (Compilation)
- Runtime detects
skill.js needs compilation
- Compiles JavaScript โ WASM (takes ~2-3 seconds)
- Stores compiled WASM in
~/.skill-engine/local-cache/
- Executes the tool
Subsequent Runs (Cached)
- Runtime finds cached WASM
- Loads from cache (<100ms startup)
- Executes immediately
After Modifications
- Runtime detects
skill.js changed (via hash)
- Automatically recompiles to WASM
- Updates cache
- Executes with new code
Skill Structure
This skill demonstrates the minimal required structure:
export function getMetadata() {
return {
name: "simple-skill",
version: "1.0.0",
description: "A simple example skill",
author: "Skill Engine Team"
};
}
export function getTools() {
return [
{
name: "hello",
description: "Greet someone",
parameters: [
{
name: "name",
paramType: "string",
description: "Name to greet",
required: true,
defaultValue: "World"
}
]
}
];
}
export async function executeTool(toolName, argsJson) {
const args = JSON.parse(argsJson);
if (toolName === "hello") {
return {
success: true,
output: `Hello, ${args.name}!\n`,
errorMessage: null
};
}
return {
success: false,
output: "",
errorMessage: `Unknown tool: ${toolName}`
};
}
export async function validateConfig() {
return { ok: null };
}
Parameter Types Reference
When defining tools in getTools(), use these parameter types:
| paramType | JavaScript Type | Example Values | Validation |
|---|
string | String | "hello", "world" | Any text |
number | Number | 42, 3.14, -10 | Parsed as float |
boolean | Boolean | true, false | true/false only |
Parameter Properties
{
name: "param_name",
paramType: "string",
description: "What it does",
required: true,
defaultValue: "default"
}
Development Workflow
1. Create Your Skill
mkdir my-skill
cd my-skill
cat > skill.js << 'EOF'
export function getMetadata() {
return {
name: "my-skill",
version: "1.0.0",
description: "My first skill"
};
}
// ... add getTools() and executeTool() ...
EOF
2. Test Locally
skill run ./my-skill tool-name param1=value1
skill info ./my-skill
skill run ./my-skill tool-name --help
3. Iterate Quickly
vim skill.js
skill run ./my-skill tool-name
4. Install (Optional)
skill install ./my-skill
skill run my-skill tool-name
Using Configuration (Advanced)
If your skill needs configuration (API keys, URLs, etc.):
1. Create skill.config.toml
[config]
api_key = "your-key-here"
api_url = "https://api.example.com"
timeout = 30
2. Access via Environment Variables
Configuration is automatically exposed as environment variables with SKILL_ prefix:
export async function executeTool(toolName, argsJson) {
const apiKey = process.env.SKILL_API_KEY;
const apiUrl = process.env.SKILL_API_URL;
const timeout = parseInt(process.env.SKILL_TIMEOUT || "30");
}
3. Validate Configuration
export async function validateConfig() {
const apiKey = process.env.SKILL_API_KEY;
if (!apiKey) {
return {
ok: null,
error: "SKILL_API_KEY is required"
};
}
return { ok: null };
}
TypeScript Support
You can write skills in TypeScript - just change the extension:
mv skill.js skill.ts
skill run ./my-skill tool-name
Error Handling Best Practices
Return Proper Error Messages
return { success: false, output: "", errorMessage: "Error" };
return {
success: false,
output: "",
errorMessage: "Invalid operation: 'foo'. Use: add, subtract, multiply, or divide"
};
Validate Input Early
function handleCalculate(args) {
if (isNaN(parseFloat(args.a)) || isNaN(parseFloat(args.b))) {
return {
success: false,
output: "",
errorMessage: "Both 'a' and 'b' must be valid numbers"
};
}
const result = parseFloat(args.a) + parseFloat(args.b);
return { success: true, output: `${result}\n`, errorMessage: null };
}
Handle Edge Cases
function handleDivide(args) {
const a = parseFloat(args.a);
const b = parseFloat(args.b);
if (b === 0) {
return {
success: false,
output: "",
errorMessage: "Cannot divide by zero"
};
}
return { success: true, output: `${a / b}\n`, errorMessage: null };
}
Best Practices
- Keep it simple - Skills should be focused and do one thing well
- Document parameters - Use clear, descriptive parameter descriptions
- Validate input - Check required parameters and types early
- Return meaningful errors - Help users understand what went wrong
- Use descriptive names - Tool and parameter names should be self-explanatory
- Provide examples - Show real usage examples in SKILL.md
- Test edge cases - Handle invalid input gracefully
- Follow conventions - Use snake_case for parameters, lowercase for tool names
Testing Your Skill
skill info simple-skill
skill run simple-skill hello name=Test
skill run simple-skill echo message="Testing 123"
skill run simple-skill calculate operation=add a=2 b=2
skill run simple-skill hello
skill run simple-skill calculate operation=add
skill run simple-skill calculate operation=divide a=10 b=0
skill run simple-skill echo message="Test" repeat=-1
Next Steps
After mastering this simple skill:
-
Study More Examples:
github-skill - HTTP API integration
slack-skill - OAuth authentication
kubernetes-skill - Native tool execution
-
Learn the SDK:
- Type-safe parameter validation
- HTTP client utilities
- Error handling helpers
- Authentication patterns
-
Build Real Skills:
- Integrate with APIs you use
- Automate your workflows
- Share with the community
Resources
License
MIT - Use as a template for your own skills!