Skip to content

Commit 3f841f0

Browse files
authored
Instruction tuning for skills (#8)
* Instruction tuning for skills * Tune readme
1 parent eaa8712 commit 3f841f0

18 files changed

Lines changed: 1466 additions & 1287 deletions

File tree

README.md

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const { tools } = await createBashTool({ sandbox: customSandbox });
177177

178178
## Skills (Experimental)
179179

180-
Skills are modular capabilities that extend agent functionality. Each skill is a directory containing a `SKILL.md` file with instructions and optional scripts.
180+
[Skills](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview) are modular capabilities that extend agent functionality. Each skill is a directory containing a `SKILL.md` file with instructions and optional scripts.
181181

182182
```typescript
183183
import {
@@ -187,7 +187,7 @@ import {
187187
import { ToolLoopAgent } from "ai";
188188

189189
// Discover skills and get files to upload
190-
const { loadSkill, files, instructions } = await createSkillTool({
190+
const { skill, files, instructions } = await createSkillTool({
191191
skillsDirectory: "./skills",
192192
});
193193

@@ -200,46 +200,28 @@ const { tools } = await createBashTool({
200200
// Use both tools with an agent
201201
const agent = new ToolLoopAgent({
202202
model,
203-
tools: { loadSkill, ...tools },
203+
tools: { skill, ...tools },
204204
});
205205
```
206206

207+
[Full Example](./examples/skills-tool/) and see [Skills.sh for a directory of publicly available skills.](https://skills.sh/)
208+
207209
### Skill Directory Structure
208210

209-
```
211+
```text
210212
skills/
211213
├── csv/
212-
│ ├── SKILL.md # Required: instructions with YAML frontmatter
213-
│ ├── analyze.sh # Optional: scripts the agent can run
214-
│ └── filter.sh
214+
│ ├── SKILL.md # Required: instructions with YAML frontmatter
215+
│ └── scripts/ # Optional: scripts the agent can run
216+
│ ├── analyze.sh
217+
│ └── filter.sh
215218
└── text/
216219
├── SKILL.md
217-
└── search.sh
220+
└── scripts/
221+
└── search.sh
218222
```
219223

220-
### SKILL.md Format
221-
222-
```markdown
223-
---
224-
name: csv
225-
description: Analyze and transform CSV files
226-
---
227-
228-
# CSV Processing
229-
230-
Use `./skills/csv/analyze.sh <file>` to analyze a CSV file.
231-
```
232-
233-
### How It Works
234-
235-
1. `createSkillTool` discovers skills and returns:
236-
- `loadSkill` - Tool for the agent to load a skill's instructions on demand
237-
- `files` - All skill files to pass to `createBashTool`
238-
- `instructions` - Extra instructions listing available skills
239-
240-
2. The agent sees skill names in the `loadSkill` tool description
241-
3. When the agent needs a skill, it calls `loadSkill("csv")` to get detailed instructions
242-
4. The agent uses `bash` to run scripts from `./skills/csv/`
224+
See the [example skills](./examples/skills-tool/skills/) for a complete reference.
243225

244226
## AI Agent Instructions
245227

examples/skills-tool/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ The example includes two bash-based skills:
2626
npx tsx examples/skills-tool/index.ts
2727
```
2828

29-
Requires `ANTHROPIC_API_KEY` environment variable.
30-
3129
## Code Overview
3230

3331
```typescript

examples/skills-tool/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
async function main() {
1818
// Discover skills and get files to upload
19-
const { loadSkill, skills, files, instructions } = await createSkillTool({
19+
const { skill, skills, files, instructions } = await createSkillTool({
2020
skillsDirectory: path.join(import.meta.dirname, "skills"),
2121
});
2222

@@ -36,17 +36,17 @@ async function main() {
3636
const agent = new ToolLoopAgent({
3737
model: "anthropic/claude-haiku-4.5",
3838
tools: {
39-
loadSkill,
39+
skill,
4040
bash: tools.bash,
4141
},
4242
instructions: `You are a data processing assistant with access to skills.
43-
Use loadSkill to discover how to use a skill, then use bash to run its scripts.
43+
Use the skill tool to discover how to use a skill, then use bash to run its scripts.
4444
Skills are located at ./skills/<skill-name>/.`,
4545
onStepFinish: ({ toolCalls, toolResults }) => {
4646
if (toolCalls && toolCalls.length > 0) {
4747
for (const call of toolCalls) {
4848
console.log(`Tool: ${call.toolName}`);
49-
if (call.toolName === "loadSkill" && "input" in call) {
49+
if (call.toolName === "skill" && "input" in call) {
5050
const input = call.input as { skillName: string };
5151
console.log(` Loading skill: ${input.skillName}`);
5252
} else if (call.toolName === "bash" && "input" in call) {

examples/skills-tool/skills/csv/SKILL.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,39 @@ Process CSV files using standard bash tools (awk, cut, sort, grep).
1212
### analyze.sh
1313
Get statistics and summary of a CSV file.
1414
```bash
15-
bash /skills/csv/analyze.sh data.csv
15+
bash /skills/csv/scripts/analyze.sh data.csv
1616
```
1717

1818
### filter.sh
1919
Filter rows where a column matches a value.
2020
```bash
21-
bash /skills/csv/filter.sh data.csv <column_number> <value>
21+
bash /skills/csv/scripts/filter.sh data.csv <column_number> <value>
2222
```
2323

2424
### select.sh
2525
Select specific columns from CSV.
2626
```bash
27-
bash /skills/csv/select.sh data.csv <col1,col2,col3>
27+
bash /skills/csv/scripts/select.sh data.csv <col1,col2,col3>
2828
```
2929

3030
### sort.sh
3131
Sort CSV by a column.
3232
```bash
33-
bash /skills/csv/sort.sh data.csv <column_number> [--numeric] [--reverse]
33+
bash /skills/csv/scripts/sort.sh data.csv <column_number> [--numeric] [--reverse]
3434
```
3535

3636
## Examples
3737

3838
```bash
3939
# Show CSV summary
40-
bash /skills/csv/analyze.sh sales.csv
40+
bash /skills/csv/scripts/analyze.sh sales.csv
4141

4242
# Filter where column 3 equals "active"
43-
bash /skills/csv/filter.sh users.csv 3 active
43+
bash /skills/csv/scripts/filter.sh users.csv 3 active
4444

4545
# Select columns 1, 2, and 4
46-
bash /skills/csv/select.sh data.csv 1,2,4
46+
bash /skills/csv/scripts/select.sh data.csv 1,2,4
4747

4848
# Sort by column 2 numerically in reverse
49-
bash /skills/csv/sort.sh data.csv 2 --numeric --reverse
49+
bash /skills/csv/scripts/sort.sh data.csv 2 --numeric --reverse
5050
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/skills-tool/skills/text/SKILL.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,40 @@ Process text files using standard bash tools (grep, sed, awk, wc).
1212
### stats.sh
1313
Get statistics about a text file (lines, words, characters).
1414
```bash
15-
bash /skills/text/stats.sh document.txt
15+
bash /skills/text/scripts/stats.sh document.txt
1616
```
1717

1818
### search.sh
1919
Search for patterns in text files.
2020
```bash
21-
bash /skills/text/search.sh <file> <pattern> [--count] [--context <lines>]
21+
bash /skills/text/scripts/search.sh <file> <pattern> [--count] [--context <lines>]
2222
```
2323

2424
### extract.sh
2525
Extract specific lines or sections from a file.
2626
```bash
27-
bash /skills/text/extract.sh <file> --lines <start>-<end>
28-
bash /skills/text/extract.sh <file> --between <start_pattern> <end_pattern>
27+
bash /skills/text/scripts/extract.sh <file> --lines <start>-<end>
28+
bash /skills/text/scripts/extract.sh <file> --between <start_pattern> <end_pattern>
2929
```
3030

3131
### wordfreq.sh
3232
Count word frequencies in a text file.
3333
```bash
34-
bash /skills/text/wordfreq.sh document.txt [--top <n>]
34+
bash /skills/text/scripts/wordfreq.sh document.txt [--top <n>]
3535
```
3636

3737
## Examples
3838

3939
```bash
4040
# Get file statistics
41-
bash /skills/text/stats.sh readme.txt
41+
bash /skills/text/scripts/stats.sh readme.txt
4242

4343
# Search with context
44-
bash /skills/text/search.sh log.txt "ERROR" --context 2
44+
bash /skills/text/scripts/search.sh log.txt "ERROR" --context 2
4545

4646
# Extract lines 10-20
47-
bash /skills/text/extract.sh file.txt --lines 10-20
47+
bash /skills/text/scripts/extract.sh file.txt --lines 10-20
4848

4949
# Top 10 most frequent words
50-
bash /skills/text/wordfreq.sh article.txt --top 10
50+
bash /skills/text/scripts/wordfreq.sh article.txt --top 10
5151
```
File renamed without changes.

0 commit comments

Comments
 (0)