agentleFS
damslethdamsleth/SKILLS/cj-cloudflare-worker/SKILL.md

cj-cloudflare-worker

Skill1 starsChanged 32 days agoMITView on GitHub

Create or update a Cloudflare Worker inside an existing GitHub repository and deploy it to one or more custom domains. Use when Codex needs to add or revise `wrangler.jsonc`, wire GitHub Actions deployment on `main` or preview branches, configure custom domains or DNS-backed hostnames, request Cloudflare account credentials and GitHub secrets, or add optional Durable Objects with SQLite-backed storage for a public or private repo.

  • Reads credentials
  • Installs packages

The file

Show its rules and text

We split this skill into the rules it gives an agent

33 rules. About 0 are common, 22 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈22

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Create Workers in-place inside an existing repository.

    line 8
  2. Distinctive:

    Read existing GitHub workflows before adding new ones.

    line 26
  3. Distinctive:

    Prefer adapting the current project over introducing a parallel structure.

    line 27
  4. Very specific:

    Add or update wrangler.jsonc.

    line 38
  5. Very specific:

    Use ./assets/wrangler.custom-domain.jsonc for a normal Worker.

    line 39
  6. Very specific:

    Use ./assets/wrangler.durable-object.jsonc when the Worker needs a Durable Object.

    line 40
  7. Distinctive:

    Keep the repo's real entrypoint and build output paths.

    line 41
  8. Distinctive:

    Use one route object per hostname.

    line 43
  9. Very specific:

    Use custom_domain: true only for hostnames inside Cloudflare-managed zones.

    line 44
  10. Distinctive:

    If the Worker should sit in front of an existing origin on only part of a hostname, use a route pattern instead of a custom domain.

    line 45
  11. Very specific:

    Keep env.preview separate from production so preview deploys do not overwrite the primary Worker.

    line 46
  12. Distinctive:

    Add the Worker runtime changes.

    line 48
  13. Distinctive:

    If the app is mostly static, route the Worker to the built assets directory instead of replacing the build system.

    line 50
  14. Distinctive:

    If a Durable Object is requested, use SQLite-backed Durable Objects for new classes by default.

    line 51
  15. Distinctive:

    Add a migration entry whenever introducing a Durable Object class.

    line 52
  16. Distinctive:

    Do not attempt to convert an already deployed KV-backed Durable Object to SQLite in place.

    line 53
  17. Distinctive:

    Add GitHub Actions deployment.

    line 55
  18. Very specific:

    Add ./assets/deploy-worker-preview.yml only when preview deploys are requested.

    line 57
  19. Distinctive:

    Keep Node on GitHub Actions as the default runtime unless the repo clearly uses something else.

    line 58
  20. Distinctive:

    Keep the preview workflow guard that skips pull requests from forks so secrets are not exposed.

    line 61
  21. Distinctive:

    Ask for a Cloudflare API token with the minimum needed permissions for Workers and DNS changes.

    line 64
  22. Very specific:

    Default local storage to a repo-local, gitignored .env file unless project conventions prefer .dev.vars.

    line 65
  23. Very specific:

    Create or update .env.example using ./assets/cloudflare.env.example.

    line 66
  24. Distinctive:

    Never commit live secrets.

    line 68
  25. Distinctive:

    Verify without assuming deploy access.

    line 70
  26. Very specific:

    Only run wrangler deploy when the user explicitly wants a live deploy or credentials are already provided.

    line 72
  27. Distinctive:

    If a preview workflow is added, verify that the PR comment step updates an existing bot comment instead of spamming new comments.

    line 73
  28. Distinctive:

    Prefer custom domains over legacy wildcard routes when the Worker should own the entire hostname.

    line 77
  29. Very specific:

    Prefer workers.dev preview deployments unless the user explicitly asks for preview custom domains.

    line 78
  30. Distinctive:

    If a hostname belongs to a zone not managed in the current Cloudflare account, stop short of claiming automatic DNS setup and explain the …

    line 79
  31. Distinctive:

    If the repository already contains deploy workflows, extend them rather than adding a conflicting second pipeline.

    line 80
  32. Very specific:

    If multiple hostnames are needed, keep them in one routes array unless there is a clear need for separate Workers.

    line 81
  33. Distinctive:

    When finishing a task with this skill, report:

    line 94

≈ “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

cj-cloudflare-worker

Create Workers in-place inside an existing repository. Preserve the repo's package manager, language, build system, and directory layout instead of replacing the project with a starter.

Retrieval First

Cloudflare configuration changes often. Retrieve current docs before making or reviewing production changes for:

  • Wrangler configuration: https://developers.cloudflare.com/workers/wrangler/configuration/
  • Custom domains: https://developers.cloudflare.com/workers/configuration/routing/custom-domains/
  • Durable Object migrations: https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/
  • API token templates and permissions: https://developers.cloudflare.com/fundamentals/api/reference/template/

Load ./references/checklist.md for the execution flow. Load ./references/patterns.md for file patterns and token guidance.

Workflow

  1. Inspect the repository first.
  • Detect the package manager from the lockfile.
  • Find the app entrypoint, build command, static output directory, and any existing Cloudflare files.
  • Read existing GitHub workflows before adding new ones.
  • Prefer adapting the current project over introducing a parallel structure.
  1. Resolve the minimum missing deployment inputs.
  • Production Worker name.
  • Preview Worker name or preview environment name.
  • main script path and optional static assets directory.
  • Production branch. Default to main.
  • Hostnames to attach and which zones are managed in Cloudflare.
  • Whether preview deploys should run on pull requests, a preview branch, or both.
  • Whether Durable Objects are needed and what state they hold.
  1. Add or update wrangler.jsonc.
  • Use ./assets/wrangler.custom-domain.jsonc for a normal Worker.
  • Use ./assets/wrangler.durable-object.jsonc when the Worker needs a Durable Object.
  • Keep the repo's real entrypoint and build output paths.
  • Set compatibility_date to the current date unless the repo already pins an older baseline for compatibility reasons.
  • Use one route object per hostname.
  • Use custom_domain: true only for hostnames inside Cloudflare-managed zones.
  • If the Worker should sit in front of an existing origin on only part of a hostname, use a route pattern instead of a custom domain.
  • Keep env.preview separate from production so preview deploys do not overwrite the primary Worker.
  1. Add the Worker runtime changes.
  • Preserve the repository's JS or TS conventions.
  • If the app is mostly static, route the Worker to the built assets directory instead of replacing the build system.
  • If a Durable Object is requested, use SQLite-backed Durable Objects for new classes by default.
  • Add a migration entry whenever introducing a Durable Object class.
  • Do not attempt to convert an already deployed KV-backed Durable Object to SQLite in place.
  1. Add GitHub Actions deployment.
  • Start from ./assets/deploy-worker.yml.
  • Add ./assets/deploy-worker-preview.yml only when preview deploys are requested.
  • Keep Node on GitHub Actions as the default runtime unless the repo clearly uses something else.
  • Adapt install commands to the lockfile: npm ci, pnpm install --frozen-lockfile, yarn install --frozen-lockfile, or the repo's existing install wrapper.
  • Reuse existing composite actions or shared setup steps when the repo already has them.
  • Keep the preview workflow guard that skips pull requests from forks so secrets are not exposed.
  1. Request credentials and wire secrets.
  • Ask for a Cloudflare API token with the minimum needed permissions for Workers and DNS changes.
  • Default local storage to a repo-local, gitignored .env file unless project conventions prefer .dev.vars.
  • Create or update .env.example using ./assets/cloudflare.env.example.
  • Mirror the same values in GitHub Actions secrets: CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.
  • Never commit live secrets.
  1. Verify without assuming deploy access.
  • Validate JSONC shape, workflow syntax, and package scripts locally.
  • Only run wrangler deploy when the user explicitly wants a live deploy or credentials are already provided.
  • If a preview workflow is added, verify that the PR comment step updates an existing bot comment instead of spamming new comments.

Decision Rules

  • Prefer custom domains over legacy wildcard routes when the Worker should own the entire hostname.
  • Prefer workers.dev preview deployments unless the user explicitly asks for preview custom domains.
  • If a hostname belongs to a zone not managed in the current Cloudflare account, stop short of claiming automatic DNS setup and explain the external DNS action needed.
  • If the repository already contains deploy workflows, extend them rather than adding a conflicting second pipeline.
  • If multiple hostnames are needed, keep them in one routes array unless there is a clear need for separate Workers.
  • For private repositories, bias toward GitHub Actions with repo secrets over local-only deployment steps.

Assets

  • ./assets/wrangler.custom-domain.jsonc
  • ./assets/wrangler.durable-object.jsonc
  • ./assets/deploy-worker.yml
  • ./assets/deploy-worker-preview.yml
  • ./assets/cloudflare.env.example

Response Shape

When finishing a task with this skill, report:

  • Files created or changed.
  • Required GitHub secrets.
  • Any unresolved hostname, zone, or credential assumptions.
  • What was verified locally and what was not run.

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.