Back to Eliza

@elizaos/skills

packages/skills/README.md

1.7.23.2 KB
Original Source

@elizaos/skills

Bundled skills and skill loading utilities for elizaOS agents.

Overview

Skills are markdown files that provide specialized instructions for AI agents to perform specific tasks. Each skill contains:

  • Frontmatter: YAML metadata including name, description, and configuration
  • Body: Detailed instructions, examples, and references

Installation

bash
npm install @elizaos/skills
# or
pnpm add @elizaos/skills

Usage

Get Bundled Skills Path

typescript
import { getSkillsDir } from "@elizaos/skills";

const skillsPath = getSkillsDir();
// Returns absolute path to bundled skills directory

Load Skills

typescript
import { loadSkills, loadSkillsFromDir } from "@elizaos/skills";

// Load from all default locations (bundled + managed + project)
const { skills, diagnostics } = loadSkills();

// Load from a specific directory
const result = loadSkillsFromDir({
  dir: "/path/to/skills",
  source: "custom",
});

Format for LLM Prompt

typescript
import { formatSkillsForPrompt } from "@elizaos/skills";

const prompt = formatSkillsForPrompt(skills);
// Returns XML-formatted skills section for system prompt

Build Command Specs

typescript
import { loadSkillEntries, buildSkillCommandSpecs } from "@elizaos/skills";

const entries = loadSkillEntries();
const commands = buildSkillCommandSpecs(entries);
// Returns array of command specs for chat interfaces

Skill Discovery

Skills are loaded from multiple locations in precedence order (later overrides earlier):

  1. Bundled skills - Included in this package (skills/)
  2. Managed skills - User-installed skills (~/.elizaos/skills/)
  3. Project skills - Project-local skills (<cwd>/.elizaos/skills/)
  4. Explicit paths - Via skillPaths option

Skill Format

Skills are markdown files with YAML frontmatter:

markdown
---
name: my-skill
description: A brief description of what this skill does
primary-env: node
required-bins:
  - node
  - npm
---

# My Skill

Detailed instructions for the AI agent...

Frontmatter Fields

FieldTypeDescription
namestringSkill name (should match directory name)
descriptionstringHuman-readable description (required)
disable-model-invocationbooleanIf true, skill won't appear in prompts
user-invocablebooleanIf false, can't be invoked via commands
primary-envstringPrimary runtime (node, python, etc.)
required-osstring[]Required operating systems
required-binsstring[]Required binaries in PATH
required-envstring[]Required environment variables

API Reference

Types

  • Skill - Loaded skill with metadata
  • SkillFrontmatter - Parsed frontmatter
  • SkillEntry - Full skill entry with all metadata
  • LoadSkillsResult - Result from loading skills

Functions

  • getSkillsDir() - Get bundled skills path
  • loadSkills(options?) - Load from all locations
  • loadSkillsFromDir(options) - Load from single directory
  • loadSkillEntries(options?) - Load with full metadata
  • formatSkillsForPrompt(skills) - Format for LLM prompt
  • buildSkillCommandSpecs(entries) - Build command specs

License

MIT