skills/cognitive-load-assessment/SKILL.md
認知負擔評估與審查工具。作為決策樹、代理人、Code Review 的基本參考標準。用於: (1) 任務複雜度評估, (2) 代理人升級判斷, (3) 任務拆分建議, (4) 程式碼品質審查與熱點識別
npx skillsauth add tarrragon/claude cognitive-load-assessmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
所有程式碼設計原則的終極目標:降低閱讀者的認知負擔
認知負擔是指閱讀者在理解程式碼時需要同時記住的資訊量。當認知負擔超過人類工作記憶的容量(約 7 個項目),理解和維護程式碼就會變得困難。
| 指標 | 低複雜度 | 中複雜度 | 高複雜度(需拆分) | |------|---------|---------|------------------| | 變數狀態數 | 1-3 | 4-5 | > 5 | | 修改檔案數 | 1-3 | 4-5 | > 5 | | 架構層級數 | 1 | 2 | > 2 | | 依賴模組數 | 0-1 | 2-3 | > 3 | | 呼叫追蹤層 | 1-2 | 3 | > 3 |
| 指標 | 閾值 | 行動 | |------|------|------| | 需追蹤概念數 | > 7 | 升級到 PM | | 無法 5 分鐘理解 | 是 | 升級到 PM | | 跨 2+ 架構層 | 是 | 請求拆分或協作 |
| 條件 | 可並行 | 需序列 | |------|--------|--------| | 架構層級 | 同一層 | 跨層 | | 邏輯依賴 | 無 | 有 | | 操作類型 | 重命名/格式化 | 設計變更 |
每個變數都是閱讀者需要「記住」的項目:
| 情況 | 認知負擔 | 建議 | |------|---------|------| | 變數數 <= 3 | 低 | 維持 | | 變數數 4-5 | 中 | 考慮重構 | | 變數數 > 5 | 高 | 必須拆分 |
追蹤呼叫鏈需要「堆疊」記憶:
| 層級 | 認知負擔 | 建議 | |------|---------|------| | 1-2 層 | 低 | 維持 | | 3 層 | 中 | 考慮扁平化 | | > 3 層 | 高 | 必須重構 |
不佳的命名增加「翻譯」負擔:
| 問題 | 範例 | 解決 |
|------|------|------|
| 縮寫不明 | btn, mgr, idx | button, manager, index |
| 含義模糊 | data, info, value | 具體化:userData, bookInfo |
| 型別前綴 | strName, intCount | 直接用 name, count |
每個分支都是需要考慮的「路徑」:
| 分支數 | 認知負擔 | 建議 | |--------|---------|------| | 1-2 | 低 | 維持 | | 3-4 | 中 | 考慮策略模式 | | > 4 | 高 | 必須重構 |
一個函式只做一件事,讓讀者只需理解一個概念
檢查問題:「這個函式做了幾件事?」
名稱本身就是文件,讓讀者不需要額外資訊
檢查問題:「不看實作,能從名稱理解功能嗎?」
函式的行為應該可預測,讓讀者不需要追蹤隱藏狀態
檢查問題:「這個函式有沒有修改輸入以外的東西?」
減少巢狀,讓讀者不需要追蹤深層上下文
檢查問題:「最深的巢狀層級是多少?(應 <= 3)」
相關的資訊應該放在一起,讓讀者不需要跳轉尋找
檢查問題:「理解這段程式碼需要跳到幾個地方?」
Code Review 的目標不只是找出錯誤,更重要的是確保程式碼對未來的閱讀者友善。
| 維度 | 檢查問題 | |------|---------| | 變數狀態追蹤 | 這段程式碼需要閱讀者同時記住幾個變數的狀態? | | 呼叫層級追蹤 | 理解這段程式碼需要追蹤幾層呼叫? | | 命名品質 | 不看實作,能從名稱理解意圖嗎? | | 條件分支 | 需要考慮幾條執行路徑? | | 函式長度 | 這個函式做了幾件事? | | 參數數量 | 呼叫者需要記住幾個參數的順序和意義? |
| 熱點類型 | 識別方法 | 影響 | |---------|---------|------| | 長函式 | > 20 行 | 難以一次理解 | | 深巢狀 | > 3 層縮排 | 上下文難追蹤 | | 多參數 | > 3 個參數 | 呼叫時容易出錯 | | 副作用 | 修改外部狀態 | 行為不可預測 | | 隱藏依賴 | 內部 new 物件 | 難以測試和理解 |
# 審查單一檔案
/cognitive-load-assessment review {檔案路徑}
# 快速掃描目錄
/cognitive-load-assessment scan {目錄}
詳細報告模板:references/review-report-template.md
常見問題模式:references/common-review-patterns.md
| 方法論 | 認知負擔視角 | |--------|-------------| | DRY | 減少重複 = 減少需要記憶的版本 | | SOLID | 每個原則都在降低特定類型的認知負擔 | | Clean Code | 可讀性 = 低認知負擔 | | 自然語言程式設計 | 讓程式碼像閱讀文章一樣自然 |
/cognitive-load-assessment assess-task "{任務描述}"
/cognitive-load-assessment assess-code {檔案路徑}
Last Updated: 2026-03-02 Version: 2.0.0 - 合併 cognitive-load-review,新增 Code Review 模式和 references/
development
Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks.
development
Claude Code release notes 框架影響評估工具。比對 last-reviewed 版本篩出新版本,逐項分類(對框架有幫助 / 需評估 / 無影響 / 不適用),對採用項引導建 ANA + WRAP + spawn 落地。Use when: 執行 /release-notes 看到新版本、定期檢查 CC 更新、評估新功能對專案框架的影響時。Triggers: release notes, release-notes, CC 更新, claude code 更新, 版本更新評估, 新功能評估, 框架影響評估。
development
Assertion design judgment framework for flaky and design-quality issues. Use when writing tests, reviewing assertions, diagnosing flaky tests, or deciding if a timing/float/cache assertion is appropriate. Do NOT use for API syntax or refactoring.
tools
Chrome Extension 實機測試與 debug 工作流,以 chrome-devtools-mcp 為核心工具。Use when: (1) 完成功能後實機驗證 / manual test / 試看看 / 跑看看 / verify feature, (2) extension debug / popup 不作動 / content script 不注入 / service worker 報錯 / background 出問題, (3) 安裝 unpacked extension / load unpacked / 載入未封裝, (4) 看 console / 看 network / 看 log / view console / inspect requests, (5) 功能更新後重新載入 extension / rebuild reload / reload extension。涵蓋 Manifest V3 service worker / content script / popup / options page 的 chrome-devtools-mcp 工具呼叫流程。不取代 Puppeteer / Playwright 自動化 E2E(CI 用),定位為開發期手動驗證與 LLM-assisted debug。