# `Jido.AI.Skill.Loader`
[🔗](https://github.com/agentjido/jido_ai/blob/v2.4.0/lib/jido_ai/skill/loader.ex#L1)

Parses SKILL.md files into `Jido.AI.Skill.Spec` structs.

Supports the agentskills.io format with YAML frontmatter.

## Lenient Parsing Mode

When `lenient: true` is passed to load functions:
- Non-fatal warnings are collected instead of causing failures
- Parent directory name mismatches generate warnings
- Cosmetic naming violations are noted
- Returns both the spec and diagnostics

## Diagnostics

All parse operations can track diagnostics via the `:diagnostics`
option or by using `load_with_diagnostics/2`:

    {:ok, spec, diagnostics} = Loader.load_with_diagnostics(path)

# `load`

```elixir
@spec load(String.t(), keyword()) :: {:ok, Jido.AI.Skill.Spec.t()} | {:error, term()}
```

Loads a skill from a SKILL.md file path.

Returns `{:ok, spec}` or `{:error, reason}`.

## Options

- `:lenient` - When true, non-fatal issues become warnings instead of errors (default: false)
- `:diagnostics` - Pass an existing Diagnostics struct to accumulate warnings

# `load!`

```elixir
@spec load!(String.t(), keyword()) :: Jido.AI.Skill.Spec.t()
```

Loads a skill from a SKILL.md file path, raising on error.

# `load_with_diagnostics`

```elixir
@spec load_with_diagnostics(String.t(), keyword()) ::
  {:ok, Jido.AI.Skill.Spec.t(), Jido.AI.Skill.Diagnostics.t()}
  | {:error, term(), Jido.AI.Skill.Diagnostics.t()}
```

Loads a skill with full diagnostics tracking.

Returns `{:ok, spec, diagnostics}` or `{:error, reason, diagnostics}`.
Always returns diagnostics even on failure, allowing inspection of warnings.

## Examples

    {:ok, spec, diagnostics} = Loader.load_with_diagnostics(path)
    Enum.each(diagnostics.warnings, &IO.puts/1)

# `parse`

```elixir
@spec parse(String.t(), String.t(), keyword()) ::
  {:ok, Jido.AI.Skill.Spec.t()} | {:error, term()}
```

Parses SKILL.md content string into a spec.

## Options

- `:lenient` - When true, non-fatal issues become warnings instead of errors
- `:diagnostics` - Pass an existing Diagnostics struct to accumulate warnings

---

*Consult [api-reference.md](api-reference.md) for complete listing*
