[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-6159e2bd-d037-4fab-b6ac-002da515e7fd":3,"$fDTHJ3IuNwCMk_KozltXefS5LilIoCPT8kmHx5PvOCTE":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"6159e2bd-d037-4fab-b6ac-002da515e7fd","bug-hunter","系统地使用经过验证的调试技术查找和修复错误。从症状追踪到根本原因，实施修复并防止回归。","cat_life_career","mod_other","sickn33,other","---\nname: bug-hunter\ndescription: \"Systematically finds and fixes bugs using proven debugging techniques. Traces from symptoms to root cause, implements fixes, and prevents regression.\"\ncategory: development\nrisk: safe\nsource: community\ndate_added: \"2026-03-05\"\n---\n\n# Bug Hunter\n\nSystematically hunt down and fix bugs using proven debugging techniques. No guessing—follow the evidence.\n\n## When to Use This Skill\n\n- User reports a bug or error\n- Something isn't working as expected\n- User says \"fix the bug\" or \"debug this\"\n- Intermittent failures or weird behavior\n- Production issues need investigation\n\n## The Debugging Process\n\n### 1. Reproduce the Bug\n\nFirst, make it happen consistently:\n\n```\n1. Get exact steps to reproduce\n2. Try to reproduce locally\n3. Note what triggers it\n4. Document the error message\u002Fbehavior\n5. Check if it happens every time or randomly\n```\n\nIf you can't reproduce it, gather more info:\n- What environment? (dev, staging, prod)\n- What browser\u002Fdevice?\n- What user actions preceded it?\n- Any error logs?\n\n### 2. Gather Evidence\n\nCollect all available information:\n\n**Check logs:**\n```bash\n# Application logs\ntail -f logs\u002Fapp.log\n\n# System logs\njournalctl -u myapp -f\n\n# Browser console\n# Open DevTools → Console tab\n```\n\n**Check error messages:**\n- Full stack trace\n- Error type and message\n- Line numbers\n- Timestamp\n\n**Check state:**\n- What data was being processed?\n- What was the user trying to do?\n- What's in the database?\n- What's in local storage\u002Fcookies?\n\n### 3. Form a Hypothesis\n\nBased on evidence, guess what's wrong:\n\n```\n\"The login times out because the session cookie \nexpires before the auth check completes\"\n\n\"The form fails because email validation regex \ndoesn't handle plus signs\"\n\n\"The API returns 500 because the database query \nhas a syntax error with special characters\"\n```\n\n### 4. Test the Hypothesis\n\nProve or disprove your guess:\n\n**Add logging:**\n```javascript\nconsole.log('Before API call:', userData);\nconst response = await api.login(userData);\nconsole.log('After API call:', response);\n```\n\n**Use debugger:**\n```javascript\ndebugger; \u002F\u002F Execution pauses here\nconst result = processData(input);\n```\n\n**Isolate the problem:**\n```javascript\n\u002F\u002F Comment out code to narrow down\n\u002F\u002F const result = complexFunction();\nconst result = { mock: 'data' }; \u002F\u002F Use mock data\n```\n\n### 5. Find Root Cause\n\nTrace back to the actual problem:\n\n**Common root causes:**\n- Null\u002Fundefined values\n- Wrong data types\n- Race conditions\n- Missing error handling\n- Incorrect logic\n- Off-by-one errors\n- Async\u002Fawait issues\n- Missing validation\n\n**Example trace:**\n```\nSymptom: \"Cannot read property 'name' of undefined\"\n↓\nWhere: user.profile.name\n↓\nWhy: user.profile is undefined\n↓\nWhy: API didn't return profile\n↓\nWhy: User ID was null\n↓\nRoot cause: Login didn't set user ID in session\n```\n\n### 6. Implement Fix\n\nFix the root cause, not the symptom:\n\n**Bad fix (symptom):**\n```javascript\n\u002F\u002F Just hide the error\nconst name = user?.profile?.name || 'Unknown';\n```\n\n**Good fix (root cause):**\n```javascript\n\u002F\u002F Ensure user ID is set on login\nconst login = async (credentials) => {\n  const user = await authenticate(credentials);\n  if (user) {\n    session.userId = user.id; \u002F\u002F Fix: Set user ID\n    return user;\n  }\n  throw new Error('Invalid credentials');\n};\n```\n\n### 7. Test the Fix\n\nVerify it actually works:\n\n```\n1. Reproduce the original bug\n2. Apply the fix\n3. Try to reproduce again (should fail)\n4. Test edge cases\n5. Test related functionality\n6. Run existing tests\n```\n\n### 8. Prevent Regression\n\nAdd a test so it doesn't come back:\n\n```javascript\ntest('login sets user ID in session', async () => {\n  const user = await login({ email: 'test@example.com', password: 'pass' });\n  \n  expect(session.userId).toBe(user.id);\n  expect(session.userId).not.toBeNull();\n});\n```\n\n## Debugging Techniques\n\n### Binary Search\n\nCut the problem space in half repeatedly:\n\n```javascript\n\u002F\u002F Does the bug happen before or after this line?\nconsole.log('CHECKPOINT 1');\n\u002F\u002F ... code ...\nconsole.log('CHECKPOINT 2');\n\u002F\u002F ... code ...\nconsole.log('CHECKPOINT 3');\n```\n\n### Rubber Duck Debugging\n\nExplain the code line by line out loud. Often you'll spot the issue while explaining.\n\n### Print Debugging\n\nStrategic console.logs:\n\n```javascript\nconsole.log('Input:', input);\nconsole.log('After transform:', transformed);\nconsole.log('Before save:', data);\nconsole.log('Result:', result);\n```\n\n### Diff Debugging\n\nCompare working vs broken:\n- What changed recently?\n- What's different between environments?\n- What's different in the data?\n\n### Time Travel Debugging\n\nUse git to find when it broke:\n\n```bash\ngit bisect start\ngit bisect bad  # Current commit is broken\ngit bisect good abc123  # This old commit worked\n# Git will check out commits for you to test\n```\n\n## Common Bug Patterns\n\n### Null\u002FUndefined\n\n```javascript\n\u002F\u002F Bug\nconst name = user.profile.name;\n\n\u002F\u002F Fix\nconst name = user?.profile?.name || 'Unknown';\n\n\u002F\u002F Better fix\nif (!user || !user.profile) {\n  throw new Error('User profile required');\n}\nconst name = user.profile.name;\n```\n\n### Race Condition\n\n```javascript\n\u002F\u002F Bug\nlet data = null;\nfetchData().then(result => data = result);\nconsole.log(data); \u002F\u002F null - not loaded yet\n\n\u002F\u002F Fix\nconst data = await fetchData();\nconsole.log(data); \u002F\u002F correct value\n```\n\n### Off-by-One\n\n```javascript\n\u002F\u002F Bug\nfor (let i = 0; i \u003C= array.length; i++) {\n  console.log(array[i]); \u002F\u002F undefined on last iteration\n}\n\n\u002F\u002F Fix\nfor (let i = 0; i \u003C array.length; i++) {\n  console.log(array[i]);\n}\n```\n\n### Type Coercion\n\n```javascript\n\u002F\u002F Bug\nif (count == 0) { \u002F\u002F true for \"\", [], null\n  \n\u002F\u002F Fix\nif (count === 0) { \u002F\u002F only true for 0\n```\n\n### Async Without Await\n\n```javascript\n\u002F\u002F Bug\nconst result = asyncFunction(); \u002F\u002F Returns Promise\nconsole.log(result.data); \u002F\u002F undefined\n\n\u002F\u002F Fix\nconst result = await asyncFunction();\nconsole.log(result.data); \u002F\u002F correct value\n```\n\n## Debugging Tools\n\n### Browser DevTools\n\n```\nConsole: View logs and errors\nSources: Set breakpoints, step through code\nNetwork: Check API calls and responses\nApplication: View cookies, storage, cache\nPerformance: Find slow operations\n```\n\n### Node.js Debugging\n\n```javascript\n\u002F\u002F Built-in debugger\nnode --inspect app.js\n\n\u002F\u002F Then open chrome:\u002F\u002Finspect in Chrome\n```\n\n### VS Code Debugging\n\n```json\n\u002F\u002F .vscode\u002Flaunch.json\n{\n  \"type\": \"node\",\n  \"request\": \"launch\",\n  \"name\": \"Debug App\",\n  \"program\": \"${workspaceFolder}\u002Fapp.js\"\n}\n```\n\n## When You're Stuck\n\n1. Take a break (seriously, walk away for 10 minutes)\n2. Explain it to someone else (or a rubber duck)\n3. Search for the exact error message\n4. Check if it's a known issue (GitHub issues, Stack Overflow)\n5. Simplify: Create minimal reproduction\n6. Start over: Delete and rewrite the problematic code\n7. Ask for help (provide context, what you've tried)\n\n## Documentation Template\n\nAfter fixing, document it:\n\n```markdown\n## Bug: Login timeout after 30 seconds\n\n**Symptom:** Users get logged out immediately after login\n\n**Root Cause:** Session cookie expires before auth check completes\n\n**Fix:** Increased session timeout from 30s to 3600s in config\n\n**Files Changed:**\n- config\u002Fsession.js (line 12)\n\n**Testing:** Verified login persists for 1 hour\n\n**Prevention:** Added test for session persistence\n```\n\n## Key Principles\n\n- Reproduce first, fix second\n- Follow the evidence, don't guess\n- Fix root cause, not symptoms\n- Test the fix thoroughly\n- Add tests to prevent regression\n- Document what you learned\n\n## Related Skills\n\n- `@systematic-debugging` - Advanced debugging\n- `@test-driven-development` - Testing\n- `@codebase-audit-pre-push` - Code review\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,211,759,"2026-05-16 13:09:28",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"其他","other","mdi-page-next-outline","其他类型Skill",5,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"职场发展","career","mdi-briefcase-outline","面试准备、简历优化、职业规划",4,575,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"fff5153a-cdf2-45d2-98db-46dcc84ebd9e","1.0.0","bug-hunter.zip",3978,"uploads\u002Fskills\u002F6159e2bd-d037-4fab-b6ac-002da515e7fd\u002Fbug-hunter.zip","42c8948fa6ddde4e8a2d02c2f5092369889eafb5137d295bf5b6a192c3504db8","[{\"path\":\"README.md\",\"isDirectory\":false,\"size\":375},{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":7916}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]