cloudflare-worker-typegen

ldsgroups225's avatarfrom ldsgroups225

Use this when Cloudflare bindings/env vars change and worker type definitions need regeneration (cf-typegen / worker-configuration.d.ts).

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 9, 2026⬇️3downloads

When & Why to Use This Skill

This Claude skill automates the synchronization between Cloudflare Worker configurations and TypeScript definitions. It ensures that 'worker-configuration.d.ts' accurately reflects changes made in 'wrangler.jsonc' bindings and environment variables, maintaining robust type safety and streamlining the development workflow for Cloudflare Workers.

Use Cases

  • Scenario 1: Automatically regenerating TypeScript definitions after adding new Cloudflare resources like KV namespaces, D1 databases, or R2 buckets to your configuration files.
  • Scenario 2: Resolving IDE type errors and 'property does not exist' warnings when accessing environment variables through the 'cloudflare:workers' module.
  • Scenario 3: Managing and syncing type definitions across multiple services in a monorepo environment, ensuring that both user-facing applications and background data services have up-to-date binding types.
namecloudflare-worker-typegen
descriptionUse this when Cloudflare bindings/env vars change and worker type definitions need regeneration (cf-typegen / worker-configuration.d.ts).

Cloudflare Worker bindings + type generation

Use this skill when the user modifies wrangler.jsonc, adds/removes bindings, changes environment variables, or sees type errors related to worker bindings.

Binding access pattern

  • Use import { env } from "cloudflare:workers" to access bindings globally.

Generate worker types

  • For the user application:
    • pnpm run --filter user-application cf-typegen

This updates worker-configuration.d.ts based on apps/user-application/wrangler.jsonc.

  • For the data service:
    • pnpm run --filter data-service cf-typegen

This updates worker-configuration.d.ts based on apps/data-service/wrangler.jsonc.

Notes

  • Local secrets belong in apps/user-application/.dev.vars.
  • If bindings change in other workers (e.g., apps/data-service), ensure their corresponding typegen workflow is run (if configured) and worker-configuration.d.ts stays in sync.