skills.r2() reads Agent Skills from an R2 bucket. Use it to share one set of skills across many agents, or to manage skills outside your Worker's code.
The bucket uses the same layout as a skills folder, under a key prefix. Every <prefix><name>/SKILL.md object is a skill, and the objects beside it are its resources:
skills/release-notes/SKILL.md
skills/release-notes/references/style-guide.md
skills/release-notes/scripts/format-release-notes.js
skills/pirate-voice/SKILL.mdUpload skills with any R2 interface. For example, with Wrangler:
npx wrangler r2 object put my-agent-skills/skills/pirate-voice/SKILL.md --file ./pirate-voice/SKILL.md --remoteBind the bucket to your Worker:
{
"r2_buckets": [{ "binding": "SKILLS_BUCKET", "bucket_name": "my-agent-skills" }],
}[[r2_buckets]]
binding = "SKILLS_BUCKET"
bucket_name = "my-agent-skills"Return the source from getSkills():
import { Think, skills } from "@cloudflare/think";
export class MyAgent extends Think {
getSkills() {
return [skills.r2(this.env.SKILLS_BUCKET, { prefix: "skills/" })];
}
}import { Think, skills } from "@cloudflare/think";
export class MyAgent extends Think<Env> {
getSkills() {
return [skills.r2(this.env.SKILLS_BUCKET, { prefix: "skills/" })];
}
}| Option | Default | Description |
|---|---|---|
prefix |
"" |
Key prefix that holds the skill directories |
skills |
all skills | Only serve these skill names |
refreshIntervalMs |
60000 |
How long to reuse a bucket listing before listing again. 0 lists on every call |
id |
r2:<prefix> |
Source id used in diagnostics |
Each SKILL.md is checked against the specification when the bucket is listed. Skills that break a rule load with a warning, and skills with no description are skipped and logged.
R2 stores files but cannot run them. To run scripts from R2 skills, set the experimental script runner, which adds the run_skill_script tool. To store and run skills as files, use a Computer Workspace instead.
The r2-skills example ↗︎ loads skills from a bucket, runs a script with the script runner, and lets you upload and delete skills from the UI.