Community程式設計與開發github.com

alfathafp/portofolio-web-design

在遇到任何錯誤、測試失敗或意外行為時使用,在提出修復方案之前先進行系統性除錯。

portofolio-web-design 是什麼?

本技能(alfathafp/portofolio-web-design)的核心是強制執行一套嚴格的**系統性除錯流程**,確保開發者在提出任何修復方案之前,**必須先找到根本原因**。它適用於所有技術問題,包括測試失敗、生產環境錯誤、效能問題、建置失敗等。此流程分為四個階段:根本原因調查(必須先徹底解析錯誤訊息、重現問題、檢查近期變更,並在多元件系統中透過診斷儀器找出故障層)、模式分析(比較正常與異常的程式碼範例以找出差異)、假設與測試(以科學方法逐一驗證),最後才是實作修復(先建立失敗測試案例,再進行單一變更,並用驗證工具確認)。如果連續三次修復都失敗,流程會要求開發者停下來重新質疑架構設計,而非繼續猜測。這項技能可搭配 Claude Code、Cursor、Codex 等工具使用,能有效避免常見的「猜測式除錯」陷阱,大幅提高問題解決的效率與品質。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/systematic-debugging

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

系統性除錯

概述

核心原則: 在嘗試任何修復之前,永遠先找出根本原因。僅處理症狀的修復就是失敗。

背離此流程的文字,就是違背除錯的精神。

鐵律

未經根本原因調查,不得提出修復方案

如果你尚未完成第一階段,就不能提議任何修復。

使用時機

用於任何技術問題:

  • 測試失敗
  • 生產環境中的錯誤
  • 意外行為
  • 效能問題
  • 建置失敗
  • 整合問題

特別在以下情況使用此流程:

  • 時間緊迫(緊急狀況容易讓人想猜測)
  • 看似「只要快速修一個就好」
  • 你已經嘗試過多次修復
  • 先前的修復無效
  • 你尚未完全理解問題所在

不要跳過此流程的情況:

  • 問題看似簡單(簡單的錯誤也有根本原因)
  • 你很趕時間(匆忙保證會導致重工)
  • 主管要求立即修復(系統性方法比胡亂猜測更快)

四個階段

你必須在進行下一階段之前,先完成當前階段的每一個步驟。

第一階段:根本原因調查

在嘗試任何修復之前:

  1. 仔細閱讀錯誤訊息

    • 不要跳過錯誤或警告
    • 它們通常包含確切的解決方案
    • 完整閱讀堆疊追蹤
    • 注意行號、檔案路徑、錯誤代碼
  2. 一致性重現問題

    • 你能可靠地觸發它嗎?
    • 確切的步驟為何?
    • 每次都會發生嗎?
    • 如果無法重現 → 收集更多資料,不要猜測
  3. 檢查近期變更

    • 什麼變更可能導致這個問題?
    • Git diff、最近的提交
    • 新的相依套件、設定變更
    • 環境差異
  4. 在多元件系統中收集證據

    當系統包含多個元件時(CI → 建置 → 簽署、API → 服務 → 資料庫):

    在提出修復方案之前,加入診斷儀器:

    對於每個元件邊界:
      - 記錄進入元件的資料
      - 記錄離開元件的資料
      - 驗證環境/設定傳播
      - 檢查每個層的狀態
    
    執行一次以收集證據,顯示問題在哪裡中斷
    然後分析證據以找出故障的元件
    接著調查該特定元件
    

    範例(多層系統):

    # 第 1 層:工作流程
    echo "=== 工作流程中可用的密鑰:==="
    echo "IDENTITY: $([ -n "${IDENTITY:-}" ] && echo 已設定 || echo 未設定)"
    
    # 第 2 層:建置腳本
    echo "=== 建置腳本中的環境變數:==="
    printenv IDENTITY >/dev/null 2>&1 && echo "IDENTITY 存在於環境中" || echo "IDENTITY 不存在於環境中"
    
    # 第 3 層:簽署腳本
    echo "=== 鑰匙圈狀態:==="
    security list-keychains
    security find-identity -v
    
    # 第 4 層:實際簽署
    codesign --sign "$IDENTITY" --verbose=4 "$APP"
    

    這會揭示: 哪一層失敗(密鑰 → 工作流程 ✓,工作流程 → 建置 ✗)

  5. 追蹤資料流

    當錯誤出現在深層呼叫堆疊時:

    請參閱此目錄中的 root-cause-tracing.md 以獲取完整的反向追蹤技術。

    快速版本:

    • 錯誤值從何處產生?
    • 是誰用錯誤的值呼叫了這個?
    • 持續往上追蹤,直到找到根源
    • 在根源處修復,而不是在症狀處

第二階段:模式分析

在修復之前先找出模式:

  1. 尋找運作中的範例

    • 在同一個程式碼庫中找到類似的運作中程式碼
    • 有什麼運作中的東西與損壞的東西相似?
  2. 對照參考資料進行比較

    • 如果是在實作某個模式,請完整閱讀參考實作
    • 不要略讀——閱讀每一行
    • 在套用之前充分理解該模式
  3. 找出差異

    • 運作中的程式碼與損壞的程式碼有什麼不同?
    • 列出每一個差異,無論多麼微小
    • 不要假設「那個不可能有影響」
  4. 理解相依關係

    • 這需要哪些其他元件?
    • 需要什麼設定、配置、環境?
    • 它做了哪些假設?

第三階段:假設與測試

科學方法:

  1. 形成單一假設

    • 清楚地陳述:「我認為 X 是根本原因,因為 Y」
    • 寫下來
    • 要具體,不要模糊
  2. 最小化測試

    • 做最小的變更來測試假設
    • 一次只改變一個變數
    • 不要同時修復多個東西
  3. 驗證後再繼續

    • 有效嗎?是 → 第四階段
    • 無效?形成新的假設
    • 不要在上面疊加更多修復
  4. 當你不知道時

    • 說「我不理解 X」
    • 不要假裝知道
    • 尋求幫助
    • 進行更多研究

第四階段:實作

修復根本原因,而不是症狀:

  1. 建立會失敗的測試案例

    • 最簡單的重現方式
    • 如果可能的話,用自動化測試
    • 如果沒有測試框架,用一次性測試腳本
    • 必須在修復之前擁有
    • 使用 superpowers:test-driven-development 技能來撰寫正確的失敗測試
  2. 實作單一修復

    • 處理已識別的根本原因
    • 一次一個變更
    • 不要「順便」進行改善
    • 不要捆綁重構
  3. 驗證修復

    • 測試現在通過了嗎?
    • 沒有其他測試被破壞嗎?
    • 問題是否確實解決了?
    • 在聲稱成功之前,請使用 superpowers:verification-before-completion 技能
  4. 如果修復無效

    • 停止
    • 計數:你嘗試了幾次修復?
    • 如果 < 3:回到第一階段,用新資訊重新分析
    • 如果 ≥ 3:停止並質疑架構(見下方的步驟 5)
    • 未經架構討論,不要嘗試第四次修復
  5. 如果 3 次以上修復失敗:質疑架構

    表示架構問題的模式:

    • 每次修復都揭示了不同位置的新共享狀態/耦合/問題
    • 修復需要「大規模重構」才能實作
    • 每次修復都會在其他地方產生新的症狀

    停下來質疑基本原則:

    • 這個模式從根本上來說合理嗎?
    • 我們是否「只是出於慣性而堅持它」?
    • 我們應該重構架構,還是繼續修復症狀?

    在嘗試更多修復之前,請與你的人類夥伴討論

    這不是失敗的假設——這是錯誤的架構。

紅旗警示——停下來並遵循流程

如果你發現自己正在想:

  • 「先快速修一下,之後再調查」
  • 「先改 X 試試看,看能不能運作」
  • 「同時做多個變更,然後執行測試」
  • 「跳過測試,我手動驗證就好」
  • 「大概是 X 的問題,我來修一下」
  • 「我不完全理解,但這可能有效」
  • 「模式說要用 X,但我會用不同的方式調整」
  • 「主要的問題如下:[列出修復方案,沒有經過調查]」
  • 「在追蹤資料流之前就提出解決方案」
  • 「再嘗試一次修復」(當你已經試過 2+ 次時)
  • 「每次修復都在不同的地方揭示新問題」

所有這些都意味著:停止。回到第一階段。

如果 3 次以上修復失敗: 質疑架構(請參閱第四階段的第 5 點)

你的人類夥伴表示你做錯了的信號

請留意這些重新導向:

  • 「那不是沒發生嗎?」——你在沒有驗證的情況下就假設了
  • 「它會顯示給我們看嗎...?」——你應該要收集證據的
  • 「別再猜了」——你在沒有理解的情況下就提議修復
  • 「好好思考這個問題」——質疑基本原則,而不僅僅是症狀
  • 「我們卡住了嗎?」(感到沮喪)——你的方法行不通

當你看到這些時: 停止。回到第一階段。

常見的合理化藉口

藉口現實
「問題很簡單,不需要流程」簡單的問題也有根本原因。流程對簡單的錯誤來說很快。
「緊急狀況,沒時間走流程」系統性除錯比胡亂猜測更快。
「先試試這個,之後再調查」第一次修復定了模式。從一開始就要做對。
「我會在確認修復有效後再寫測試」未經測試的修復無法持久。先測試才能證明。
「同時做多個修復可以節省時間」無法隔離哪個有效。還會引入新錯誤。
「參考資料太長,我會調整模式」部分理解保證會產生錯誤。請完整閱讀。
「我看到問題了,讓我來修」看到症狀 ≠ 理解根本原因。
「再嘗試一次修復」(在 2 次以上失敗後)3+ 次失敗 = 架構問題。質疑模式,而不是繼續修復。

快速參考

階段關鍵活動成功標準
1. 根本原因讀取錯誤、重現問題、檢查變更、收集證據理解「什麼」和「為什麼」
2. 模式尋找運作中的範例、進行比較找出差異
3. 假設形成理論、最小化測試證實或形成新的假設
4. 實作建立測試、修復、驗證錯誤解決、測試通過

當流程揭示「沒有根本原因」

如果系統性調查顯示問題確實是環境相關、時間依賴性或外部因素:

  1. 你已完成流程
  2. 記錄你調查了什麼
  3. 實作適當的處理方式(重試、超時、錯誤訊息)
  4. 加入監控/日誌記錄以供未來調查

但是: 95% 的「沒有根本原因」案例都是調查不完整。

輔助技術

這些技術是系統性除錯的一部分,可在本目錄中找到:

  • root-cause-tracing.md - 透過呼叫堆疊向後追蹤錯誤,找出原始觸發點
  • defense-in-depth.md - 在找到根本原因後,在多個層級加入驗證
  • condition-based-waiting.md - 用條件輪詢取代任意超時

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

相關技能