As an agent handles more procedures — writing release notes, triaging incidents, checking refund policies — stuffing every playbook into the system prompt wastes tokens and confuses the model. Skills solve this with progressive disclosure: the model sees only a compact catalog of names and short descriptions, and loads the full instructions on demand when a task calls for them.

What ExAgent simplifies:

  • Standard SKILL.md format: Compatible with the Agent Skills directory convention, so the exact same skill files can serve your ExAgent apps and your coding agents.
  • Tool gating built in: Unlock specialized tools only after the model loads the corresponding skill, keeping the prompt clean and focused.
  • Survives compaction and persistence: Loaded skills stay in conversation history, survive snapshots/continuations, and are automatically restored when ExAgent.Compaction summarizes older turns.

Write a skill

Create one subdirectory per skill containing a SKILL.md with YAML frontmatter (name and description) plus optional reference text files:

priv/skills/
  release-notes/
    SKILL.md
    references/style.md
  incident-report/
    SKILL.md
---
name: release-notes
description: Write release notes. Use when asked to summarise changes for a release.
---
# Release notes

1. Group user-visible changes first; read references/style.md for tone.
2. Highlight breaking changes and migration steps clearly.

Write the description for the model: say what the skill does and when to load it (up to 1,024 characters). Names support lowercase Unicode letters, digits and single hyphens (revisión, мой-навык, 技能, normalized to NFKC, up to 64 code points).

Attach skills to an agent

Load a directory of skills with ExAgent.Skills.from_dir!/1 and pass them to ExAgent.new/1:

skills = ExAgent.Skills.from_dir!(Application.app_dir(:my_app, "priv/skills"))

agent =
  ExAgent.new(
    model: model,
    instructions: "You are the release assistant.",
    skills: skills
  )

ExAgent adds a load_skill tool whose description lists the available catalog. When the model loads a skill, the instructions enter the conversation as a normal tool return — so they persist across ExAgent.Server turns, snapshots and continuations. Inspect loaded skills at any time with ExAgent.Skills.loaded/1 (for a live Server, call {:ok, messages} = ExAgent.Server.history(server) and pass messages).

Runtime Agent Skills vs. ExAgent coding-agent skills

This guide covers runtime skills loaded by your agents from directories like priv/skills/. For the 11 coding-agent skills bundled inside the ExAgent package itself (usage-rules/skills/, synced into your repo via mix usage_rules.sync), see Coding-agent manual.

SKILL.md is re-read on each load (edits apply immediately without restarting), and you can also define inline skills in Elixir:

ExAgent.Skill.new(
  name: "refund-policy",
  description: "Refund rules. Use when a customer asks for a refund.",
  content: "Refunds within 30 days are eligible if the item is unused..."
)

Import an external catalog

ExAgent.Skills.from_dir/1 fails fast if any skill in the directory is invalid. If you want to load a third-party catalog resiliently and skip malformed entries, iterate with ExAgent.Skill.from_dir/1:

require Logger

skills =
  for entry <- Enum.sort(File.ls!(root)),
      !String.starts_with?(entry, "."),
      dir = Path.join(root, entry),
      File.regular?(Path.join(dir, "SKILL.md")),
      reduce: [] do
    accepted ->
      case ExAgent.Skill.from_dir(dir) do
        {:ok, skill} ->
          [skill | accepted]

        {:error, reason} ->
          Logger.warning("Skipping skill #{inspect(reason)}")
          accepted
      end
  end

ExAgent.new(model: model, skills: Enum.reverse(skills))

Read skill files

Directory-backed skills automatically give the agent a safe read_skill_file tool for relative UTF-8 text files inside that skill's directory (up to 200 listed files, depth 8). ExAgent blocks absolute paths, .. traversal, symlink escapes, hidden dotfiles, binary files and oversized files, returning clear :tool_error messages so the model can correct paths without spending retries.

ExAgent never executes scripts inside a skill directory; expose any executable action as an explicit Elixir tool protected by ExAgent.Permissions.

Unlock tools with a skill

Attach specialized tools to a skill so the model only sees them after loading its instructions:

skills =
  ExAgent.Skills.from_dir!(dir,
    tools: %{"deploy" => DeployTools.tools()}
  )

ExAgent.Skills.Gate omits "deploy"'s tools from model requests until load_skill("deploy") succeeds, keeping your base prompt uncluttered while keeping the tools in the agent's inventory for persisted continuations. Note that gating controls what is offered to the model — always use ExAgent.Permissions for security authorization.

Compaction

When ExAgent.Compaction.capability/2 summarizes older conversation messages, ExAgent.Skills.Restore automatically re-injects any loaded skill's instructions into the request projection (without mutating canonical history) so the agent never forgets a playbook mid-conversation.

Compose it yourself

Use ExAgent.Skills.capabilities/2 when you need custom capability ordering or a tighter :max_file_bytes ceiling (default 256 KiB):

%{gate: gate, restore: restore} =
  ExAgent.Skills.capabilities(skills, max_file_bytes: 32_768)

ExAgent.new(model: model, capabilities: [gate, restore])

Keep :gate before capabilities that filter tools and :restore after compaction.

Limits and security notes

  • Keep skill descriptions concise — every catalog entry consumes tokens on every model request.
  • Treat SKILL.md content as trusted host instructions (like :instructions:); never load untrusted user-supplied skills.
  • Frontmatter fields such as allowed-tools are informational only; enforce real authority with ExAgent.Permissions.

API: ExAgent.Skills, ExAgent.Skill, ExAgent.Skills.Gate, ExAgent.Skills.Restore.