Community程式設計與開發github.com

alfathafp/portfólio-web-design

記錄決策與文件。當你需要記錄架構決策 (ADR) 或設計選擇背後的理由、修改公開 API、發布功能,或需要記錄未來工程師與 AI Agent 理解程式碼庫所需的背景資訊時使用。

portfólio-web-design 是什麼?

這個技能提供了一套完善的架構決策記錄 (ADR) 與文件撰寫指南,強調記錄「為什麼」而非「做了什麼」的重要性。它能幫助開發者和 AI Agent 在做出重要的架構選擇、比較不同方案、修改 API 或發布新功能時,系統性地記錄下決策背景、考量因素與權衡取捨。該技能支援多種平台,並提供詳細的 ADR 模板、內嵌文件規範、README 架構建議以及變更記錄維護指引。其核心價值在於透過書面記錄,為未來的團隊成員(包含人類與 AI Agent)保留關鍵的背景知識,避免重複討論相同的決策,並預防已知陷阱。技能中還包含了常見的自我合理化說法的反駁,以及專案文件健康度的檢查清單,確保文件不僅存在,而且有價值。

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

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

在你喜歡的 AI 中提問

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

說明文件

文件與架構決策記錄 (ADR)

概述

記錄決策,而不只是記錄程式碼。最有價值的文件記錄的是「為什麼」—— 也就是導致某個決策的背景、限制和權衡取捨。程式碼顯示「做了什麼」;文件則解釋「為什麼這樣做」以及「考慮了哪些替代方案」。這個背景資訊對於未來在程式碼庫中工作的人類和 AI Agent 都至關重要。

何時使用

  • 做出重大的架構決策
  • 在相互競爭的方法之間做選擇
  • 新增或修改公開 API
  • 發布會改變使用者面向行為的功能
  • 有新團隊成員(或 Agent)加入專案
  • 當你發現自己不斷重複解釋同一件事時

何時不該使用: 不要為顯而易見的程式碼撰寫文件。不要添加只是重述程式碼的註解。不要為一次性原型撰寫文件。

架構決策記錄 (ADR)

ADR 記錄了重要技術決策背後的理由。它們是你能寫出的最有價值的文件。

何時撰寫 ADR

  • 選擇框架、函式庫或主要依賴項
  • 設計資料模型或資料庫結構
  • 選擇驗證策略
  • 決定 API 架構 (REST vs. GraphQL vs. tRPC)
  • 在建置工具、託管平台或基礎設施之間做選擇
  • 任何難以逆轉的決策

先遵循既有慣例

在建立 ADR 之前,檢查可用的儲存庫上下文以尋找既有的慣例 —— 現有的 ADR、專案說明文件,以及與 ADR 相關的設定或工具(例如 .adr-dir 檔案)。既有的慣例應優先於下列預設值。需符合:

  • 位置與格式 —— 例如 docs/adr/*.md、Documentation/Decisions/*.rst、MADR 佈局或 adr-tools 設定。符合既有的目錄、副檔名和標記語言(Markdown 與 reStructuredText)。
  • 編號與命名 —— 沿用現有的序列和檔案名稱模式 (ADR-004-Title.rst、0004-title.md …);不要從 001 重新開始或引入第二種命名方案。
  • 章節標題 —— 重複使用專案的標題集,而不是套用這個範本的。

如果可用的資訊相互衝突,應指出衝突之處,而不是默默地引入另一種方案。只有在完全無法確定既有慣例時,才套用下面的預設值。

ADR 範本

除非專案已使用其他位置(見上方說明),否則將 ADR 存放在 docs/decisions/,並使用連續編號:

# ADR-001: 使用 PostgreSQL 作為主要資料庫

## 狀態
已提議 | 已接受 | 被 ADR-XXX 取代 | 已棄用

## 日期
2025-01-15

## 背景
我們需要一個用於任務管理應用程式的主要資料庫。主要需求:
- 關聯式資料模型(使用者、任務、團隊,彼此之間有關聯)
- 用於任務狀態變更的 ACID 交易
- 支援任務內容的全文搜尋
- 提供代管服務(對於小型團隊,運維能力有限)

## 決策
使用 PostgreSQL 搭配 Prisma ORM。

## 考慮過的替代方案

### MongoDB
- 優點:結構彈性,容易上手
- 缺點:我們的資料本質上是關聯式的;需要手動管理關聯
- 已拒絕:在文件資料庫中儲存關聯式資料會導致複雜的關聯或資料重複

### SQLite
- 優點:無需設定,內嵌式,讀取速度快
- 缺點:並發寫入支援有限,沒有適用於正式環境的代管服務
- 已拒絕:不適用於正式環境中的多使用者網頁應用程式

### MySQL
- 優點:成熟,廣泛支援
- 缺點:PostgreSQL 在 JSON 支援、全文搜尋和生態系統工具方面表現更佳
- 已拒絕:PostgreSQL 更符合我們的功能需求

## 結果
- Prisma 提供型別安全的資料庫存取和遷移管理
- 我們可以使用 PostgreSQL 的全文搜尋功能,而無需額外加入 Elasticsearch
- 團隊需要具備 PostgreSQL 知識(基本技能,風險低)
- 使用代管服務(Supabase、Neon 或 RDS)

ADR 生命週期

已提議 → 已接受 → (被取代 或 已棄用)
  • 不要刪除舊的 ADR。 它們記錄了歷史背景。
  • 當決策變更時,撰寫一個新的 ADR,參考並取代舊的 ADR。

內嵌文件

何時加入註解

註解「為什麼」,而不是「做什麼」:

// 不好:重述程式碼
// 計數器加 1
counter += 1;

// 好:解釋不明顯的意圖
// 速率限制使用滑動視窗 — 在視窗邊界重置計數器,
// 而不是在固定時間點,以防止在視窗邊緣發生突發攻擊
if (now - windowStart > WINDOW_SIZE_MS) {
  counter = 0;
  windowStart = now;
}

何時不該加入註解

// 不要為顯而易見的程式碼加入註解
function calculateTotal(items: CartItem[]): number {
  return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}

// 不要為你應該現在就做的事情留下 TODO 註解
// TODO: 加入錯誤處理  ← 直接加上去

// 不要留下註解掉的程式碼
// const oldImplementation = () => { ... }  ← 刪掉它,git 有歷史紀錄

記錄已知陷阱

/**
 * 重要:此函式必須在首次渲染前呼叫。
 * 如果在 hydration 之後呼叫,會導致內容閃爍,
 * 因為主題 context 在 SSR 期間不可用。
 *
 * 完整的設計理由請參考 ADR-003。
 */
export function initializeTheme(theme: Theme): void {
  // ...
}

API 文件

對於公開 API(REST、GraphQL、函式庫介面):

搭配型別內嵌(TypeScript 優先)

/**
 * 建立一個新任務。
 *
 * @param input - 任務建立資料(標題為必填,描述為選填)
 * @returns 包含伺服器產生的 ID 和時間戳的已建立任務
 * @throws {ValidationError} 如果標題為空或超過 200 個字元
 * @throws {AuthenticationError} 如果使用者未通過驗證
 *
 * @example
 * const task = await createTask({ title: 'Buy groceries' });
 * console.log(task.id); // "task_abc123"
 */
export async function createTask(input: CreateTaskInput): Promise<Task> {
  // ...
}

REST API 的 OpenAPI / Swagger

paths:
  /api/tasks:
    post:
      summary: 建立一個任務
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskInput'
      responses:
        '201':
          description: 任務已建立
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        '422':
          description: 驗證錯誤

README 結構

每個專案都應該有一個 README,涵蓋以下內容:

# 專案名稱

一段描述此專案用途的段落。

## 快速開始
1. 複製儲存庫
2. 安裝相依套件:`npm install`
3. 設定環境變數:`cp .env.example .env`
4. 啟動開發伺服器:`npm run dev`

## 指令
| 指令 | 描述 |
|---------|-------------|
| `npm run dev` | 啟動開發伺服器 |
| `npm test` | 執行測試 |
| `npm run build` | 產生正式環境建置 |
| `npm run lint` | 執行語法檢查 |

## 架構
簡要說明專案結構和關鍵設計決策。
詳細內容請參考 ADR 的連結。

## 貢獻方式
如何貢獻、編碼標準、PR 流程。

變更記錄維護

對於已發布的功能:

# 變更記錄

## [1.2.0] - 2025-01-20
### 新增
- 任務分享:使用者可以與團隊成員分享任務 (#123)
- 任務指派的電子郵件通知 (#124)

### 修正
- 快速點擊建立按鈕時出現重複任務的問題 (#125)

### 變更
- 任務清單現在一次載入 50 個項目(原為 20 個)以改善使用者體驗 (#126)

給 Agent 的文件

關於 AI Agent 上下文的特別考量:

  • CLAUDE.md / rules 檔案 —— 記錄專案慣例,讓 Agent 能夠遵循
  • 規格檔案 —— 保持規格更新,讓 Agent 能建構出正確的功能
  • ADR —— 幫助 Agent 理解過去決策的原因(防止重複決策)
  • 內嵌陷阱記錄 —— 防止 Agent 掉入已知陷阱

散文審核

在檢查技術內容之後,審核散文以確保對讀者友善。更清晰的措辭不得改變決策本身或其限制。

  1. 標記必須保留的細節:名稱、數字與單位、指令、路徑、連結、條件、權衡取捨以及不確定性。根據可用的程式碼和決策背景進行比對;標記任何你無法證實的內容。
  2. 用讀者需要的具體資訊取代樣板化的開頭、宣傳性形容詞和重複的摘要。不要用虛構的例子或更強烈的保證來取代未經支持的陳述。保留必要的技術性重複及專案既有的術語。
  3. 將編輯後的文件與原始檔及其來源進行比較。恢復任何遺失的限制或但書,驗證指令和程式碼範例仍按文件所述運作,並解釋任何未解決的事實問題,而不是將其修飾掉。

常見的自我合理化說法

合理化說法現實
「程式碼本身就是文件」程式碼顯示「做了什麼」。它不會顯示「為什麼」、拒絕了哪些替代方案,或存在哪些限制。
「等 API 穩定後我們再寫文件」當你撰寫文件時,API 會更快穩定下來。文件是設計的第一個測試。
「沒人看文件」Agent 會看。未來的工程師會看。三個月後的你自己也會看。
「ADR 是額外負擔」花 10 分鐘寫一份 ADR,可以避免六個月後針對同一個決策進行 2 小時的辯論。
「註解會過時」關於「為什麼」的註解是穩定的。關於「做了什麼」的註解會過時 —— 這就是為什麼我們只寫前者。

危險信號

  • 沒有書面理由的架構決策
  • 沒有文件或型別的公開 API
  • README 沒有說明如何執行專案
  • 註解掉的程式碼而不是刪除
  • 已經存在數週的 TODO 註解
  • 在有重大架構選擇的專案中沒有 ADR
  • 重述程式碼而非解釋意圖的文件

驗證

在完成文件記錄後:

  • 所有重要的架構決策都有對應的 ADR
  • README 涵蓋了快速開始、指令和架構概覽
  • API 函式有參數和回傳型別的文件
  • 已知陷阱已在相關位置內嵌記錄
  • 沒有殘留的註解掉的程式碼
  • 規則檔案(CLAUDE.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

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

Delivers changes incrementally in thin, verifiable slices. Use when implementing any feature or change that touches more than one file, or when picking up the next task from a plan. Use when rolling a change out behind a feature flag, when you're about to write a large amount of code at once, or when a task feels too big to land in one step.

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.

相關技能