Anvia
Skills

Skill Loading

Discover and resolve skills at runtime.

Use loadSkills(...) to resolve one or more skill loaders into a SkillSet.

1. Load One Directory

import { loadSkills, skill } from "@anvia/core";

const skillSet = await loadSkills(skill.local("./skills"));

The returned SkillSet contains:

skillSet.skills;
skillSet.instructions;
skillSet.tools;

2. Load Multiple Sources

const skillSet = await loadSkills([
  skill.local("./skills/base"),
  skill.local("./skills/project"),
]);

When two loaders return the same skill name, the later loader wins. Use this to override shared skills with project-specific versions.

3. Handle Validation Errors

import { SkillValidationError } from "@anvia/core";

try {
  const skillSet = await loadSkills(skill.local("./skills"));
  return skillSet;
} catch (error) {
  if (error instanceof SkillValidationError) {
    console.error(error.issues);
  }
  throw error;
}

Each validation issue includes the file path and a message.

4. Attach the Result Once

const skillSet = await loadSkills(skill.local("./skills"));

const agent = new AgentBuilder("assistant", model)
  .skills(skillSet)
  .build();

Load skills during startup or request setup, then pass the SkillSet to the agent builder.

Empty Skill Sets

If no skills are loaded, skillSet.instructions is an empty string and skillSet.tools is an empty array.