SkillBase

View as MarkdownOpen in Claude

SkillBase is the abstract base class for all agent skills. Skills are modular, reusable capabilities — such as weather lookup, web search, or calendar access — that can be added to any AgentBase agent with a single call to agent.addSkill().

Extend SkillBase to create custom skills. You must implement the abstract methods getManifest() and getTools(), and optionally override lifecycle and prompt methods.

For the catalog of built-in skills and their configuration parameters, see the Skills page.

Static Members

SUPPORTS_MULTIPLE_INSTANCES
booleanDefaults to false

When true, the same skill can be added to an agent multiple times with different configurations.

getParameterSchema()
static method

Returns metadata about all parameters the skill accepts. See getParameterSchema.

Constructor

1constructor(skillName: string, config?: SkillConfig)
skillName
stringRequired

Unique identifier for the skill (e.g., "weather", "web_search").

config
SkillConfig

Optional configuration key-value pairs for the skill instance.

Instance Properties

skillName
string

The registered name for this skill instance (readonly).

instanceId
string

Unique identifier for this skill instance (readonly).

config
SkillConfig

Configuration parameters passed to the constructor (protected).

swaigFields
Record<string, unknown>

SWAIG metadata extracted from config, automatically merged into tool definitions (readonly).

Methods

getManifest (abstract)

1abstract getManifest(): SkillManifest

Returns the skill’s metadata including name, description, version, required environment variables, and required packages. You must implement this in every subclass.

getTools (abstract)

1abstract getTools(): SkillToolDefinition[]

Returns the SWAIG tool definitions this skill provides. You must implement this in every subclass. Each tool is registered with the agent when the skill is loaded.

getConfig

1getConfig<T = unknown>(key: string, defaultValue?: T): T

Read a configuration value by key, with an optional fallback default. Returns the value cast to type T, or defaultValue if the key is not present.

key
stringRequired

The configuration key to look up.

defaultValue
T

Value to return if the key is not present in the config.

Examples

Custom skill

1import { SkillBase, SkillManifest, SkillToolDefinition } from '@signalwire/sdk';
2
3class MyWeatherSkill extends SkillBase {
4 constructor(config?: Record<string, unknown>) {
5 super('my_weather', config);
6 }
7
8 getManifest(): SkillManifest {
9 return { name: 'my_weather', description: 'Look up weather', version: '1.0.0' };
10 }
11
12 getTools(): SkillToolDefinition[] {
13 return [{
14 name: 'get_weather',
15 description: 'Get current weather for a city',
16 parameters: { city: { type: 'string', description: 'City name' } },
17 handler: async (args) => ({ response: 'Sunny, 72F' }),
18 }];
19 }
20}

Using a skill

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'weather-agent' });
4agent.setPromptText("You are a helpful assistant.")
5agent.addSkill("weather")
6
7// Or with custom configuration
8agent.addSkill("weather", { units: "celsius" })
9
10// Entry point
11agent.run()