Skills

Skills provide reusable instructions for an agent. Load the skills you want, then pass them through createSkillsAdapter() when creating the agent.

Load a skill file

Create a SKILL.md file:

---
name: concise-answers
description: Keep explanations short and concrete.
---
Lead with the answer. Use an example when it helps explain the idea.

In Node.js, loadSkillFile() reads it into a skill record:

import { createFxAgent } from 'libfx'
import { createSkillsAdapter, loadSkillFile } from 'libfx/skills/node'

const skill = await loadSkillFile('./SKILL.md')
const skills = createSkillsAdapter([skill])
const agent = await createFxAgent({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  ...skills,
})
try {
  const turn = agent.prompt('What is a database index?')
  for await (const event of turn) {
    if (event.type === 'text_delta') process.stdout.write(event.delta)
  }
  await turn.result
} finally {
  await agent.close()
}

The adapter combines the loaded instructions and any tools attached to the records. You choose which files to load; it does not scan directories or load files referenced by a skill.

Use already-loaded instructions

In the browser, import createSkillsAdapter from libfx/skills and pass records with name and instructions. See SkillRecord for optional resources and tools.