# Gateway Workers

Build, debug, or review Cloudflare Workers invoked by the Forward action in Gateway...

- Repository: https://github.com/cloudflare/skills (3246 stars)
- Category: Testing
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add cloudflare/skills --skill gateway-workers -g -a claude-code -y`
Codex: `npx skills add cloudflare/skills --skill gateway-workers -g -a codex -y`
Cursor: `npx skills add cloudflare/skills --skill gateway-workers -g -a cursor -y`
Gemini CLI: `npx skills add cloudflare/skills --skill gateway-workers -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add cloudflare/skills`

## Description

Build, debug, or review Cloudflare Workers invoked by the Forward action in Gateway HTTP policies, including the GatewayMiddleware entrypoint, Gateway types, context, and continuation.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Gateway Workers

Read the current [Forward guide](https://developers.cloudflare.com/cloudflare-one/traffic-controls/integrate-workers/forward-traffic/index.md) before implementing a Worker. It defines how Gateway invokes Workers on permitted HTTP traffic. Retrieve the relevant page below rather than copying setup, API payloads, or limits into the project from memory.

## Workflow

1. Inspect the existing Worker and choose a [Worker template](https://developers.cloudflare.com/cloudflare-one/traffic-controls/integrate-workers/worker-templates/index.md) for the required transformation, synthetic response, or background task.
2. Export a named `GatewayMiddleware` class extending `WorkerEntrypoint` from `cloudflare:workers`. Implement `handle(request, context, next)` and return a `Response`. Gateway calls this method through RPC. A default `fetch()` handler alone does not implement the Forward contract.
3. For TypeScript, follow the chosen template's current package installation and type-import instructions.
4. Use the second argument for [Gateway context](https://developers.cloudflare.com/cloudflare-one/traffic-controls/integrate-workers/available-context/index.md). It describes the original request and stays unchanged when the Worker modifies the request. Keep it distinct from `this.ctx` (Workers execution context) and `this.env` (bindings).
5. Continue the user's request with `next(request)` at most once, or return a synthetic response without calling it. `next()` always targets the original destination. Changes to the destination URL or host are ignored, and it cannot redirect, retry, or fan out. Use `fetch()` to send a request to a different destination. It creates an independent subrequest that does not inherit the user's Gateway policies or egress configuration.

## Context

The rest: https://github.com/cloudflare/skills/blob/HEAD/skills/gateway-workers/SKILL.md
