Loading Skills
Load skills into agents using LocalSkills and the Skills orchestrator.
Skills are loaded using the Skills class with one or more SkillLoader instances set as loaders.
Currently, LocalSkills is available for loading skills from the filesystem.
Basic Usage
1from kern.agent import Agent2from kern.models.openai import OpenAIResponses3from kern.skills import Skills, LocalSkills45# Load skills from a directory6agent = Agent(7 model=OpenAIResponses(id="gpt-5.2"),8 skills=Skills(loaders=[LocalSkills("/path/to/skills")])9)LocalSkills Loader
The LocalSkills loader reads skills from the local filesystem.
Loading from a Directory of Skills
If you have multiple skills in subdirectories:
1skills/2├── code-review/3│ └── SKILL.md4├── git-workflow/5│ └── SKILL.md6└── testing/7 └── SKILL.md1from kern.skills import Skills, LocalSkills23# Load all skills from the directory4skills = Skills(loaders=[LocalSkills("/path/to/skills")])Loading a Single Skill
If you want to load just one skill:
1from kern.skills import Skills, LocalSkills23# Load a single skill directory4skills = Skills(loaders=[LocalSkills("/path/to/skills/code-review")])Multiple Loaders
You can combine multiple loaders to load skills from different locations:
1from kern.skills import Skills, LocalSkills23skills = Skills(loaders=[4 LocalSkills("/path/to/shared-skills"),5 LocalSkills("/path/to/project-skills"),6])If skills from different loaders have the same name, the later loader's skill will overwrite the earlier one.
Agent Tools
When you add skills to an agent, it automatically gets access to these tools:
| Tool | Description |
|---|---|
get_skill_instructions(skill_name) | Load full instructions for a skill |
get_skill_reference(skill_name, reference_path) | Load a reference document |
get_skill_script(skill_name, script_path, execute, args, timeout) | Read or execute a script |
Example: Using Skill Tools
1from kern.agent import Agent2from kern.models.openai import OpenAIResponses3from kern.skills import Skills, LocalSkills45agent = Agent(6 model=OpenAIResponses(id="gpt-5.2"),7 skills=Skills(loaders=[LocalSkills("/path/to/skills")]),8 instructions=[9 "You have access to specialized skills.",10 "Use get_skill_instructions to load full guidance when needed.",11 ],12)1314# The agent will automatically use skills when relevant15agent.print_response("Review this code for best practices: def foo(): pass")System Prompt Integration
Skills metadata is automatically added to the agent's system prompt. The agent sees:
- Skill names and descriptions
- Available scripts and references
- Instructions on how to load full skill details
This allows the agent to discover and use skills without loading everything upfront.
Reloading Skills
If your skills change at runtime, you can reload them:
1from kern.skills import Skills, LocalSkills23skills = Skills(loaders=[LocalSkills("/path/to/skills")])45# ... skills are modified on disk ...67# Reload to pick up changes8skills.reload()Error Handling
Skills are validated when loaded. If validation fails, a SkillValidationError is raised:
1from kern.skills import Skills, LocalSkills, SkillValidationError23try:4 skills = Skills(loaders=[LocalSkills("/path/to/skills")])5except SkillValidationError as e:6 print(f"Skill validation failed: {e}")7 print(f"Errors: {e.errors}")Complete Example
1from pathlib import Path2from kern.agent import Agent3from kern.models.openai import OpenAIResponses4from kern.skills import Skills, LocalSkills56# Get skills directory relative to this file7skills_dir = Path(__file__).parent / "skills"89# Create agent with skills10agent = Agent(11 name="Code Assistant",12 model=OpenAIResponses(id="gpt-5.2"),13 skills=Skills(loaders=[LocalSkills(str(skills_dir))]),14 instructions=[15 "You are a helpful coding assistant with access to specialized skills."16 ],17 markdown=True,18)1920if __name__ == "__main__":21 agent.print_response(22 "Review this Python function:\n\n"23 "def calc(x,y): return x+y"24 )