agentleFS
CloudflareKnown publishercloudflare/vibesdk/worker/agents/think/skills/app-ai-binding/SKILL.md

app-ai-binding

Skill5.4k starsChanged 3 months agoMITView on GitHub

Build AI features in generated apps using the platform-provided Workers AI binding. Load this skill for chatbots, summarization, classification, embeddings, semantic search, image understanding, transcription, translation, or other model inference.

  • Reads credentials

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 2 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use only AI.run(model, inputs, options?).

    line 8
  2. Very specific:

    Keep AI calls in the server-side App class.

    line 33
  3. Very specific:

    Use @cf/meta/llama-4-scout-17b-16e-instruct with either prompt or messages:

    line 39
  4. Very specific:

    Use @cf/baai/bge-base-en-v1.5.

    line 50
  5. Very specific:

    Use @cf/microsoft/resnet-50 with image bytes converted to a number array:

    line 60
  6. Very specific:

    Use @cf/openai/whisper with audio bytes:

    line 69
  7. Distinctive:

    Never return canned, random, mock, placeholder, or hard-coded content as a fallback for an AI response.

    line 82
  8. Very specific:

    Never catch an AI.run() error and continue with an apparently successful response.

    line 83
  9. Very specific:

    Never return 200 with fields such as fallbackUsed after inference fails.

    line 84
  10. Distinctive:

    Do not retry rate-limit failures in a loop.

    line 86
  11. Very specific:

    Use non-streaming calls for preview-compatible code.

    line 108

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Generated apps can call Workers AI from the App Durable Object through this.env.AI. The platform provides this binding automatically in Dynamic Worker previews and native Cloudflare deployments. Do not add an ai section to the generated app's wrangler.json.

Use only AI.run(model, inputs, options?). Preview uses a restricted proxy with this method, while deployed Workers receive the native Workers AI binding. Methods such as AI.gateway(), AI.models(), AI.autorag(), and AI.toMarkdown() are not portable between preview and deployment.

Type and usage

import { DurableObject } from "cloudflare:workers";

interface Env {
  AI: Ai;
}

export class App extends DurableObject<Env> {
  async fetch(request: Request): Promise<Response> {
    const { prompt } = await request.json<{ prompt: string }>();
    const result = await this.env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", {
      messages: [
        { role: "system", content: "Answer clearly and concisely." },
        { role: "user", content: prompt },
      ],
    });
    return Response.json(result);
  }
}

Keep AI calls in the server-side App class. Browser code should call an app API route; it must never receive model credentials or call the binding directly.

Common tasks

Text generation

Use @cf/meta/llama-4-scout-17b-16e-instruct with either prompt or messages:

const result = await this.env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", {
  messages: [{ role: "user", content: userPrompt }],
  max_tokens: 512,
});

Embeddings

Use @cf/baai/bge-base-en-v1.5. The response contains embedding vectors in data:

const result = await this.env.AI.run("@cf/baai/bge-base-en-v1.5", {
  text: ["first document", "second document"],
});

Image classification

Use @cf/microsoft/resnet-50 with image bytes converted to a number array:

const image = [...new Uint8Array(await request.arrayBuffer())];
const result = await this.env.AI.run("@cf/microsoft/resnet-50", { image });

Speech transcription

Use @cf/openai/whisper with audio bytes:

const audio = [...new Uint8Array(await request.arrayBuffer())];
const result = await this.env.AI.run("@cf/openai/whisper", { audio });

Model input and output shapes differ. Keep model-specific parsing close to the call and validate user input before inference. Use only active model IDs from the current Workers AI model catalog; never generate code with a deprecated model.

Limits and errors

Dynamic Worker previews enforce a per-app AI call limit. AI features must fail transparently when inference is unavailable.

  • Never return canned, random, mock, placeholder, or hard-coded content as a fallback for an AI response.
  • Never catch an AI.run() error and continue with an apparently successful response.
  • Never return 200 with fields such as fallbackUsed after inference fails.
  • Return a non-2xx JSON response containing a safe, useful error message. The frontend must display that error to the user.
  • Do not retry rate-limit failures in a loop.
try {
  const result = await this.env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", {
    messages: [{ role: "user", content: userPrompt }],
  });
  return Response.json(result);
} catch (error) {
  const message = error instanceof Error ? error.message : "AI inference failed";
  return Response.json({ error: "AI inference failed", details: message }, { status: 503 });
}

Frontend callers must inspect both the HTTP status and error body:

const response = await fetch("./api/chat", requestOptions);
const body = await response.json<{ content?: string; error?: string; details?: string }>();
if (!response.ok) throw new Error(body.details || body.error || "AI request failed");

Use non-streaming calls for preview-compatible code. Native Workers AI deployments support { stream: true }, but streaming across the preview proxy is not guaranteed.

Download now (ZIP)

Trending

More talk lately.about the whole repository

Dec 2025: 4 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 8 mentionsOct 2026: 2 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cloudflare/vibesdk repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about cloudflare/vibesdk

The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 18

Talked about on GitHub, Hacker News and Bluesky (18 times).

On GitHub · 10

5 more on GitHub

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.