Skip to main content

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:
  1. Discovery: Agent loads only name and description at startup
  2. Activation: When relevant, agent reads full SKILL.md instructions
  3. Execution: Agent follows instructions, accessing bundled resources as needed

The SKILL.md File

Every skill contains a SKILL.md file with frontmatter and instructions:
Frontmatter requires:
  • name: Short identifier
  • description: When to use this skill

Prerequisites

Your agent needs:
  1. Filesystem access: Read files and directories
  2. Load skill tool: Read SKILL.md content
  3. 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 using prepareCall:

Step 7: Run the Agent

Example Skill

Here’s a complete example skill:

Extract data from a single page

Example:

Handle pagination

Use the pagination template:
Modify the config and run:

Using Skills in Next.js

Integrate with a Next.js API route:

Best Practices

Skill Design

  1. Clear descriptions: Help the agent know when to use the skill
  2. Explicit instructions: Provide step-by-step guidance
  3. Examples: Include example commands and outputs
  4. Error handling: Document common errors and solutions

Security

  1. Validate inputs: Sanitize all user inputs in skill scripts
  2. Restrict commands: Limit what bash commands can execute
  3. Sandbox environment: Run skills in isolated containers
  4. Audit trails: Log all skill executions

Organization

Example Use Cases

  1. Code Generation: Templates and linters for different languages
  2. Data Processing: ETL workflows and data validation
  3. API Integration: Pre-configured API clients and auth flows
  4. Testing: Test generation and execution frameworks
  5. Documentation: Doc generators and formatters

Skill Discovery

Browse community skills at skills.sh

Next Steps

Resources