Skills

Skills are reusable instructions for an agent, optionally with tools. Load the skills you want, then pass them through createSkillsAdapter() when you create 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 or Bun, loadSkillFile() reads it into a skill record:

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

const skills = createSkillsAdapter([await loadSkillFile('./SKILL.md')])
const agent = createFxAgent({ ...skills })

const turn = agent.session().prompt('What is a database index?')
for await (const event of turn) {
  if (event.type === 'text_delta') process.stdout.write(event.delta)
}
await agent.close()

The adapter combines the skills' instructions and any tools attached to them. You choose which files to load: it doesn't scan directories or load files a skill references. It takes up to 64 skills with unique names, and their combined instructions must fit in 64 KiB. A skill's tools must set idempotent themselves, like any other tool.

Spreading the adapter sets the agent's instructions and tools. To keep your own as well, combine them, as in tools: [...myTools, ...skills.tools].

Use already-loaded instructions

In the browser, import createSkillsAdapter from libfx/skills and pass records with name and instructions:

import { createSkillsAdapter } from 'libfx/skills'

const skills = createSkillsAdapter([
  { name: 'concise-answers', instructions: 'Lead with the answer.' },
])

See SkillRecord for optional resources and tools.