[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74D4X6B1HG7C2Y2J8CQJXZX":3,"skill-same:01M74D4X6B1HG7C2Y2J8CQJXZX":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":34,"repositoryHtmlUrl":35,"repositoryHomepageUrl":36,"ownerHtmlUrl":37,"ownerBlogUrl":38,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M74D4X6B1HG7C2Y2J8CQJXZX","pages-function-checkpoint-debug",null,"When a Cloudflare Pages Function (or any Worker-style serverless handler) returns a generic 502\u002F500 hiding the actual error, instrument the handler with a `?debug=1` query param + an in-memory checkpoint array that accumulates step markers and gets returned in the response body. Lets you bisect \"which step crashed\" in 1-2 deploy\u002Fretest cycles instead of guessing for hours.","CarlosCaPe\u002Foctorato","CarlosCaPe","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F39838249?v=4","01M72WXX4ZRR8MBH1EP1QND2FQ","dataqbs","01M72WXX5NA7YCKRSJ54GW1GQ8",18,"MIT","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fpages-function-checkpoint-debug\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: pages-function-checkpoint-debug\ndescription: When a Cloudflare Pages Function (or any Worker-style serverless handler) returns a generic 502\u002F500 hiding the actual error, instrument the handler with a `?debug=1` query param + an in-memory checkpoint array that accumulates step markers and gets returned in the response body. Lets you bisect \"which step crashed\" in 1-2 deploy\u002Fretest cycles instead of guessing for hours.\nwhen_to_use: Cloudflare Pages Functions, Cloudflare Workers, AWS Lambda, GCP Cloud Functions, Vercel\u002FNetlify functions — any serverless handler whose runtime error stays inside the platform's edge layer and doesn't reach the caller. Especially when you can't easily attach a debugger (no `wrangler tail`, no Lambda log streaming, no Otel collector) and need a one-shot diagnostic.\ntriggers: [\"pages function 502\", \"worker crash debug\", \"serverless 500 hidden error\", \"checkpoint debug pattern\", \"where is my function crashing\"]\n---\n\n# Pages Function Checkpoint Debug\n\n## When this fires\n\nYou hit a Pages Function \u002F Worker. Auth path returns 401 cleanly. Post-auth\nflow returns a generic 502 \u002F 500 with body like `error code: 502` or\n`Internal Server Error` — no stack trace, no useful info. `wrangler tail`\neither isn't available (older Pages deploys) or your error isn't reaching it.\n\nYou need to know **which step is throwing**, fast.\n\n## The pattern\n\nThree pieces:\n\n### 1. Global try\u002Fcatch wrapper\n\nWrap your handler so any uncaught throw returns a JSON 500 with the message\n+ a truncated stack — never a CF edge 502. Without this, the platform layer\nintercepts the crash and serves its generic page.\n\n```ts\nexport const POST: APIRoute = async (ctx) => {\n  try {\n    return await runHandler(ctx);\n  } catch (err) {\n    const msg = (err as Error)?.message ?? String(err);\n    const stack = ((err as Error)?.stack ?? '').split('\\n').slice(0, 5).join(' | ');\n    return jsonResponse({ ok: false, error: 'uncaught', message: msg.slice(0, 400), stack: stack.slice(0, 600) }, 500, origin);\n  }\n};\nasync function runHandler(ctx) { \u002F* your real code *\u002F }\n```\n\n### 2. Checkpoint accumulator with `?debug=1`\n\nInside the handler, keep an array. Every meaningful step pushes a marker\nwith a timestamp + optional payload. When `?debug=1`, the marker payload\ngets included; otherwise it's just step names (cheap).\n\n```ts\nconst debug = new URL(request.url).searchParams.get('debug') === '1';\nconst checkpoints: Array\u003C{ step: string; ts: number; data?: any }> = [];\nconst step = (name: string, extra: any = {}) => {\n  checkpoints.push({ step: name, ts: Date.now(), data: debug ? extra : undefined });\n  return null;  \u002F\u002F never early-returns; diagnostics ride along\n};\n\nconst debugWrap = (resp: Response): Response => {\n  if (!debug) return resp;\n  return resp.text().then((t) => {\n    const parsed = (() => { try { return JSON.parse(t); } catch { return { rawBody: t }; } })();\n    parsed.checkpoints = checkpoints;\n    return new Response(JSON.stringify(parsed), { status: resp.status, headers: resp.headers });\n  }) as unknown as Response;\n};\n```\n\n### 3. Sprinkle steps + ONE early-return that you move forward\n\nAdd steps before AND after each suspect operation. Then add a single\n`if (debug) return debugWrap(...)` that you progressively move FORWARD\nthrough the handler each deploy until the response stops returning\n(\"crash before this checkpoint, so the bug is between the last successful\ncheckpoint and this one\").\n\n```ts\nstep('1-locked', { bucket });\nconst channels = await getAllChannels(kv, userId);\nstep('2-got-channels', { count: channels.length });\n\u002F\u002F ... more steps ...\nif (debug) return debugWrap(jsonResponse({ status: 'debug-stop-after-step-N', checkpoints }, 200, origin));\n\u002F\u002F suspicious code below — uncomment the return AT this checkpoint until you find the crash\n```\n\n## Workflow\n\n1. Deploy handler with global try\u002Fcatch + checkpoint array + ONE early-return after the first checkpoint.\n2. Trigger handler with `?debug=1`. Confirm response returns the checkpoint(s) you've reached. If it returns 502, the crash is BEFORE step 1 — bug is in module load OR the try\u002Fcatch itself.\n3. Move the early-return FORWARD by 1-2 steps. Redeploy. Re-trigger.\n4. Repeat step 3 until you cross a step where the response stops returning checkpoints. The crash is in the operation between the last successful checkpoint and the failed one.\n5. Inspect that operation. Fix.\n6. Remove `?debug=1` from any production trigger (workflow YAML, cron). Leave the checkpoint scaffold in code — it's harmless when `debug=0` (array isn't read).\n\n## When NOT to use\n\n- **`wrangler tail` works for you** — use that first. Tail gives you `console.log` output without redeploys. Checkpoints are for when tail is unavailable (Pages deploys without Functions metadata, restrictive IAM, etc.) or when you need the diag in the response body for a downstream caller.\n- **You can repro locally** — `wrangler pages dev` or `wrangler dev` gives you stack traces in the terminal. No need for in-band diagnostics.\n- **The error is reaching the caller** — if you already have a useful error message back from the function, this skill is overkill.\n\n## Calibration\n\nReal-case from 2026-05-19: hidden bug in a Pages Function caused 502s with no visibility.\n- 1 deploy: added try\u002Fcatch + 5 checkpoints. Got past step 5, crash after.\n- 2nd deploy: added 5 more checkpoints inside the suspect block. Found crash between step 8a (load item) and 8b (mirror photos). Inspected step 8b — saw the photo URLs were full paths, not filenames. Bug found in ~30 min total.\n\nWithout this pattern: would have been a 2-3 hour wrangler tail wrestle or a multi-day mystery.\n\n## Anti-patterns to refuse\n\n- **Adding 50 checkpoints up front.** Adds noise. Start with 5; bisect.\n- **Logging full request\u002Fresponse bodies into the checkpoint payload.** KV\u002Flog size limits matter; truncate to \u003C200 chars per data field.\n- **Leaving `?debug=1` in production triggers after the bug is fixed.** Costs cycles (the wrap reads the body to inject checkpoints).\n- **Returning 200 from a real failure just because `debug=1` is on.** Keep the actual HTTP code (502\u002F500) — only ADD the checkpoint payload.\n\n## Related\n\n- `dry-run-gate-pattern` — companion for safe testing of any side-effectful handler before going live\n- `cache-bust-deploy-validation` — verify your deploy actually shipped before assuming the bug is in the code (sometimes the bug is \"old code still served\")\n- `post-check-verification` — 3D Diligent: always verify behavior with evidence\n","# Pages Function Checkpoint Debug\n\n## When this fires\n\nYou hit a Pages Function \u002F Worker. Auth path returns 401 cleanly. Post-auth\nflow returns a generic 502 \u002F 500 with body like `error code: 502` or\n`Internal Server Error` — no stack trace, no useful info. `wrangler tail`\neither isn't available (older Pages deploys) or your error isn't reaching it.\n\nYou need to know **which step is throwing**, fast.\n\n## The pattern\n\nThree pieces:\n\n### 1. Global try\u002Fcatch wrapper\n\nWrap your handler so any uncaught throw returns a JSON 500 with the message\n+ a truncated stack — never a CF edge 502. Without this, the platform layer\nintercepts the crash and serves its generic page.\n\n```ts\nexport const POST: APIRoute = async (ctx) => {\n  try {\n    return await runHandler(ctx);\n  } catch (err) {\n    const msg = (err as Error)?.message ?? String(err);\n    const stack = ((err as Error)?.stack ?? '').split('\\n').slice(0, 5).join(' | ');\n    return jsonResponse({ ok: false, error: 'uncaught', message: msg.slice(0, 400), stack: stack.slice(0, 600) }, 500, origin);\n  }\n};\nasync function runHandler(ctx) { \u002F* your real code *\u002F }\n```\n\n### 2. Checkpoint accumulator with `?debug=1`\n\nInside the handler, keep an array. Every meaningful step pushes a marker\nwith a timestamp + optional payload. When `?debug=1`, the marker payload\ngets included; otherwise it's just step names (cheap).\n\n```ts\nconst debug = new URL(request.url).searchParams.get('debug') === '1';\nconst checkpoints: Array\u003C{ step: string; ts: number; data?: any }> = [];\nconst step = (name: string, extra: any = {}) => {\n  checkpoints.push({ step: name, ts: Date.now(), data: debug ? extra : undefined });\n  return null;  \u002F\u002F never early-returns; diagnostics ride along\n};\n\nconst debugWrap = (resp: Response): Response => {\n  if (!debug) return resp;\n  return resp.text().then((t) => {\n    const parsed = (() => { try { return JSON.parse(t); } catch { return { rawBody: t }; } })();\n    parsed.checkpoints = checkpoints;\n    return new Response(JSON.stringify(parsed), { status: resp.status, headers: resp.headers });\n  }) as unknown as Response;\n};\n```\n\n### 3. Sprinkle steps + ONE early-return that you move forward\n\nAdd steps before AND after each suspect operation. Then add a single\n`if (debug) return debugWrap(...)` that you progressively move FORWARD\nthrough the handler each deploy until the response stops returning\n(\"crash before this checkpoint, so the bug is between the last successful\ncheckpoint and this one\").\n\n```ts\nstep('1-locked', { bucket });\nconst channels = await getAllChannels(kv, userId);\nstep('2-got-channels', { count: channels.length });\n\u002F\u002F ... more steps ...\nif (debug) return debugWrap(jsonResponse({ status: 'debug-stop-after-step-N', checkpoints }, 200, origin));\n\u002F\u002F suspicious code below — uncomment the return AT this checkpoint until you find the crash\n```\n\n## Workflow\n\n1. Deploy handler with global try\u002Fcatch + checkpoint array + ONE early-return after the first checkpoint.\n2. Trigger handler with `?debug=1`. Confirm response returns the checkpoint(s) you've reached. If it returns 502, the crash is BEFORE step 1 — bug is in module load OR the try\u002Fcatch itself.\n3. Move the early-return FORWARD by 1-2 steps. Redeploy. Re-trigger.\n4. Repeat step 3 until you cross a step where the response stops returning checkpoints. The crash is in the operation between the last successful checkpoint and the failed one.\n5. Inspect that operation. Fix.\n6. Remove `?debug=1` from any production trigger (workflow YAML, cron). Leave the checkpoint scaffold in code — it's harmless when `debug=0` (array isn't read).\n\n## When NOT to use\n\n- **`wrangler tail` works for you** — use that first. Tail gives you `console.log` output without redeploys. Checkpoints are for when tail is unavailable (Pages deploys without Functions metadata, restrictive IAM, etc.) or when you need the diag in the response body for a downstream caller.\n- **You can repro locally** — `wrangler pages dev` or `wrangler dev` gives you stack traces in the terminal. No need for in-band diagnostics.\n- **The error is reaching the caller** — if you already have a useful error message back from the function, this skill is overkill.\n\n## Calibration\n\nReal-case from 2026-05-19: hidden bug in a Pages Function caused 502s with no visibility.\n- 1 deploy: added try\u002Fcatch + 5 checkpoints. Got past step 5, crash after.\n- 2nd deploy: added 5 more checkpoints inside the suspect block. Found crash between step 8a (load item) and 8b (mirror photos). Inspected step 8b — saw the photo URLs were full paths, not filenames. Bug found in ~30 min total.\n\nWithout this pattern: would have been a 2-3 hour wrangler tail wrestle or a multi-day mystery.\n\n## Anti-patterns to refuse\n\n- **Adding 50 checkpoints up front.** Adds noise. Start with 5; bisect.\n- **Logging full request\u002Fresponse bodies into the checkpoint payload.** KV\u002Flog size limits matter; truncate to \u003C200 chars per data field.\n- **Leaving `?debug=1` in production triggers after the bug is fixed.** Costs cycles (the wrap reads the body to inject checkpoints).\n- **Returning 200 from a real failure just because `debug=1` is on.** Keep the actual HTTP code (502\u002F500) — only ADD the checkpoint payload.\n\n## Related\n\n- `dry-run-gate-pattern` — companion for safe testing of any side-effectful handler before going live\n- `cache-bust-deploy-validation` — verify your deploy actually shipped before assuming the bug is in the code (sometimes the bug is \"old code still served\")\n- `post-check-verification` — 3D Diligent: always verify behavior with evidence\n",{"name":5,"triggers":24,"description":7,"when_to_use":30},[25,26,27,28,29],"pages function 502","worker crash debug","serverless 500 hidden error","checkpoint debug pattern","where is my function crashing","Cloudflare Pages Functions, Cloudflare Workers, AWS Lambda, GCP Cloud Functions, Vercel\u002FNetlify functions — any serverless handler whose runtime error stays inside the platform's edge layer and doesn't reach the caller. Especially when you can't easily attach a debugger (no `wrangler tail`, no Lambda log streaming, no Otel collector) and need a one-shot diagnostic.","master","b4414608cd5a3f87d1525b518f1c6add8363540d","skills\u002Fpages-function-checkpoint-debug",6,"https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato","https:\u002F\u002Fwww.dataqbs.com\u002Foctorato","https:\u002F\u002Fgithub.com\u002FCarlosCaPe","www.dataqbs.com"," AI-powered data engineering\r\n& consulting\r\n\r\nWe build data platforms that turn complexity into clarity — from cloud architecture and ETL pipelines to AI-driven","2026-11-14 00:21:00",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add CarlosCaPe\u002Foctorato --skill pages-function-checkpoint-debug",{"tool":47,"command":48},"bunx","bunx skills add CarlosCaPe\u002Foctorato --skill pages-function-checkpoint-debug",{"tool":50,"command":51},"pnpm","pnpm dlx skills add CarlosCaPe\u002Foctorato --skill pages-function-checkpoint-debug","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fpages-function-checkpoint-debug\u002FSKILL.md",true,[55],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"skill.json","REFERENCE","参考文档",507,"https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fpages-function-checkpoint-debug\u002Fskill.json",[62,71,79,86,94,102],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":66,"licenseFileUrl":67,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M74EVAA4A4B4AKR5TT732GP4","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":66,"licenseFileUrl":75,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M74EV4WMRDKP2NQS4YWR8PXH","wrangler","Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwrangler\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwrangler\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M74EV05MHTXKEXD4B2QJEYTF","workspace-skill-discovery","Discover and include ALL skills across the workspace — not just global ones. Use at the start of every session or when the user asks about available skills. Ensures project-level skills (under .claude\u002Fskills\u002F or skills\u002F in any repo) are never missed.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkspace-skill-discovery\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":66,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M74ETV78525B4VP2F28Z6NRD","workers-best-practices","Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkers-best-practices\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkers-best-practices\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":66,"licenseFileUrl":98,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M74ETR75NF67WGVEN7288ACV","winui-app","Create, build and design WinUI 3 desktop apps with C# and the Windows App SDK following Microsoft's official guidance and CommunityToolkit. Covers XAML, navigation, theming, accessibility and deployment.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwinui-app\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwinui-app\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":19},"01M74ETJFRNPPNSQZ36C6HD6CW","windows-brain-script-portability","Scripts in ~\u002F.claude\u002Fscripts\u002F that run on a Windows brain: use the python3.cmd shim and not bare python3, and reconfigure stdout to UTF-8 if you print symbols. Use it when writing a brain script or triaging a Windows-only crash.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwindows-brain-script-portability\u002FSKILL.md",[],[]]