# `CommBus.Template.Loader`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

Prompt template loader with YAML frontmatter.

# `load_prompt_file`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec load_prompt_file(
  String.t(),
  keyword()
) ::
  {:ok, CommBus.Template.Prompt.t()}
  | {:error, [CommBus.Template.ValidationError.t()]}
```

Reads a prompt file from disk, parses its YAML frontmatter, validates the
schema, and returns a `%Prompt{}` struct.

## Parameters

  - `path` — Absolute or relative file path to a Markdown prompt file.
  - `opts` — Keyword options: `:schema` (`:devman`, `:human`, `:flex`),
    `:root` (prompt root directory for slug derivation).

## Returns

`{:ok, %Prompt{}}` on success or `{:error, [%ValidationError{}]}` on failure.

# `load_prompt_string`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec load_prompt_string(String.t(), String.t() | nil, keyword()) ::
  {:ok, CommBus.Template.Prompt.t()}
  | {:error, [CommBus.Template.ValidationError.t()]}
```

Parses a prompt from a raw string containing YAML frontmatter delimited by
`---`, validates the schema, and returns a `%Prompt{}` struct.

## Parameters

  - `content` — The full prompt string including YAML frontmatter.
  - `path` — Optional file path for error reporting and slug derivation.
  - `opts` — Keyword options: `:schema`, `:root`.

## Returns

`{:ok, %Prompt{}}` on success or `{:error, [%ValidationError{}]}` on failure.

# `load_prompts`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec load_prompts(
  String.t(),
  keyword()
) ::
  {:ok, [CommBus.Template.Prompt.t()]}
  | {:error, [CommBus.Template.ValidationError.t()]}
```

Recursively loads all `.md` prompt files under the given directory, returning
a list of validated `%Prompt{}` structs.

## Parameters

  - `root` — The root directory to scan for prompt files.
  - `opts` — Keyword options: `:schema`, `:root`.

## Returns

`{:ok, [%Prompt{}]}` if all files pass validation, or
`{:error, [%ValidationError{}]}` collecting errors from all invalid files.

# `parse_frontmatter`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec parse_frontmatter(String.t(), String.t() | nil) ::
  {:ok, map(), String.t()} | {:error, [CommBus.Template.ValidationError.t()]}
```

Splits a prompt string on `---` delimiters and parses the YAML frontmatter
into a map.

## Parameters

  - `content` — The full prompt string.
  - `path` — Optional file path for error reporting.

## Returns

`{:ok, frontmatter_map, body_string}` on success or
`{:error, [%ValidationError{}]}` on failure.

---

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