Custom Skills
Custom Skills
Create your own skills by inheriting from SkillBase. Custom skills can be reused across agents and shared with others.
Creating custom skills is worthwhile when you have functionality you want to reuse across multiple agents or share with your team. A skill packages a capability—functions, prompts, hints, and configuration—into a single reusable unit.
When to Create a Custom Skill
Create a skill when:
- You’ll use the same functionality in multiple agents
- You want to share a capability with your team
- The functionality is complex enough to benefit from encapsulation
- You want version-controlled, tested components
Just use define_tool() when:
- The function is specific to one agent
- You need quick iteration during development
- The logic is simple and unlikely to be reused
Skill Structure
Create a directory with these files:
What each file does:
Basic Custom Skill
Required Class Attributes
Optional Attributes:
Required Methods
setup()
Initialize the skill and validate requirements:
register_tools()
Register SWAIG functions:
Optional Methods
get_hints()
Provide speech recognition hints:
get_prompt_sections()
Add sections to the agent’s prompt:
get_global_data()
Provide data for the agent’s global context:
cleanup()
Release resources when skill is unloaded:
Parameter Schema
Define parameters your skill accepts:
Multi-Instance Skills
Support multiple instances with different configurations:
Complete Example
Using Custom Skills
Register the skill directory:
How Skill Registration Works
When you call skill_registry.add_skill_directory():
- The registry scans the directory for valid skill packages
- Each subdirectory with a
skill.pyis considered a potential skill - Skills are validated but not loaded yet (lazy loading)
- When
add_skill()is called, the skill class is instantiated
Registration order matters: If multiple directories contain skills with the same name, the first registered takes precedence.
Testing Custom Skills
Test your skill before using it in production:
1. Test the skill class directly:
2. Test with a real agent using swaig-test:
3. Validate skill structure:
Publishing and Sharing Skills
Option 1: Git Repository
Share your skills via Git:
Users clone and register:
Option 2: Python Package
Package skills for pip installation using entry points:
After pip install, skills are automatically discoverable.
Option 3: Environment Variable
Set SIGNALWIRE_SKILL_PATHS to include your skills directory:
Skill Development Best Practices
DO:
- Use descriptive SKILL_NAME and SKILL_DESCRIPTION
- Validate all parameters in setup()
- Return user-friendly error messages
- Log technical errors for debugging
- Include speech hints for better recognition
- Write clear prompt sections explaining usage
- Handle network/API failures gracefully
- Version your skills meaningfully
DON’T:
- Hard-code configuration values
- Expose internal errors to users
- Skip parameter validation
- Forget to handle edge cases
- Make setup() do heavy work (defer to first use)
- Use global state between instances