SKILL.md files.
What are Agent Skills?
Agent Skills are:- Markdown-based: Written in simple Markdown format with YAML frontmatter
- Modular: Each skill is a self-contained capability
- Reusable: Skills can be shared across agents and projects
- Context-aware: Automatically loaded based on task similarity
- Code-free: No code changes needed to add new capabilities
Skills Directory Structure
SKILL.md Format
Basic Structure
EachSKILL.md file has two parts:
- YAML Frontmatter: Metadata about the skill
- Markdown Content: Instructions and methodology
Example: Financial Analysis Skill
Using Agent Skills
Dynamic Loading (Task-Based, Automatic)
Settingskills_dir on an agent enables dynamic, task-based skill loading automatically. Every call to agent.run(task) selects the skills whose description is similar enough to the current task: cosine similarity over word counts of the task and the description, with a threshold of 0.3 (a skill is selected when its score is at least the threshold). The selected skills are sent with every LLM call of that run as an extra system message, placed after the agent’s system prompt. agent.system_prompt itself is never changed. A run that selects no skills sends none.
agent.skills_metadata lists the skills the last matching run selected.
Loading Every Skill on Every Run
run() always selects skills by similarity. To send every skill regardless of the task, set the threshold to 0 before the first run:
Calling
agent.handle_skills() with no task selects every skill, but the next run() selects again by similarity and replaces that selection. The skills loader is built on the first run and reused; assign agent.skills_dir again to pick up skill files added later.Skills from Several Directories
skills_dir also takes a list. Directories are read in order. When two directories hold a skill with the same name, the skill from the later directory is used and a warning names both paths.
Creating Custom Skills
Step 1: Create Directory
Step 2: Write SKILL.md
Step 3: Use the Skill
Skill Examples
Data Visualization Skill
Dynamic Skills Loader
Best Practices
1. Keep Skills Focused
2. Include Examples
Always provide concrete examples in your skills:3. Use Clear Instructions
4. Provide Guidelines
Sharing Skills
Skills can be easily shared across projects and teams:Next Steps
Structured Outputs
Get structured responses from agents
Creating Agents
Learn how to create agents
Reference
- Skills handling:
swarms/structs/agent.py(handle_skillsstores the selected section;call_llmsends it with every request) plusswarms/agents/skills_manager.py(SkillsManager._static_prompt,SkillsManager._dynamic_prompt) for the tiered static/dynamic loading logic. See the SkillsManager reference - Dynamic skills loader and multi-directory loading:
swarms/structs/dynamic_skills_loader.py - Example skills:
examples/single_agent/capabilities/skills/, includingmultiple_skill_dirs/ - Anthropic Agent Skills: Agent Skills announcement