Basic Skills

Basic Skills Example.

1"""
2Basic Skills
3=============================
4
5Basic Skills Example.
6"""
7
8from pathlib import Path
9
10from kern.agent import Agent
11from kern.models.openai import OpenAIResponses
12from kern.skills import LocalSkills, Skills
13
14# ---------------------------------------------------------------------------
15# Create Agent
16# ---------------------------------------------------------------------------
17# Get the skills directory relative to this file
18skills_dir = Path(__file__).parent / "sample_skills"
19
20# Create an agent with skills loaded from the directory
21agent = Agent(
22 name="Code Review Agent",
23 model=OpenAIResponses(id="gpt-5.2"),
24 skills=Skills(loaders=[LocalSkills(str(skills_dir))]),
25 instructions=[
26 "You are a helpful assistant with access to specialized skills.",
27 ],
28 markdown=True,
29)
30
31
32# ---------------------------------------------------------------------------
33# Run Agent
34# ---------------------------------------------------------------------------
35if __name__ == "__main__":
36 # Ask the agent to review some code
37 agent.print_response(
38 "Review this Python code and provide feedback:\n\n"
39 "```python\n"
40 "def calculate_total(items):\n"
41 " total = 0\n"
42 " for i in range(len(items)):\n"
43 " total = total + items[i]['price'] * items[i]['quantity']\n"
44 " return total\n"
45 "```"
46 )

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/16_skills
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python basic_skills.py