Skip to content
cccskills
FreePublished on GitHub

debug

系統性 debug 工作流:捕捉錯誤、分析日誌、關聯跨系統 pattern,產出有根因與修復驗證的報告。適用於 bug、test 失敗、生產異常。

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md3.1 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Debug — 系統性除錯

觸發條件

  • 出現錯誤訊息或 stack trace
  • 測試失敗
  • 程式行為非預期
  • 生產環境出現異常(日誌分析、error spike)

除錯流程(6 步驟)

  1. Capture — 取得完整錯誤訊息、stack trace、重現步驟
  2. Isolate — 縮小故障範圍(模組、函式、時間點)
  3. Hypothesize — 形成 2-3 個可能根因假設
  4. Test — 用證據驗證假設(不要憑感覺猜)
  5. Fix — 實作最小修復(不要順手清理無關的程式碼)
  6. Verify — 確認修復有效,並排除引入新問題

快速診斷指令

# 查看最近哪些變更可能引起問題
git log --oneline -10
git diff HEAD~3

# 搜尋日誌中的錯誤模式
grep -rn "error\|Error\|ERROR" logs/ 2>/dev/null | tail -20

# 執行測試並捕捉輸出
npm test 2>&1 | tail -50       # Node.js
pytest -x --tb=short 2>&1      # Python
cargo test 2>&1 | tail -50     # Rust
go test ./... 2>&1             # Go

日誌分析

# 最近的錯誤與上下文
grep -B 5 -A 10 "ERROR" /var/log/app.log

# 統計錯誤類型頻率
grep -oE "Error: [^:]*" app.log | sort | uniq -c | sort -rn

# 某時段的錯誤
awk '/2026-04-18 14:/ && /ERROR/' app.log

# 找出高頻錯誤
grep "ERROR" app.log | cut -d']' -f2 | sort | uniq -c | sort -rn | head -20

# 錯誤 spike 分析
grep "ERROR" app.log | cut -d' ' -f1-2 | uniq -c | sort -rn

常見 Error Pattern

Pattern指向行動
NullPointer / undefined缺少 null check加入防衛性驗證
Timeout依賴服務慢加 timeout + retry
Connection refused服務未啟動檢查 health endpoint
OOM記憶體洩漏用 profiler 找洩漏點
Rate limit請求過多加 backoff + 佇列

跨系統關聯查詢(SQL)

-- 某 endpoint 的錯誤頻率
SELECT endpoint, count(*) as errors
FROM logs
WHERE level = 'ERROR' AND time > NOW() - INTERVAL '1 hour'
GROUP BY endpoint ORDER BY errors DESC;

-- 用 request_id 跨服務追蹤
SELECT service, message, time
FROM logs
WHERE request_id = 'req-xxxxx'
ORDER BY time;

輸出格式

## Debug Report

**Issue:** [一句話描述問題]
**Root Cause:** [實際根因]

### Evidence
- [找到的具體證據 1]
- [找到的具體證據 2]

### Fix
[程式碼或設定的最小修復]

### Verification
[如何確認修復有效:指令或測試]

### Prevention
[如何預防此問題再次發生]

Gotcha

  • 只做最小修復:debug 不是重構,不要順手改不相關的程式碼
  • 假設要有證據:每個假設必須由工具呼叫驗證,不憑直覺
  • 先跑相關測試:不要跑全套測試套件,先跑最相關的一個測試確認方向
  • 記錄 root cause:修完後把根因和修復方式寫進 commit message,有助於日後 retro 分析

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

建立符合官方規格的 Claude Code skill:蒐集需求、產出正確格式的 SKILL.md、驗證命名與描述規則、套用 Progressive Disclosure 結構。適合在新增 skill 或 slash command 時使用。

The English summary is being prepared. Showing the original description.

zeuikli/claude-code-workspace156Updated Oct 18, 2026

啟動 Agent Team 模式,多個 worker 平行處理任務並共享發現。適用於大型重構、codebase 遷移、全面審查。

The English summary is being prepared. Showing the original description.

zeuikli/claude-code-workspace156Updated Oct 18, 2026

分析 claude.com/blog 的新文章,提取可操作洞察並更新 workspace 設定。手動調用。

The English summary is being prepared. Showing the original description.

zeuikli/claude-code-workspace156Updated Oct 18, 2026

分析當前專案的 Claude Code session 資料,產出 context 效率報告(模型用量、工具效率、委派比例、TodoWrite 使用率)。搭配 context-management.md 使用。

The English summary is being prepared. Showing the original description.

zeuikli/claude-code-workspace156Updated Oct 18, 2026

追蹤並計算當前 session 的 Token 使用量和花費(USD)。產出前後對比報告,幫助使用者了解 workspace 優化的實際效益。

The English summary is being prepared. Showing the original description.

zeuikli/claude-code-workspace156Updated Oct 18, 2026

對 staged changes 執行三維度平行審查(安全、效能、風格),合成優先排序的發現摘要。

The English summary is being prepared. Showing the original description.

zeuikli/claude-code-workspace156Updated Oct 18, 2026

See all skills by zeuikli

Report a problem with this skill