dev-debug
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "dev-debug" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-93c6d9c0af254f1aa91a77b7d84bf29d2411b1d6b544595844e9af497b6d50f0. Verify the upstream source and version against https://skillhub.cn/skills/user_a465771f/dev-debug before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Systematic debugging Skill for frontend deployments on cloud platforms. Used when production issues cannot be reproduced locally; applies systematic-debugging and ECC harness methodology to investigate and locate problems for Cloudflare Pages, Vercel, and Netlify deployments.
Introduction source: third_party · user_a465771f · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: cloud-debug
description: 云平台(Cloudflare Pages/Vercel/Netlify)前端部署问题系统化调试——当生产环境出现本地无法复现的bug时使用,综合 systematic-debugging + ECC harness 方法论
triggers:
- "生产环境崩了"
- "本地正常部署后报错"
- "Cloudflare Pages 有问题"
- "部署后页面崩溃"
- "生产环境独有的bug"
- "removeChild"
- "fetch 挂起"
- "页面崩溃"Cloud Deployment Debugging Skill
综合 superpowers/systematic-debugging + everything-claude-code-harness + Cloudflare Wrangler 的云平台专属调试框架
铁律
NO FIXES WITHOUT EVIDENCE FIRST
没有日志的猜测 = 浪费时间。每多一次盲目修复 = 引入新 bug。
适用场景
- Cloudflare Pages / Vercel / Netlify 部署后出现本地无法复现的 bug
- React/Vue SPA 在生产环境崩溃但 dev 正常
- fetch/XHR 在生产环境挂起(pending forever)
- DOM 冲突(
removeChild、insertBefore等) - 第三方平台注入脚本干扰
Phase 1: 武装取证 (Arm & Observe)
1.1 三级日志系统
// Level 1: localStorage 持久日志 — 崩溃不丢失
const LOG_KEY = 'debug_log'
const debugLog: string[] = JSON.parse(localStorage.getItem(LOG_KEY) || '[]')
function dlog(msg: string) {
debugLog.push(`[${new Date().toISOString().slice(11,19)}] ${msg}`)
localStorage.setItem(LOG_KEY, JSON.stringify(debugLog))
}
// Level 2: 全局异常捕获
window.onerror = (msg, src, line, col, err) => {
dlog(`GLOBAL: ${msg} at ${src}:${line}`)
}
window.onunhandledrejection = (e) => {
dlog(`REJECTION: ${e.reason?.message || e.reason}`)
}
// Level 3: ErrorBoundary 展示日志
class ErrorBoundary extends React.Component {
componentDidCatch(err) {
dlog(`CRASH: ${err.message}`)
dlog(`STACK: ${err.stack?.split('\n').slice(0,3).join(' | ')}`)
}
render() {
if (this.state.error) {
return <pre>{debugLog.join('\n')}</pre> // 崩溃页面直接展示日志
}
return this.props.children
}
}
1.2 关键代码路径埋点
在以下位置加 dlog():
- 所有
fetch()调用前后(URL、method、status) - 所有
setState/useState状态切换点 - 所有
useEffect执行点 - 路由导航点
1.3 多源证据采集
# 源1: Cloudflare Pages Function 日志
npx wrangler pages deployment tail <deploy-id> --project-name=<name>
# 源2: 直接 curl 测试服务端(排除客户端干扰)
curl -sv --max-time 10 -X POST "https://<domain>/api/..." -d '{...}'
# 源3: 本地生产构建对比
npm run build && npx vite preview # 或 npx serve dist/
# 源4: Cloudflare 安全设置检查
# Dashboard → Speed → Optimization(Auto Minify 关掉)
# Dashboard → Speed → Rocket Loader(关掉)
Phase 2: 二分隔离 (Binary Isolation)
2.1 先证明"不是我的问题"
1. 本地 npm run build + npx vite preview → 正常?
YES → 问题在 Cloudflare/部署层
NO → 问题在构建产物
2. curl 直接调 API → 返回正常?
YES → 问题在浏览器端(CORS/Bot Detection/脚本冲突)
NO → 问题在服务端/网络
3. 去掉异步调用,只做 UI 状态切换 → 正常?
YES → 问题在异步操作(fetch/await)
NO → 问题在 React 渲染本身
2.2 测试按钮法
在页面临时加一个"跳过所有异步、只做状态切换"的按钮:
<Button onClick={() => { setStep("next"); setMessage("test"); }}>
测试:直接跳转
</Button>
如果这个按钮正常工作,说明 React 渲染没问题,问题在异步操作。
2.3 替换调用目标
// 直接调 Supabase → 跨域,可能被 Cloudflare Bot Detection 拦截
fetch('https://xxx.supabase.co/auth/v1/otp', {...})
// 改为同源代理 → 绕过跨域和 Bot Detection
fetch('/api/auth/otp', {...}) // Pages Function 转发
Phase 3: 根因定位 (Root Cause)
3.1 常见根因速查表
| 症状 | 可能根因 | 验证方法 |
|---|---|---|
| fetch 挂起不返回 | Cloudflare Bot Detection 拦截跨域请求 | curl 同 URL 对比 |
removeChild 崩溃 |
Cloudflare 注入脚本与 React 冲突 | 关 Auto Minify/Rocket Loader |
| 生产 JS 语法错误 | Cloudflare 二次压缩破坏代码 | 关 Auto Minify |
| 页面白屏 | 静态资源 404 / SPA 路由未配置 | 检查 _redirects 文件 |
| 第三方 API 调不通 | CORS / CSP 头被 Cloudflare 修改 | 检查 Response Headers |
3.2 本次实战验证的根因
Cloudflare Pages 会在浏览器端注入 __cf_bm Bot Detection 脚本,操作 DOM 实现人机验证。React 的异步回调(.then())如果恰好在 Cloudflare 脚本操作 DOM 的同一帧触发,React 的 reconciler 会因 DOM 节点已不存在而抛出 removeChild 错误。
证据链:
- 本地生产构建正常(排除代码/构建问题)
- curl 调 Pages Function 返回 200(排除服务端问题)
- "直接跳转"按钮正常(排除 React 渲染问题)
await改为.then()无效(异步回调仍与 Cloudflare 脚本冲突)requestAnimationFrame推迟到下一帧 → 修复(确认是帧内冲突)
Phase 4: 最小修复 (Minimal Fix)
4.1 修复优先级
| 优先级 | 方案 | 适用场景 |
|---|---|---|
| 1 | requestAnimationFrame(() => setState(...)) |
DOM 冲突 |
| 2 | 同源 Pages Function 代理 | 跨域 fetch 被拦截 |
| 3 | 移除 StrictMode | React 18 生产环境问题 |
| 4 | 关 Cloudflare Auto Minify/Rocket Loader | JS 被破坏 |
| 5 | 纯 REST API 替代 SDK | SDK 注入 iframe/DOM 操作 |
4.2 修复纪律
- 一次只改一个变量
- 改完立即部署验证
- 3 次修复失败 → 回到 Phase 1 重新取证
- 3+ 次失败 → 质疑架构(不是继续修)
快速检查清单
部署到 Cloudflare Pages 之前:
- [ ]
dist/_redirects存在:/* /index.html 200 - [ ]
dist/_headers存在(如需 CSP) - [ ] Supabase URL Configuration 包含生产域名
- [ ] 生产
.env变量已设 - [ ] Cloudflare Speed → Auto Minify: OFF
- [ ] Cloudflare Speed → Rocket Loader: OFF
出现生产环境 bug 时:
- [ ] Phase 1: 加了 localStorage 日志 + ErrorBoundary
- [ ] Phase 1: curl 测试了 API 端点
- [ ] Phase 2: 加了"跳过异步"测试按钮
- [ ] Phase 2: 对比了本地生产构建 vs 云端部署
- [ ] Phase 3: 对照了常见根因速查表
- [ ] Phase 4: 单变量修复,一次一个
与 superpowers 协同
| superpowers skill | cloud-debug 中的角色 |
|---|---|
systematic-debugging |
四阶段流程骨架 |
writing-plans |
测试组计划编写 |
requesting-code-review |
修复后独立审查 |
test-driven-development |
修复前写失败测试 |
与 everything-claude-code-harness 协同
| ECC 能力 | cloud-debug 中的角色 |
|---|---|
security-scan |
检查生产环境密钥泄露 |
harness-audit |
审计部署配置完整性 |
hooks/PostEdit |
每次修改后自动跑 npm run build |
rules/typescript |
确保调试代码不影响类型安全 |
来源: Yuie 项目
yuie.cnCloudflare Pages 部署调试实战 验证日期: 2026-06-18 关键发现: Cloudflare Bot Detection 注入脚本与 React 异步回调 DOM 冲突 最小修复:requestAnimationFrame+ Pages Functions 同源代理
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决前端部署生产环境调试这一高频刚需痛点
- 覆盖Cloudflare/Vercel/Netlify三大主流云平台
- 提供systematic-debugging + ECC harness完整方法论
Highlights
- 触发词精准完整,覆盖多种变体
- 边界清晰,包含具体错误类型如removeChild、fetch挂起等
Highlights
- Phase/步骤清晰,有出口条件
- 含端到端示例,frontmatter完整
- 单文件≤500行,结构规范
Highlights
- 工具来源明确,参数正确
- 覆盖主要异常,不可逆操作有确认机制
- 提供快速检查清单确保执行可靠性
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 85, 91, 105 -
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 223
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- xxx.supabase.co
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.