Lab 39.5: Loading and Using Agent Skills
Goalโ
In this lab, you will create a simple ADK Skill on your file system and configure an agent to use it via the SkillToolset.
Step 1: Create the Projectโ
-
Create a new agent project:
Environment setup:
- Local machine: If you're continuing the course in sequence,
cdinto theadk-trainingproject you created in Module 2 and skip the block below -- your environment and dependencies already carry forward. If you're starting fresh at this module, create that project first:uv init adk-training --python 3.10 && cd adk-training
uv add "google-adk>=2.1.0" python-dotenv - DevContainer / Codespaces (Alternative): If you opened this repository in a DevContainer or GitHub Codespaces, Python,
uv, and the core ADK dependencies are already pre-installed in your container environment.
uv run adk create skills_agentThis prompts for a model choice (any option is fine, you'll set the real model in
agent.pybelow) and, if needed, a backend -- there's no separate "type" prompt,agent.py/Code is already the default. - Local machine: If you're continuing the course in sequence,
-
Navigate to the directory:
cd skills_agent
Step 2: Create the Skill Directoryโ
We need to create the physical structure for our skill.
- Inside
skills_agent, create a directory calledskills:mkdir skills - Inside
skills, create a directory for our specific skill:mkdir skills/greeting-skill - Inside
skills/greeting-skill, create the requiredSKILL.mdfile:touch skills/greeting-skill/SKILL.md
Step 3: Write the Skill Instructionsโ
Open skills/greeting-skill/SKILL.md in your editor and paste the following content. This defines the metadata (how the agent knows when to use it) and the body (the actual instructions).
---
name: greeting-skill
description: The official Nebula-9 Collective greeting protocol. Use this skill any time the user greets you, says hello, or asks to be greeted.
---
# Nebula-9 Collective Greeting Protocol
You are now using the official Nebula-9 Collective Greeting Skill!
Step 1: Read the user's input to see if they provided a name.
Step 2: Respond using EXACTLY this template, replacing [NAME] with their name (or "traveler" if you don't know it):
"๐ Greetings, [NAME]! Welcome aboard the Nebula-9 Collective. May your orbit be ever bright. ๐โจ"
Step 3: Do not deviate from this template under any circumstances -- no extra commentary before or after it.
This gives the skill a distinctive, made-up phrase ("Nebula-9 Collective") that a model could never produce on its own -- so if you see it in the final response, that's proof the skill actually loaded and was followed, not just the model being generically friendly.
Step 4: Configure the Agentโ
Exercise: Open your main agent.py file. Your task is to load the skill from the directory and provide it to the agent.
import pathlib
from google.adk.agents import Agent
from google.adk.skills import load_skill_from_dir
from google.adk.tools.skill_toolset import SkillToolset
from google.adk.code_executors.unsafe_local_code_executor import UnsafeLocalCodeExecutor
# TODO: 1. Load the skill from the directory you created.
# Hint: Use pathlib.Path(__file__).parent / "skills" / "greeting-skill"
greeting_skill = None
# TODO: 2. Create the SkillToolset.
# Pass your loaded skill in a list to the `skills` parameter.
# We must include the code_executor even if we don't have scripts yet.
my_skill_toolset = None
# TODO: 3. Configure the Agent.
# Add your `my_skill_toolset` to the agent's `tools` list.
# Also add an `instruction` that names the skill explicitly and tells the
# agent it MUST call `load_skill('greeting-skill')` whenever the user
# greets it. A generic "check your skills if relevant" instruction is too
# weak in practice -- the model won't reliably invoke a skill for a message
# as simple as "hi" unless the skill and the trigger condition are named
# directly.
root_agent = Agent(
model="gemini-3.5-flash",
name="skill_user_agent",
description="An agent that can use specialized skills.",
# Add instruction and tools here
)
(Note: The full implementation is available in the lab-solution.md if you need a hint.)
Step 5: Test the Skillโ
- Set up your
.envfile. - Navigate to the parent directory (
cd ..) and start the Dev UI:uv run adk web skills_agent - Interact with the system:
- Say "Hello there, my name is Alex."
- You should receive the exact Nebula-9 Collective greeting template, including the made-up "Nebula-9 Collective" phrase -- proof the agent loaded and followed the
SKILL.mdinstructions, not just a generic friendly reply.
- Examine the Trace View:
- Look at the trace. You should see the agent making a "tool call" to activate the
greeting-skillskill. This is progressive disclosure in action!
- Look at the trace. You should see the agent making a "tool call" to activate the
Self-Reflection Questionsโ
- Look at your
SKILL.mdfile. Which part of it is loaded into the agent's context before the user says hello? Which part is loaded after? - Why do we have to wrap the skill in a
SkillToolsetbefore giving it to the agent? (Think about the other things a toolset might manage, like code executors or additional tools). - Your
instructionnamesgreeting-skilland its trigger condition explicitly. What do you think would happen if you had 20 skills instead of 1 -- would naming every single one in the instruction still scale, and what does that suggest about thesearch_skills/Skill Registry pattern mentioned in "Going Further"?
๐ Reference Solution Vaultโ
Module 39_5 Reference Solution Vault
Active Comprehension Gate โข Zero Guessable URLs โข Guided Verification