# Practical and Useful Patterns with ADK
## ๐ Load Knowledge On-Demand with ADK Skills
Stuffing all knowledge into your agent's instructions blows up token costs. ADK **Skills** let you load workflows and knowledge on-demand โ only when relevant โ saving tokens while extending capabilities! ๐
## ๐ Title
Skills for Agents
## ๐ URL
## ๐งฉ Overview
A Skill is a self-contained unit of functionality that an ADK agent can use to perform a specific task. It packages instructions, references, assets, and scripts, loading them only when the agent needs them.
Skills follow a 3-level architecture:
- **L1 (Metadata)**: `SKILL.md` frontmatter enables skill discovery
- **L2 (Instructions)**: Main instructions in the `SKILL.md` body
- **L3 (Resources)**: Supporting materials in `references/`, `assets/`, `scripts/`
By loading only when needed, Skills optimize context window usage and minimize token consumption.
## ๐ How to Use
**Directory structure:**
```
my_agent/
skills/
code_review/
SKILL.md # Required: metadata + instructions
references/
CHECKLIST.md # Detailed review checklist
assets/
template.json # Review output template
scripts/
# Lint execution script
```
**Python integration:**
Import `load_skill_from_dir` from `google.adk.skills` and `skill_toolset` from ` along with `pathlib`. Call `load_skill_from_dir()` with the path `pathlib.Path(__file__).parent / "skills" / "code_review"` to load the skill from its directory. Then create a `skill_toolset.SkillToolset(skills=[code_review_skill])` and pass it to the `Agent` constructor via the `tools` parameter. The agent is created with `model="gemini-flash-latest"` and `name="dev_assistant"`, gaining on-demand access to the skill through the toolset.
## ๐ Practical Usage
**Skills for a DevOps agent:**
```
skills/
code_review/
SKILL.md # "Code Review Checklist"
references/
CHECKLIST.md # Detailed review criteria
release/
SKILL.md # "Release Procedure"
references/
PROCEDURE.md # Step-by-step release flow
assets/
changelog.tmpl # CHANGELOG template
incident/
SKILL.md # "Incident Response"
references/
RUNBOOK.md # Incident response runbook
scripts/
# Slack notification script
```
The agent loads `code_review` only when asked to review code, and `release` only when asked to deploy. No need to keep all skills loaded at all times, dramatically reducing token consumption.
**Inline skills (TypeScript):**
```typescript
const releaseSkill: Skill = {
frontmatter: {
name: 'release-procedure',
description: 'Standard release procedure with checklist',
},
instructions: "Follow the release checklist step by step...",
resources: {
references: {
'checklist.md': '1. Run tests\n2. Update version\n3. Create tag...',
},
},
};
const skillTools = new SkillToolset([releaseSkill]);
```
## ๐ก Use Cases
- ๐ **Code review checklists**: Load detailed review criteria only when reviews are requested
- ๐ **Release procedures**: Load step-by-step deployment guides and templates only at release time
- ๐ง **Troubleshooting**: Load runbooks and notification scripts only during incidents
- ๐ **Document authoring**: Load type-specific templates and guidelines per document type
- ๐ **Employee onboarding**: Load relevant knowledge base sections based on questions
## โ ๏ธ Caveats
- Skills are experimental (Python v1.25.0+, TypeScript v0.6.1+, Go v1.2.0+)
- `SKILL.md` is required; include `name` and `description` in frontmatter
- Skill discovery accuracy depends on description quality โ write clear descriptions
- Large resource files impact token consumption; keep them minimal
- Be mindful of script execution permissions and security
## โจ Closing
Skills implement "load knowledge only when needed" in an elegant way. Instead of cramming everything into instructions, modularize capabilities as Skills to keep token costs low while extending your agent's abilities infinitely. DevOps, customer support, education โ the pattern applies everywhere!
#
ADK# #
AIAgent#