# Debug a CF Worker

> Tail logs, decode CF exception codes (1101 uncaught, 1102 CPU), trace which boundary is failing.

- **Kind**: Shell tool
- **Category**: engineering
- **Owner**: Sentinel (/sentinel)
- **Default model**: sonnet
- **Cost class**: standard (Sonnet-class model. Default for most skills.)
- **Turn budget**: 15
- **Execution**: synchronous (result lands in the same turn)
- **Canonical URL**: https://app.51ultron.com/docs/skills/debug-cf-worker

## What it does

Implements debug-cf-worker/SKILL.md. Tails the live Worker logs via wrangler tail, captures the exception, decodes the error code, identifies which boundary is at fault (Worker code, DO RPC, container fetch, fetch upstream). When the failure spans multiple layers, layers in instrument-then-fix/SKILL.md: insert raw passthrough diagnostics at each boundary to pinpoint the broken layer before patching.

## When to use this

- user reports a Worker returning 500
- user says 'CF exception 1101' or 'error code 1102'
- Worker works locally but fails when deployed
- DO RPC failing or container fetch returning HTML error page

## When NOT to use this

- Worker hasn't been deployed yet → use deploy-to-cloudflare and verify-deploy first
- user wants to debug a non-Worker process (Next.js dev server, etc.) → use shell_exec + iterate-until-green

## Example prompts

- `this Worker is returning 500 — debug it`
- `Worker exception 1101 in production`
- `the DO is throwing 'Cannot read property of undefined' under load`

## Inputs

- **worker_name**: wrangler.toml `name` field
- **error_signal**: URL that triggers it, or exception code

## Output

Root-cause analysis + the patch applied + post-fix verify result.

## Tools used

`shell_exec`, `shell_read`

## Execution template

Shell tools dispatch through `shell_exec` with the following command template:

```bash
wrangler tail {{worker_name}} & repro {{error_signal}}; follow debug-cf-worker/SKILL.md; instrument-then-fix if multi-layer
```

## Tags

`engineering`, `debug`, `cloudflare`

## Keywords

debug, worker, 1101, 1102, exception, cloudflare, DO, container, wrangler tail

