Agent Skills
Learn how to extend your AI agent with Agent Skills, a lightweight format for adding specialized knowledge and workflows from markdown files.What are Agent Skills?
Agent Skills are folders containing instructions and resources that agents can load on-demand:How Skills Work
Skills use progressive disclosure to manage context efficiently:- Discovery: Agent loads only name and description at startup
- Activation: When relevant, agent reads full
SKILL.mdinstructions - Execution: Agent follows instructions, accessing bundled resources as needed
The SKILL.md File
Every skill contains aSKILL.md file with frontmatter and instructions:
name: Short identifierdescription: When to use this skill
Prerequisites
Your agent needs:- Filesystem access: Read files and directories
- Load skill tool: Read
SKILL.mdcontent - Command execution: Optional, for skills with scripts
Implementation
Step 1: Define Sandbox Interface
Create a generic interface for filesystem operations:Step 2: Discover Skills
Scan directories and extract metadata:Step 3: Build System Prompt
Include skill descriptions in system prompt:Step 4: Create Load Skill Tool
Implement the tool to load skill content:Step 5: Create Additional Tools
Provide tools for accessing skill resources:Step 6: Wire Up the Agent
Combine everything usingprepareCall:
Step 7: Run the Agent
Example Skill
Here’s a complete example skill:Extract data from a single page
Handle pagination
Use the pagination template:Using Skills in Next.js
Integrate with a Next.js API route:Best Practices
Skill Design
- Clear descriptions: Help the agent know when to use the skill
- Explicit instructions: Provide step-by-step guidance
- Examples: Include example commands and outputs
- Error handling: Document common errors and solutions
Security
- Validate inputs: Sanitize all user inputs in skill scripts
- Restrict commands: Limit what bash commands can execute
- Sandbox environment: Run skills in isolated containers
- Audit trails: Log all skill executions
Organization
Example Use Cases
- Code Generation: Templates and linters for different languages
- Data Processing: ETL workflows and data validation
- API Integration: Pre-configured API clients and auth flows
- Testing: Test generation and execution frameworks
- Documentation: Doc generators and formatters
Skill Discovery
Browse community skills at skills.shNext Steps
- Read the Agent Skills specification
- Check out example skills
- Learn authoring best practices
- Use the reference library for validation