Communitygithub.com

alfathafp/portofolio-web-design

當建立新技能、編輯現有技能或驗證技能在部署前能正常運作時使用

portofolio-web-design 是什麼?

此技能將測試驅動開發 (TDD) 原則應用於 AI 代理的技能文件編寫流程。它強制要求遵循「紅-綠-重構」循環:首先建立壓力測試場景並觀察代理在沒有技能時的失敗行為(紅),然後撰寫技能文件(綠),最後透過修補漏洞來重構。該技能支援 Claude Code、Codex、Copilot CLI 和 Gemini CLI 等多個執行環境,並可透過 `~/.claude/skills/` 或 `~/.agents/skills/` 等目錄進行安裝。它詳細說明了技能格式(包含 YAML 前置元和 Markdown 主體)、描述欄位的撰寫要點(僅描述觸發條件而非工作流程),以及詞彙覆蓋率與命名最佳化等技能探索優化 (SDO) 技巧。核心原則是:若未先觀察代理在沒有技能時失敗,就無法確定技能是否傳授了正確的知識。

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

在你喜歡的 AI 中提問

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

說明文件

撰寫技能

概述

撰寫技能是將測試驅動開發應用於流程文件化。

個人技能存放在您的執行環境的技能目錄中(Claude Code 為 ~/.claude/skills/)— 其他執行環境的路徑請參閱 codex-tools.md 或 gemini-tools.md。Codex、Copilot CLI 和 Gemini CLI 也都能辨識 ~/.agents/skills/ 作為跨執行環境的別名。

您需要撰寫測試案例(包含子代理的壓力情境),觀察它們失敗(基準行為),撰寫技能(文件),觀察測試通過(代理遵循指示),然後重構(封閉漏洞)。

核心原則: 如果您沒有觀察過代理在沒有技能的情況下失敗,您就無法知道這個技能是否教對了東西。

必要背景: 您必須先理解 superpowers:test-driven-development 才能使用此技能。該技能定義了基本的紅-綠-重構循環。此技能則將 TDD 應用於文件化。

官方指南: 關於 Anthropic 官方的技能編寫最佳實務,請參閱 anthropic-best-practices.md。本文件提供了補充該 TDD 聚焦方法的額外模式與指南。

什麼是技能?

技能是針對已驗證技術、模式或工具的參考指南。技能有助於未來的代理找到並應用有效的方法。

技能是: 可重複使用的技術、模式、工具、參考指南

技能不是: 關於您過去如何解決某個問題的敘述故事

技能的 TDD 映射

TDD 概念技能建立
測試案例包含子代理的壓力情境
生產代碼技能文件 (SKILL.md)
測試失敗 (紅)代理在無技能情況下違反規則(基準)
測試通過 (綠)代理在有技能時遵循指示
重構在維持遵循度的同時封閉漏洞
先寫測試在撰寫技能之前先執行基準情境
觀察它失敗記錄代理使用的確切合理化說詞
最小代碼撰寫僅針對這些特定違規的技能
觀察它通過驗證代理現在遵循指示
重構循環發現新的合理化說詞 → 修補 → 重新驗證

整個技能建立流程遵循紅-綠-重構。

何時建立技能

建立時機:

  • 該技術對您而言並非直觀易懂
  • 您可能會在跨專案時再次參考此技術
  • 模式廣泛適用(非專案特定)
  • 其他人會因此受益

不要為以下情況建立:

  • 一次性解決方案
  • 已在其他地方有完善文件說明的標準做法
  • 專案特定的慣例(請放入您的指令檔案)
  • 機械性限制(如果可以透過正規表達式/驗證來強制執行,就自動化它—將文件留給需要判斷的場合)

技能類型

技術

具有可遵循步驟的具體方法(條件式等待、根本原因追蹤)

模式

解決問題的思考方式(用旗標扁平化、測試不變量)

參考

API 文件、語法指南、工具文件(辦公室文件)

目錄結構

skills/
  技能名稱/
    SKILL.md              # 主要參考(必要)
    支援檔案.*             # 僅在需要時使用

扁平命名空間 - 所有技能放在一個可搜尋的扁平命名空間中

獨立檔案用於:

  1. 大量參考(100 行以上)- API 文件、全面語法
  2. 可重複使用的工具 - 腳本、公用程式、範本

保留內嵌:

  • 原則與概念
  • 程式碼模式(少於 50 行)
  • 其他所有內容

SKILL.md 結構

前置元件 (YAML):

  • 兩個必要欄位:name 和 description(所有支援的欄位請參閱 agentskills.io/specification)
  • 總長度最多 1024 個字元
  • name:僅使用字母、數字和連字號(無括號、特殊字元)
  • description:使用第三人稱,僅描述何時使用(非技能功能)
    • 以「Use when...」開頭,聚焦於觸發條件
    • 包含特定的症狀、情境和上下文
    • 絕對不要總結技能的流程或工作流程(原因請參閱 SDO 章節)
    • 盡可能保持在 500 字元以下
---
名稱: 含連字號的技能名稱
description: 當 [特定的觸發條件和症狀] 時使用
---

# 技能名稱

## 概述
這是什麼?用 1-2 句說明核心原則。

## 何時使用
[如果決策非顯而易見,使用小型內嵌流程圖]

包含症狀和使用案例的項目符號清單
何時不使用

## 核心模式(適用於技術/模式)
改造前/改造後的程式碼比較

## 快速參考
用於掃描常見操作的表格或項目符號

## 實作
對於簡單模式,內嵌程式碼
對於大量參考或可重複使用的工具,連結到檔案

## 常見錯誤
出錯的原因 + 修正方式

## 實際影響(可選)
具體成果

技能探索最佳化 (SDO)

對於探索至關重要: 未來的代理需要能夠找到您的技能

1. 豐富的描述欄位

目的: 您的代理會讀取描述來決定為某項任務載入哪些技能。讓它能回答:「我現在應該閱讀這個技能嗎?」

格式: 以「Use when...」開頭,聚焦於觸發條件

關鍵:描述 = 何時使用,非技能功能

描述應僅描述觸發條件。請勿在描述中總結技能的流程或工作流程。

為何重要: 測試發現,當描述總結了技能的工作流程時,代理可能會遵循描述而不是閱讀完整的技能內容。一個描述為「在任務之間進行程式碼審查」的技能,導致代理只進行了一次審查,即使該技能的流程圖清楚地顯示了兩次審查(先規格符合性,再程式碼品質)。

當描述改為「當執行包含獨立任務的實作計畫時使用」(無工作流程摘要),代理正確地閱讀了流程圖並遵循了兩階段的審查流程。

陷阱: 總結工作流程的描述會為代理創建一個捷徑,導致技能本體成為代理跳過的文件。

# ❌ 錯誤:總結工作流程 - 代理可能遵循此描述而非閱讀技能
description: 當執行計畫時使用 - 在任務之間透過子代理分配並進行程式碼審查

# ❌ 錯誤:過多流程細節
description: 用於 TDD - 先寫測試,觀察它失敗,撰寫最小代碼,重構

# ✅ 良好:僅觸發條件,無工作流程摘要
description: 當在當前會話中執行包含獨立任務的實作計畫時使用

# ✅ 良好:僅觸發條件
description: 在實作任何功能或錯誤修復之前,在撰寫實作代碼時使用

內容:

  • 使用具體的觸發條件、症狀和情況來表明此技能適用
  • 描述問題(競爭條件、不一致行為)而非特定語言的症狀(setTimeout、sleep)
  • 除非技能本身是技術特定的,否則保持觸發條件的技術中立性
  • 如果技能是技術特定的,請在觸發條件中明確說明
  • 使用第三人稱撰寫(將被注入系統提示)
  • 絕對不要總結技能的流程或工作流程
# ❌ 錯誤:過於抽象、模糊,未包含使用時機
description: 用於非同步測試

# ❌ 錯誤:使用第一人稱
description: 我可以幫助你處理不穩定的非同步測試

# ❌ 錯誤:提到技術但技能並非專屬於該技術
description: 當測試使用 setTimeout/sleep 且不穩定時使用

# ✅ 良好:以「Use when」開頭,描述問題,無工作流程
description: 當測試有競爭條件、時序相依性或通過/失敗不一致時使用

# ✅ 良好:技術特定的技能,具有明確的觸發條件
description: 當使用 React Router 並處理驗證重定向時使用

2. 關鍵字覆蓋率

使用代理會搜尋的詞彙:

  • 錯誤訊息:「Hook timed out」、「ENOTEMPTY」、「競爭條件」
  • 症狀:「不穩定」、「掛起」、「殭屍」、「污染」
  • 同義詞:「超時/掛起/凍結」、「清理/拆卸/afterEach」
  • 工具:實際的命令、函式庫名稱、檔案類型

3. 描述性命名

使用主動語態,動詞在前:

  • ✅ creating-skills 而非 skill-creation
  • ✅ condition-based-waiting 而非 async-test-helpers

4. 代幣效率(關鍵)

問題: 入門指南和頻繁參考的技能會載入到每一次對話中。每一個代幣都很重要。

目標字數:

  • 入門指南工作流程:每個少於 150 字
  • 頻繁載入的技能:總計少於 200 字
  • 其他技能:少於 500 字(仍需簡潔)

技巧:

將細節移至工具說明:

# ❌ 錯誤:在 SKILL.md 中記錄所有旗標
search-conversations 支援 --text、--both、--after DATE、--before DATE、--limit N

# ✅ 良好:參考 --help
search-conversations 支援多種模式和篩選條件。執行 --help 以取得詳細資訊。

使用交叉參考:

# ❌ 錯誤:重複工作流程細節
搜尋時,使用範本分配子代理...
[20 行重複的指示]

# ✅ 良好:參考其他技能
始終使用子代理(節省 50-100 倍上下文)。必要:使用 [其他技能名稱] 來管理工作流程。

壓縮範例:

# ❌ 錯誤:冗長的範例(42 字)
您的人類夥伴:「我們之前在 React Router 中是如何處理驗證錯誤的?」
您:我將搜尋過去的對話以尋找 React Router 驗證模式。
[使用搜尋查詢分配子代理:「React Router 驗證錯誤處理 401」]

# ✅ 良好:最小範例(20 字)
夥伴:「我們在 React Router 中是如何處理驗證錯誤的?」
您:正在搜尋...
[分配子代理 → 綜合整理]

消除冗餘:

  • 不要重複已在交叉參考技能中的內容
  • 不要解釋從命令中顯而易見的內容
  • 不要包含相同模式的多個範例

驗證:

wc -w skills/路徑/SKILL.md
# 入門指南工作流程:目標 <150 字每個
# 其他頻繁載入的技能:目標 <200 字總計

根據您的行為或核心見解命名:

  • ✅ condition-based-waiting > async-test-helpers
  • ✅ using-skills 而非 skill-usage
  • ✅ flatten-with-flags > data-structure-refactoring
  • ✅ root-cause-tracing > debugging-techniques

動名詞 (-ing) 適用於流程:

  • creating-skills、testing-skills、debugging-with-logs
  • 主動,描述您正在採取的動作

5. 交叉參考其他技能

在撰寫參考其他技能的文件時:

僅使用技能名稱,並附帶明確的必要性標記:

  • ✅ 良好:**必要子技能:** 使用 superpowers:test-driven-development
  • ✅ 良好:**必要背景:** 您必須理解 superpowers:systematic-debugging
  • ❌ 錯誤:參閱 skills/testing/test-driven-development(不明確是否必要)
  • ❌ 錯誤:@skills/testing/test-driven-development/SKILL.md(強制載入,浪費上下文)

為什麼不使用 @ 連結: @ 語法會立即強制載入檔案,在您需要它們之前就消耗 200k+ 上下文。

流程圖使用

縮圖 when_flowchart {
    「需要顯示資訊嗎?」 [形狀=菱形];
    「決策點可能出錯嗎?」 [形狀=菱形];
    「使用 Markdown」 [形狀=方框];
    「小型內嵌流程圖」 [形狀=方框];

    「需要顯示資訊嗎?」 -> 「決策點可能出錯嗎?」 [標籤=「是」];
    「決策點可能出錯嗎?」 -> 「小型內嵌流程圖」 [標籤=「是」];
    「決策點可能出錯嗎?」 -> 「使用 Markdown」 [標籤=「否」];
}

僅在以下情況使用流程圖:

  • 非顯而易見的決策點
  • 可能過早停止的流程循環
  • 「何時使用 A 對比 B」的決策

切勿將流程圖用於:

  • 參考資料 → 表格、清單
  • 程式碼範例 → Markdown 程式碼區塊
  • 線性指示 → 編號清單
  • 沒有語義意義的標籤(step1、helper2)

請參閱此目錄中的 graphviz-conventions.dot 以獲取 graphviz 樣式規則。

為您的人類夥伴進行視覺化: 使用此目錄中的 render-graphs.js 將技能的流程圖渲染為 SVG:

node ./render-graphs.js ../某個技能           # 每個圖表分開
node ./render-graphs.js ../某個技能 --combine # 所有圖表在一個 SVG 中

程式碼範例

一個出色的範例勝過許多平庸的範例

選擇最相關的語言:

  • 測試技術 → TypeScript/JavaScript
  • 系統除錯 → Shell/Python
  • 資料處理 → Python

好的範例:

  • 完整且可執行
  • 附有說明 WHY 的完善註解
  • 來自真實情境
  • 清晰地展示模式
  • 準備好可供改寫(非泛型範本)

不要:

  • 用 5 種以上語言實作
  • 建立填空式範本
  • 撰寫人為設計的範例

您擅長移植 - 一個出色的範例就足夠了。

檔案組織

自包含技能

defense-in-depth/
  SKILL.md    # 所有內容內嵌

當:所有內容都適合,無需大量參考

附帶可重複使用工具的技能

condition-based-waiting/
  SKILL.md    # 概述 + 模式
  example.ts  # 可供改寫的實用輔助工具

當:工具是可重複使用的程式碼,而不僅僅是敘述

附帶大量參考的技能

pptx/
  SKILL.md       # 概述 + 工作流程
  pptxgenjs.md   # 600 行 API 參考
  ooxml.md       # 500 行 XML 結構
  scripts/       # 可執行工具

當:參考資料太大,無法內嵌

通過其解釋器在文件中呼叫捆綁的腳本(bash scripts/tool.sh、node scripts/tool.js),絕不要使用裸路徑:某些 harness 外掛打包程式會剝離可執行位元,裸的 scripts/tool.sh 會在那裡因「許可被拒絕」而失敗。

鐵律(與 TDD 相同)

沒有技能可以在沒有先通過一個失敗的測試的情況下建立

這適用於新的技能以及對現有技能的編輯。

先寫技能再測試?刪掉它。重新開始。 未經測試就編輯技能?同樣的違規。

沒有例外:

  • 不適用於「簡單的補充」
  • 不適用於「只是新增一個章節」
  • 不適用於「文件更新」
  • 不要保留未經測試的變更作為「參考」
  • 不要在執行測試的同時「改寫」
  • 刪除意味著刪除

必要背景: superpowers:test-driven-development

…

[為翻譯而截斷]

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.

相關技能