---
description: Load Agent Skills from an R2 bucket that uses the Agent Skills directory layout.
title: R2
image: https://developers.cloudflare.com/agents/skills/sources/r2/og.png?v=78cc6735e910ea92
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/agents/llms.txt  
> Use this file to discover all available pages before exploring further.

# R2

Last updated Oct 29, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/agents/skills/sources/r2/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

`skills.r2()` reads [Agent Skills](https://developers.cloudflare.com/agents/skills/) from an [R2](https://developers.cloudflare.com/r2/) bucket. Use it to share one set of skills across many agents, or to manage skills outside your Worker's code.

## Store skills in a bucket

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:

```text
skills/release-notes/SKILL.md
skills/release-notes/references/style-guide.md
skills/release-notes/scripts/format-release-notes.js
skills/pirate-voice/SKILL.md
```

Upload skills with any R2 interface. For example, with Wrangler:

```sh
npx wrangler r2 object put my-agent-skills/skills/pirate-voice/SKILL.md --file ./pirate-voice/SKILL.md --remote
```

## Read skills from the bucket

Bind the bucket to your Worker:

```jsonc
{
	"r2_buckets": [{ "binding": "SKILLS_BUCKET", "bucket_name": "my-agent-skills" }],
}
```

```toml
[[r2_buckets]]
binding = "SKILLS_BUCKET"
bucket_name = "my-agent-skills"
```

Return the source from `getSkills()`:

*src/server.jsjs*

```js
import { Think, skills } from "@cloudflare/think";

export class MyAgent extends Think {
	getSkills() {
		return [skills.r2(this.env.SKILLS_BUCKET, { prefix: "skills/" })];
	}
}
```

*src/server.tsts*

```ts
import { Think, skills } from "@cloudflare/think";

export class MyAgent extends Think<Env> {
	getSkills() {
		return [skills.r2(this.env.SKILLS_BUCKET, { prefix: "skills/" })];
	}
}
```

## Options

| 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](https://developers.cloudflare.com/agents/skills/#validation) when the bucket is listed. Skills that break a rule load with a warning, and skills with no `description` are skipped and logged.

## Run skill scripts

R2 stores files but cannot run them. To run scripts from R2 skills, set the experimental [script runner](https://developers.cloudflare.com/agents/skills/execution/#script-runner), which adds the `run_skill_script` tool. To store and run skills as files, use a [Computer Workspace](https://developers.cloudflare.com/agents/skills/sources/computer/) instead.

## Example

The [`r2-skills` example ↗︎](https://github.com/cloudflare/agents/tree/main/examples/r2-skills) loads skills from a bucket, runs a script with the script runner, and lets you upload and delete skills from the UI.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/agents/skills/sources/r2/#page","headline":"R2","description":"Load Agent Skills from an R2 bucket that uses the Agent Skills directory layout.","url":"https://developers.cloudflare.com/agents/skills/sources/r2/","inLanguage":"en","image":"https://developers.cloudflare.com/agents/skills/sources/r2/og.png?v=78cc6735e910ea92","dateModified":"2026-10-29","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
