一键导入
debugging-error-tracking
Systematic debugging workflow for errors, performance issues, and runtime problems in the portfolio.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Systematic debugging workflow for errors, performance issues, and runtime problems in the portfolio.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Migrate from Next.js 15 to Next.js 16 and handle breaking changes
Configure Content Security Policy and security headers for the portfolio
Deploy Next.js to Cloudflare Workers using OpenNext adapter
Manage the canary token honeypot system for detecting security scanning
Write, debug, and optimize GROQ queries for Sanity CMS in this portfolio
Advanced TypeScript patterns and type safety as used in this portfolio
| name | debugging-error-tracking |
| description | Systematic debugging workflow for errors, performance issues, and runtime problems in the portfolio. |
Classify the error:
| Category | Examples | Priority |
|---|---|---|
| Build-time | TypeScript errors, lint failures, missing imports | Fix before commit |
| Runtime | Console errors, unhandled promises, null references | Fix before deploy |
| Hydration | Server/client HTML mismatch, useEffect missing | Fix before deploy |
| Network | API failures, CORS errors, timeout | Fix based on user impact |
| Performance | Slow LCP, high CLS, janky animations | Fix if regression |
| Browser-specific | Safari-only, mobile-only, Firefox-only | Fix if significant audience |
Step 1: Reproduce the error
Step 2: Read the error carefully
Step 3: Check common patterns
| Error pattern | Likely cause | Fix |
|---|---|---|
Cannot read property of undefined | Null data from API | Add null checks or ?? defaults |
Hydration mismatch | Server/client render difference | Add useEffect guard, mounted state |
Too many re-renders | State update in render | Move to useEffect or callback |
Invalid hook call | Conditional hook or wrong React | Ensure hooks are called unconditionally |
404 on _next/static | Stale service worker | Clear SW cache (see PWA skill) |
CORS error | Missing headers | Check API route CORS config |
Symptoms: Warning in console about hydration mismatch, content flickers on load.
Common causes:
Date/time rendering -- Server and client generate different strings
// BAD: server and client time differ
<span>{new Date().toLocaleDateString()}</span>
// GOOD: render only on client
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
<span>{mounted ? new Date().toLocaleDateString() : ''}</span>
Browser extensions -- Extensions inject elements into the DOM
Conditional rendering based on window/document
// BAD
<div>{typeof window !== 'undefined' ? 'client' : 'server'}</div>
// GOOD: use useEffect
const [isClient, setIsClient] = useState(false);
useEffect(() => setIsClient(true), []);
DevTools → Network tab:
Fetch/XHR to see API callsStatus column for failures (4xx, 5xx)Preview tab for error detailsResponse Headers for CORS issuesCommon network issues:
| Status | Meaning | Fix |
|---|---|---|
| 400 | Bad request | Check request body/params |
| 401 | Unauthorized | Check API token |
| 403 | Forbidden | Check permissions/CORS |
| 404 | Not found | Check the API route exists |
| 429 | Rate limited | Add retry logic, back off |
| 500 | Server error | Check server logs |
| CORS error | Missing Access-Control-Allow-Origin | Add CORS headers to API route |
Chrome DevTools → Performance tab:
Summary tab for breakdown (scripting, rendering, painting)React DevTools → Profiler:
Quick performance checks:
# Lighthouse audit
npx lighthouse http://localhost:3000 --output html --view
# Bundle size check
npm run build 2>&1 | grep -E "First Load|shared"
DevTools → Memory tab:
Common memory leak sources:
useEffect returnsetInterval not clearedChrome DevTools → Toggle Device Toolbar:
Remote debugging (real device):
chrome://inspect with USB debugging| Problem | First thing to check |
|---|---|
| Page is blank | Console errors, build errors |
| Data not loading | Network tab, API routes |
| Styling broken | Tailwind classes, dark mode toggle |
| Slow page | Performance tab, bundle size |
| Works on desktop, broken on mobile | Responsive breakpoints, touch events |
| Works in Chrome, broken in Safari | CSS features, JS compatibility |
| Intermittent error | Race conditions, async timing |