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 Agent
2from kern.models.openai import OpenAIResponses
3from kern.skills import Skills, LocalSkills
4
5# Load skills from a directory
6agent = 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.md
4 git-workflow/
5 SKILL.md
6 testing/
7 SKILL.md
1from kern.skills import Skills, LocalSkills
2
3# Load all skills from the directory
4skills = Skills(loaders=[LocalSkills("/path/to/skills")])

Loading a Single Skill

If you want to load just one skill:

1from kern.skills import Skills, LocalSkills
2
3# Load a single skill directory
4skills = 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, LocalSkills
2
3skills = Skills(loaders=[
4 LocalSkills("/path/to/shared-skills"),
5 LocalSkills("/path/to/project-skills"),
6])
Note

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:

ToolDescription
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 Agent
2from kern.models.openai import OpenAIResponses
3from kern.skills import Skills, LocalSkills
4
5agent = 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)
13
14# The agent will automatically use skills when relevant
15agent.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, LocalSkills
2
3skills = Skills(loaders=[LocalSkills("/path/to/skills")])
4
5# ... skills are modified on disk ...
6
7# Reload to pick up changes
8skills.reload()

Error Handling

Skills are validated when loaded. If validation fails, a SkillValidationError is raised:

1from kern.skills import Skills, LocalSkills, SkillValidationError
2
3try:
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 Path
2from kern.agent import Agent
3from kern.models.openai import OpenAIResponses
4from kern.skills import Skills, LocalSkills
5
6# Get skills directory relative to this file
7skills_dir = Path(__file__).parent / "skills"
8
9# Create agent with skills
10agent = 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)
19
20if __name__ == "__main__":
21 agent.print_response(
22 "Review this Python function:\n\n"
23 "def calc(x,y): return x+y"
24 )