Give an Agent Skills from SKILL.md
easy10 minagent-skills.ts
You keep instructions for recurring tasks (release notes, reviews, deploys) as Agent Skills folders, and want an agent to load one only when a task needs it instead of carrying them all in its prompt.
What it shows
SkillRegistryfindsSKILL.mdfolders indirs, the workspace, the project and the home folder- The model sees names and descriptions,
use_skillloads the instructions and lists the files todos: trueaddswrite_todos, the list is kept in the thread and returned asresult.todos
The code
agent-skills.ts
import { Agent, Cogitator, SkillRegistry } from '@cogitator-ai/core';
const agent = new Agent({
name: 'release-manager',
model: 'ollama/qwen2.5:0.5b',
instructions: 'You prepare releases. Activate the matching skill before you work on a task.',
skills: [new SkillRegistry({ dirs: ['./skills'] })],
todos: true,
});
const cog = new Cogitator({ memory: { adapter: 'memory' } });
const result = await cog.run(agent, {
input: 'Activate the release-notes skill with use_skill, then write release notes for 2.1.0.',
threadId: 'release-2.1.0',
onToolCall: (call) => console.log(call.name, call.arguments),
});
console.log(result.output);
console.log(result.todos);
await cog.close();Run it
install · bash
pnpm add @cogitator-ai/core
ollama pull qwen2.5:0.5brun · bash
npx tsx agent-skills.tsOr run the full example from a clone of the repository (keys in .env):
repository · bash
npx tsx examples/core/23-skills-and-todos.tsskills/release-notes/SKILL.md
skills/release-notes/SKILL.md · bash
mkdir -p skills/release-notes
cat > skills/release-notes/SKILL.md <<'EOF'
---
name: release-notes
description: Write release notes for a new version from a list of changes. Use when asked for release notes or a changelog entry.
---
Sort every change into Added, Changed or Fixed, one line per change, in the past tense.
EOF