agentleFS
d-o-hubd-o-hub/github-template-ai-agents/.agents/skills/cloudflare-worker-api/SKILL.md

cloudflare-worker-api

Skill2 starsChanged 9 days agoMITView on GitHub

Structure Worker API routes and handlers. Use this skill when defining Cloudflare Worker routes, building response helpers, or implementing typed handler patterns — even if they just say "set up the worker routes" or "add an API endpoint to the worker". Auth belongs to secure-invite-and-access. Not for api-design-first, cicd-pipeline.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All routes must be typed and validated.

    line 40
  2. Distinctive:

    Use Zod for input validation.

    line 41
  3. Distinctive:

    All responses must follow consistent format.

    line 42

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Cloudflare Worker API

Provide a standardized structure for Worker routes, auth middleware, and response helpers.

When to Use

  • User asks to define Cloudflare Worker routes or handlers
  • Building response helpers or typed handler patterns
  • Even if they just say "set up the worker routes" or "add an API endpoint to the worker"

Key Responsibilities

  • Define API routes and handlers.
  • Implement auth middleware and session validation.
  • Provide response helpers for consistent API responses.
  • Design signed URL endpoints for secure file access.

Interface Example

// Example route file structure
src/routes/
  access.ts
  resources.ts
  admin.ts

Constraints

  • No hardcoded secrets.
  • All routes must be typed and validated.
  • Use Zod for input validation.
  • All responses must follow consistent format.

Checklist

  • All routes have input validation with Zod.
  • Error responses follow consistent format.
  • Auth middleware applied to protected routes.
  • Rate limiting configured on public endpoints.
  • CORS headers set appropriately.

References

  • references/routing-patterns.md - Common routing patterns for Workers
  • references/response-helpers.md - Consistent response formatting

See Also

  • secure-invite-and-access — Auth endpoints and permissions
  • api-design-first — API design and OpenAPI specs

Rationalizations

RationalizationReality
"I'll add auth later, it's just an MVP"Unauthenticated endpoints are immediately exploitable; even internal routes need auth.
"Hardcoded secrets are fine for dev"Dev credentials leak into version control; use environment bindings from day one.
"Rate limiting isn't needed for internal APIs"Compromised internal tokens turn rate-limited services into attack amplifiers.

Red Flags

  • Returning raw error stack traces in API responses
  • Skipping input validation because "the client should handle it"
  • Deploying without CORS configuration on public endpoints

Voice & Context

  • Default: professional + blog
  • Reference: voice-profiles skill for definitions and auto-detection.

Download now (ZIP)

Does it work?

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

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.