Jido.AI.Skill behaviour (Jido AI v2.2.0)

Copy Markdown View Source

Unified skill abstraction for Jido agents.

Skills can be defined two ways:

  1. Compile-time modules using use Jido.AI.Skill
  2. Runtime-loaded SKILL.md files following the agentskills.io format

Both present the same API to agents and strategies.

Module-based Skills

defmodule MyApp.Skills.WeatherAdvisor do
  use Jido.AI.Skill,
    name: "weather-advisor",
    description: "Provides weather-aware travel and activity advice.",
    license: "MIT",
    allowed_tools: ~w(weather_geocode weather_forecast),
    actions: [MyApp.Actions.Weather.Forecast],
    body: """
    # Weather Advisor

    ## Workflow
    1. Determine location
    2. Fetch weather data
    3. Provide contextual advice
    """
end

Runtime Skills

Load SKILL.md files at runtime:

{:ok, spec} = Jido.AI.Skill.Loader.load("priv/skills/code-review/SKILL.md")
Jido.AI.Skill.Registry.register(spec)

Unified API

Both types support the same interface:

Jido.AI.Skill.manifest(skill)      # Returns the Spec struct
Jido.AI.Skill.body(skill)          # Returns the skill body text
Jido.AI.Skill.allowed_tools(skill) # Returns list of allowed tool names
Jido.AI.Skill.actions(skill)       # Returns list of action modules

Summary

Functions

Returns the actions for a skill.

Returns the allowed tools for a skill.

Returns the body text for a skill.

Returns the manifest (Spec) for a skill.

Returns the plugins for a skill.

Resolves a skill reference to a Spec.

Callbacks

actions()

@callback actions() :: [module()]

allowed_tools()

@callback allowed_tools() :: [String.t()]

body()

@callback body() :: String.t()

manifest()

@callback manifest() :: Jido.AI.Skill.Spec.t()

plugins()

@callback plugins() :: [module()]

Functions

actions(mod)

@spec actions(module() | Jido.AI.Skill.Spec.t() | String.t()) :: [module()]

Returns the actions for a skill.

allowed_tools(mod)

@spec allowed_tools(module() | Jido.AI.Skill.Spec.t() | String.t()) :: [String.t()]

Returns the allowed tools for a skill.

body(mod)

@spec body(module() | Jido.AI.Skill.Spec.t() | String.t()) :: String.t()

Returns the body text for a skill.

manifest(mod)

@spec manifest(module() | Jido.AI.Skill.Spec.t() | String.t()) ::
  Jido.AI.Skill.Spec.t()

Returns the manifest (Spec) for a skill.

Works with both module references and Spec structs.

plugins(mod)

@spec plugins(module() | Jido.AI.Skill.Spec.t() | String.t()) :: [module()]

Returns the plugins for a skill.

resolve(mod)

@spec resolve(module() | Jido.AI.Skill.Spec.t() | String.t()) ::
  {:ok, Jido.AI.Skill.Spec.t()} | {:error, term()}

Resolves a skill reference to a Spec.

Accepts:

  • Module atoms (compile-time skills)
  • Spec structs (already resolved)
  • String names (runtime registry lookup)