openhands/sdk/context/skills/
Core Responsibilities
The Skill system has four primary responsibilities:- Context Injection - Add specialized prompts to agent context based on triggers
- Trigger Evaluation - Determine when skills should activate (always, keyword, task)
- MCP Integration - Load MCP tools associated with repository skills
- Third-Party Support - Parse
.cursorrules,agents.md, and other skill formats
Architecture
Key Components
| Component | Purpose | Design |
|---|---|---|
Skill | Core skill model | Pydantic model with name, content, trigger |
KeywordTrigger | Keyword-based activation | String matching on user messages |
TaskTrigger | Task-based activation | Special type of KeywordTrigger for skills with user inputs |
InputMetadata | Task input parameters | Defines user inputs for task skills |
| Skill Loader | File parsing | Reads markdown with frontmatter, validates schema |
Skill Types
Repository Skills
Always-active skills that provide repository-specific guidelines: Characteristics:- Trigger:
None(always active) - Purpose: Project conventions, coding standards, architecture rules
- MCP Tools: Can include MCP tool configuration
- Location:
.openhands/skills/*.mdor third-party formats
.cursorrules- Cursor IDE guidelinesagents.md/agent.md- General agent instructions- Custom repo skills with frontmatter
Knowledge Skills
Keyword-triggered skills for specialized domains: Characteristics:- Trigger:
KeywordTriggerwith regex patterns - Purpose: Domain-specific knowledge (e.g., βkubernetesβ, βmachine learningβ)
- Activation: Keywords detected in user messages
- Location: System or user-defined knowledge base
Task Skills
Keyword-triggered skills with structured inputs for guided workflows: Characteristics:- Trigger:
TaskTrigger(a special type of KeywordTrigger for skills with user inputs) - Activation: Keywords/triggers detected in user messages (same matching logic as KeywordTrigger)
- Purpose: Guided workflows (e.g., bug fixing, feature implementation)
- Inputs: User-provided parameters (e.g., bug description, acceptance criteria)
- Location: System-defined or custom task templates
Trigger Evaluation
Skills are evaluated at different points in the agent lifecycle: Evaluation Rules:| Trigger Type | Evaluation Point | Activation Condition |
|---|---|---|
| None | Every step | Always active |
| KeywordTrigger | On user message | Keyword/string match in message |
| TaskTrigger | On user message | Keyword/string match in message (same as KeywordTrigger) |
MCP Tool Integration
Repository skills can include MCP tool configurations: MCP Configuration Format: Skills can embed MCP server configuration following the FastMCP format:- Load Skill: Parse markdown file with frontmatter
- Extract MCP Config: Read
mcp_toolsfield - Spawn MCP Servers: Create MCP clients for each server
- Register Tools: Add MCP tools to agentβs tool registry
- Inject Context: Add skill content to agent prompt
Skill File Format
Skills are defined in markdown files with YAML frontmatter:| Field | Required | Description |
|---|---|---|
| name | Yes | Unique skill identifier |
| trigger | Yes* | Activation trigger (null for always active) |
| mcp_tools | No | MCP server configuration (repo skills only) |
| inputs | No | User input metadata (task skills only) |
trigger: null (or omit trigger field)
Component Relationships
How Skills Integrate
Relationship Characteristics:- Skills β Agent Context: Active skills contribute their content to system prompt
- Skills β MCP: Repository skills can spawn MCP servers and register tools
- Context β Agent: Combined skill content becomes part of agentβs instructions
- Skills Lifecycle: Loaded at conversation start, evaluated each step
See Also
- Agent Architecture - How agents use skills for context
- Tool System - MCP tool spawning and client management
- Context Management Guide - Using skills in applications

