Skip to content

Skills

Updated

A skill is a Markdown document of instructions for one kind of task: how to give a guided tour, how to take a booking, what to say about one exhibit. The persona’s instructions go to the model with every turn, so they should stay short. A skill is different: the model sees only its name and a one-line description of when to use it, and loads the full text when the situation calls for it. That lets an agent know a lot without carrying all of it into every answer.

  • You have an agent with a persona; see Creating an agent.
  • Skills often tell the model when to call a tool.
  • A skill is written in Markdown with a short header in YAML, a plain key: value format.

The AI Skill (comp-ai-skill, AISkillComponent) holds one skill document. An agent can carry several.

Prop Type Default Description
name string 'Skill' A label for the editor, at most 50 characters. Never sent to the model.
content string a starter document The skill: YAML front matter, then a Markdown body.
Member What it does
inspect(content?) Check the component’s content, or a draft you pass, without changing anything. Returns { valid, diagnostics, name?, description?, body? }; each diagnostic has a code and a message.
isEmpty true when the content is blank.
setProps(patch) Change the label or the content.
setEnabled(on) Offer the skill to the model, or withhold it.

Editing a skill’s content, or switching it on or off, applies from the next turn. Renaming its label changes nothing for the model.

A skill starts with front matter between two --- lines, holding its name and description, followed by the body:

---
name: guided-tour
description: Use when the visitor asks for a tour, or seems unsure where to start.
---
## Steps
1. Ask how much time the visitor has: 5, 15 or 30 minutes.
2. Pick three to six works from the list below that fit the time.
3. Introduce each one in two sentences, then ask whether to continue.
4. When the visitor wants to move on, call go_to_wing with the next wing's id.
## Works
- **The Harbour at Dawn** (wing-east): oil; point out the reflected light.
- **Bronze Dancer** (wing-east): walk around it; the pose changes with the angle.
- **Night Market** (wing-west): the painter's last work.
## Notes
Never invent works that are not on this list. If asked about one, say it is not on display.

The rules:

  • Front matter is required, at the very start of the content.
  • name: 1 to 64 lowercase letters and digits, with single hyphens inside, such as guided-tour.
  • description: not blank, at most 1,024 characters. Write it as when to use the skill: it is what the model reads to decide whether to load it.
  • Body: not blank. Steps, lists and short rules work best.
  • Plain YAML only. Advanced YAML features (tags, anchors, aliases, duplicate keys) are rejected.
  • Other keys are ignored. Extra front-matter keys are kept but never acted on. A skill never loads links, files or other documents, and it grants no permissions.

On each turn, the agent offers the model every enabled skill: its name and description. When the model decides a skill applies, its full text is loaded into the request. The agent reports each step through its Signal Emitters:

Event When
AIAgent::skill-requested The model asked for a skill.
AIAgent::skill-loaded The skill’s text was included in a model request. This does not mean the model followed it.
AIAgent::skill-load-failed The skill could not be loaded.
AIAgent::skill-updated The agent’s skills changed.
SkillCheck.jx
#pragma lifecycle(startup)
function startup() {
const skills = findEntity('Guide').getComponents(AISkillComponent);
for (const skill of skills) {
if (skill.isEmpty) {
log(`Skill "${skill.props.name}" is empty.`);
continue;
}
const result = skill.inspect();
if (result.valid) {
log(`Skill "${result.name}": ${result.description}`);
} else {
for (const problem of result.diagnostics) log(`Skill "${skill.props.name}": ${problem.message}`);
}
}
}
  • getComponents(AISkillComponent) lists every skill on the agent.
  • inspect() checks the front matter and body the same way the agent does, and never runs or fetches anything.
  • The editor label (props.name) identifies the component; the skill’s own name comes from its front matter.
SkillModes.jx
#pragma lifecycle(startup)
// Scene: an AI Agent named "Guide" with AI Skills labelled "Tour", "Quiz" and "Shop".
// Other scripts emit 'game/mode' with 'tour', 'quiz' or 'shop'.
const LABELS = { tour: 'Tour', quiz: 'Quiz', shop: 'Shop' };
function startup() {
const skills = findEntity('Guide').getComponents(AISkillComponent);
function setMode(mode) {
for (const skill of skills) skill.setEnabled(skill.props.name === LABELS[mode]);
log('Guide skills now:', LABELS[mode]);
}
setMode('tour');
on('game/mode', (mode) => setMode(mode));
}
  • Only enabled skills are offered to the model, so switching them follows the game without touching the persona.
  • The change applies from the next turn; a reply being written finishes as it started.
ExhibitSkill.jx
#pragma lifecycle(startup)
// Scene: an AI Agent named "Guide". The script builds a skill describing the works in this room.
const WORKS = [
{ title: 'The Harbour at Dawn', note: 'point out the reflected light' },
{ title: 'Bronze Dancer', note: 'the pose changes as you walk around it' },
];
function buildSkill(works) {
const list = works.map((work) => `- **${work.title}**: ${work.note}.`).join('\n');
return [
'---',
'name: room-works',
'description: Use when the visitor asks about the works in this room.',
'---',
'',
'## Works in this room',
'',
list,
'',
'Only talk about the works listed here.',
].join('\n');
}
function startup() {
const guide = findEntity('Guide');
const content = buildSkill(WORKS);
const existing = guide.getComponents(AISkillComponent).find((skill) => skill.props.name === 'Room works');
const skill = existing || new AISkillComponent({ name: 'Room works', content });
const check = skill.inspect(content);
if (!check.valid) return log('Skill rejected:', check.diagnostics.map((d) => d.message).join('; '));
if (existing) existing.setProps({ content });
else guide.addComponent(skill);
}
  • The skill text is assembled from data, so one script serves every room.
  • inspect(content) checks a draft before it is applied, so an invalid skill never reaches the agent.
  • An existing component is updated in place; otherwise a new one is added.
SkillActivity.jx
#pragma lifecycle(startup)
// Scene: an AI Agent named "Guide" with AI Skills and a Signal Emitter on 'guide:ai'.
function startup() {
on('guide:ai', (event) => {
if (event.eventType === EventType.AIAgent.SkillLoaded) log('The guide loaded a skill for this answer.');
if (event.eventType === EventType.AIAgent.SkillLoadFailed) log('A skill could not be loaded.');
});
}
  • These events show whether your descriptions work: if a skill never loads when it should, rewrite its description as a clearer “Use when …”.
  • Describing what, not when. “Tour information” rarely triggers a load. “Use when the visitor asks for a tour” does.
  • Missing or misplaced front matter. The --- header must come first, before any blank line or text.
  • Using the editor label as the skill’s name. The model reads the name in the front matter, never the component’s name prop.
  • Putting everything in the persona. Long instructions go to the model on every turn. Move task-specific detail into skills.