Community程式設計與開發github.com

alfathafp/portofolio-web-design

以書面合約建立專案的品質門檻,防止 Agent 默默降低標準。它會訪談使用者哪些維度重要,當使用者沒有具體數字時提供合理的預設值,將一切記錄在 CONSTRAINTS.md 中,並監控 diff 中是否出現削弱的跡象——新的 @ts-ignore 或 eslint-disable 抑制、跳過或刪除的測試、被移除的斷言、未實作的樁程式、調低的門檻。

portofolio-web-design 是什麼?

這項技能旨在透過建立一份稱為 CONSTRAINTS.md 的書面合約來強制執行專案品質門檻,防止 AI Agent 在無人監督的情況下降低標準。它對使用者進行簡短的訪談,以確定哪些品質維度(例如測試覆蓋率、無障礙性、效能預算)是重要的,並在使用者沒有特定數字時提供合理的預設值。所有約束都會記錄在一個檔案中,該檔案在 Agent 任務結束時存活,並可在審查期間以機械方式檢查。該技能還監控 diff 以偵測品質門檻是否被削弱,例如新增的抑制註解、跳過的測試或調低的門檻。它支援 Claude Code、Cursor、Codex 等平台,並提供特定工具(如 eslint、semgrep、Lighthouse)的參考實作,以確保約束是可執行的。

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

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

在你喜歡的 AI 中提問

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

說明文件

約束驅動開發

概述

這個套件中的其他技能描述了「好」的樣貌。code-review-and-quality 提供了五個軸向。test-driven-development 提供了一個循環。security-and-hardening 提供了一個威脅清單。所有這些都存在於 Agent 閱讀且可能遵循或不遵循的散文敘述中,並且它們都無法在對話結束後留存。

這項技能產生的東西不同:一份關於此專案門檻的書面記錄,包含數字,它比對話更長壽,並且可以機械地檢查。

這很重要。當你編寫程式碼時,閱讀它就能知道它好不好。一個 Agent 在一個下午寫的程式碼比你一週能讀的還多,因此判斷力從你的腦袋轉移到圍繞循環運行的檢查中。那些檢查需要存在,它們需要你實際選擇的數字,並且它們需要在離工作足夠近的地方觸發,以便 Agent 修復自己的輸出。

規格驅動開發說明了要建構什麼。測試驅動開發證明了它能運作。約束驅動開發定義了「足以出貨」的意義,在任何人於 Pull Request 中爭論之前。

使用時機

在以下情況套用此技能:

  • 開始一個專案或一個重要功能,且沒有書面的品質門檻
  • 使用者要求「設定約束」、「加入品質關卡」、「定義我們的標準」或「阻止 Agent 產出垃圾」
  • Agent 正在產生大量沒人會逐行閱讀的程式碼
  • CI 有檢查,但沒人能說清楚哪些會阻擋合併,哪些只是裝飾
  • 覆蓋率、效能或無障礙性數字在每個 PR 中被爭論,而不是一次性決定
  • 你即將執行 /build auto 或任何自主循環,而唯一阻擋它奔向 main 的是 Agent 自己寫的測試套件

何時不要使用:

  • 專案已經有 CONSTRAINTS.md 且使用者沒有要修改它——應閱讀並遵循它
  • 一次性腳本、實驗性原型、可拋棄的原型
  • 使用者想要立即進行程式碼審查(code-review-and-quality)或建立 CI 管道(ci-cd-and-automation)
  • 預計生命周期僅兩週的產品市場契合前程式碼——最低底線仍然值得,但其餘部分則否

載入約束

訪談需要一個活躍的使用者。請勿在非互動式情境下執行(CI、/loop、自主運作)。如果在那些情境中缺少約束,請套用下面的底線,註明你已這麼做,並將剩餘部分標記給人類處理。

流程

步驟 1:在詢問之前先偵測

永遠不要問你可以讀到的東西。在第一個問題之前,收集:

項目去哪裡找
語言和技術棧package.json, pyproject.toml, go.mod, Cargo.toml
測試執行器開發依賴、test 腳本、現有測試檔案
現有 lintereslint.config.*, biome.json, .ruff.toml
當前覆蓋率coverage/ 輸出,或執行一次測試套件
CI.github/workflows/, .gitlab-ci.yml
Agent 框架.claude/, .codex/, AGENTS.md

用兩行報告你發現的內容,然後只詢問剩下的部分。

步驟 2:四個問題,每個都有預設值

遵循 interview-me 中的一次一個問題的原則,但有一個變化:這裡的每個問題都有預設值,因此「我不知道」是一個完整的答案,仍然能產生一個可用的配置。

Q1:除了底線之外,你想要強制執行哪些項目?
    (a) 新程式碼的測試覆蓋率
    (b) 安全掃描
    (c) 效能預算
    (d) 無障礙性
    (e) 架構邊界
猜測:(a) 和 (b)——你已經有測試執行器,而且你在處理使用者輸入。
不確定時的預設值:(a) 和 (b)。
說明每個選擇的成本:(c) 和 (d) 需要一個運行中的 URL,(e) 需要一個編寫規則的檔案。
Q2:當 Agent 在執行任務中檢查失敗時,它應該阻止還是警告?
猜測:阻止。你在無人值守時運行 Agent,而一個沒人讀的警告就是一個警告。
不確定時的預設值:在底線上阻止,在前兩週對其他所有項目發出警告。
Q3:你有目標數字嗎,還是我應該測量你目前的位置並維持那條線?
猜測:測量。大多數團隊沒有數字,而憑空想像的數字會被忽略。
不確定時的預設值:測量並維持。請參閱下面的「棘輪」。
Q4:在 Agent 交回工作之前,你能容忍的最慢檢查時間是多少?
猜測:大約 90 秒。再長一點你就會停止執行它。
不確定時的預設值:任務結束時 90 秒,CI 中無限制。

停在四個問題。一個十二個問題的輸入流程會產生一個沒人理解的配置和一個後悔開始的使用者。

步驟 3:撰寫 CONSTRAINTS.md

一個檔案放在倉庫根目錄。任何框架上的任何 Agent 都可以讀取它,對它的修改會在審查中出現,這正是它該在的地方。

# 約束

上次審查:2026-08-08 由 @addy

## 底線(始終強制執行,無需設定)

- 沒有新的抑制註解:`@ts-ignore`, `eslint-disable`, `# noqa`, `# type: ignore`
- 沒有未實作的樁程式:`throw new Error("Not implemented")`, 空的 `catch {}`
- 沒有跳過或刪除的測試,除非在提交訊息中說明原因
- 原始碼中沒有機密
- 此檔案不會為了通過某項變更而被削弱

## 以數字強制執行

| 維度 | 規則 | 由誰檢查 | 在哪執行 |
|-----------|------|-----------|---------|
| 型別 | 零個型別錯誤 | `tsc --noEmit` | 每次編輯 |
| Lint | 設定檔中零個錯誤 | `biome check` | 每次編輯 |
| 機密 | 原始碼中沒有機密 | `gitleaks detect --redact` | 每次編輯 |
| 覆蓋率 | 被變更的行 ≥ 80% 覆蓋 | `vitest run --coverage` + git diff | 任務結束, CI |
| 安全性:程式碼 | 沒有高風險發現 | `semgrep scan --config p/default` | CI |
| 安全性:依賴 | 沒有高風險或以上 | `osv-scanner scan source -r .` | CI |
| 無障礙性 | 零個嚴重或重大 | `axe $PREVIEW_URL --tags wcag2a,wcag2aa,wcag21aa` | 預覽部署 |
| 效能 | LCP ≤ 2500ms, CLS ≤ 0.1 | `lighthouse $PREVIEW_URL --output=json` | 預覽部署 |

每一行都指名了產生判決的指令。一個有數字但此欄位沒有指令的維度是願望,而不是約束。

## 已測量,尚未強制執行

| 指標 | 今日數值 | 方向 |
|--------|-------|-----------|
| 專案覆蓋率 | 62.4% | 不得下降 |
| 套件大小 (main) | 184 kB | 不得增長 |

## 例外

| ID | 規則 | 路徑 | 原因 | 負責人 | 到期日 |
|----|------|------|--------|-------|---------|
| W1 | `no-explicit-any` | `src/legacy/**` | 重構追蹤在 ENG-441 | @addy | 2026-11-01 |

然後在 AGENTS.md 和 CLAUDE.md 中加入一行:在撰寫程式碼之前請先閱讀 CONSTRAINTS.md。不要為了讓變更通過而削弱它。

步驟 4:安裝每個維度所需的東西

選擇一個維度意味著安裝某些東西。不要留給使用者一個數字卻沒有機制,也不要在你已經有事實上的檢查器時自己發明一個——列出這些工具是因為它們的規則格式和門檻是生態系統中其他所有東西的目標,因此團隊現有的配置可以繼續運作。

維度工具安裝執行關卡依據
型別 (TS)tsc已經存在tsc --noEmit任何錯誤
型別 (Python)mypypip install mypymypy .任何錯誤
Lint你現有的設定已經存在eslint . / biome check / ruff check任何錯誤
覆蓋率 (JS)你的測試執行器已經存在vitest run --coverage (或 jest --coverage)被變更行的覆蓋率
覆蓋率 (Python)pytest-covpip install pytest-covpytest --cov --cov-report=lcov同上
安全性:程式碼Semgreppipx install semgrepsemgrep scan --config p/default --config p/owasp-top-ten任何高風險發現
安全性:機密gitleaksbrew install gitleaksgitleaks detect --redact --no-banner任何發現
安全性:依賴osv-scannerbrew install osv-scannerosv-scanner scan source -r .高風險或以上
效能:頁面Lighthousenpm i -D lighthouselighthouse $URL --output=json --quietLCP, CLS, 效能分數
效能:套件size-limitnpm i -D size-limitsize-limit --json每個入口的位元組預算
無障礙性axe-corenpm i -D @axe-core/cliaxe $URL --tags wcag2a,wcag2aa,wcag21aa零個嚴重或重大
架構dependency-cruisernpm i -D dependency-cruiserdepcruise --validate src任何違規
斷言品質Strykernpm i -D @stryker-mutator/corestryker run --mutate <changed files>突變分數

如果你跳過它們,有五件事會咬你一口:

  1. gitleaks 上的 --redact 不是可選的。 沒有它,匹配到的機密會出現在 Agent 的記錄中,這就是洩露的金鑰如何最終出現在日誌、摘要或提交訊息中。報告規則和位置,永遠不要報告值。
  2. Lighthouse 和 axe 需要一個 URL。 它們只對運行中的應用程式有效,因此它們屬於運行時階段,針對預覽部署或你先啟動的本地伺服器。如果專案沒有要訪問的 URL——一個 CLI、程式庫、桌面應用程式——請說明並放棄該維度,而不是發明一個無法運行的檢查。
  3. 將昂貴的檢查範圍限制在 diff。 對整個倉庫執行 stryker run --mutate 需要數小時,會被關閉;對變更影響的檔案執行只需要不到一分鐘。Semgrep 也是如此,它接受路徑列表。
  4. 覆蓋率不需要第二次執行測試。 讀取你的套件已經寫入的 lcov 並與 git diff 相交。為了得到一個數字而執行兩次測試套件是讓人們討厭這個最快的方式。
  5. Semgrep 的註冊規則可以免費執行;在重新分發之前請檢查許可證。 如果這對你的法務團隊很重要,opengrep 是一個直接可取代的分支,具有相同的規則格式和 JSON 輸出。

將每一個加入專案自己的腳本,以便在沒有 Agent 的情況下可以重現:

{
  "scripts": {
    "check:fast": "tsc --noEmit && eslint . && gitleaks detect --redact --no-banner",
    "check:task": "npm run check:fast && vitest run --coverage",
    "check:full": "npm run check:task && semgrep scan --config p/default && osv-scanner scan source -r ."
  }
}

這個對應比工具本身更重要。check:fast 是在每次編輯後執行的,check:task 是當 Agent 認為已完成時執行,check:full 則在 CI 中執行。

這些指令現在存在於兩個地方——CONSTRAINTS.md 中的「由誰檢查」欄位和這些腳本。CONSTRAINTS.md 是規範來源:它在每個指令旁邊附帶理由,並且會在審查中出現。腳本是必須與之鏡像的便利包裝器,而不是第二個真相來源;如果它們偏離,檔案勝出。

步驟 5:將其連接到生命週期

最大的單一錯誤是在每個地方執行所有事情。一個停滯 Agent 的檢查會被關閉,而一個被人關閉的關卡比沒有關卡更糟,因為門檻看起來仍然存在。

階段指令執行內容預算
BUILD/build型別、Lint、機密、底線5 秒內,僅變更的檔案
VERIFY/test相關測試、變更行的覆蓋率90 秒內
REVIEW/review所有內容,加上下面的守衛數分鐘
SHIP/ship方向檢查,無回歸CI

兩個規則讓這變得可忍受:

  1. 範圍限制在 diff。 檢查此次變更觸碰的行,而不是整個倉庫。變更行的覆蓋率是 Agent 可以移動的數字;專案覆蓋率是它繼承來的。
  2. 成本決定放置位置。 任何超過幾秒的檢查移出編輯循環。對整個倉庫進行突變測試需要數小時;對變更觸碰的檔案則不到一分鐘,這是有沒有人執行檢查的區別。

步驟 6:守護門檻本身

有人會指出,如果 Agent 編寫程式碼和檢查,那麼檢查結果什麼也證明不了。說對了一半,值得圍繞這個進行工程設計。

Agent 不會設計巧妙的漏洞。它們遇到紅燈,然後走最便宜的路線到綠燈。在審查時,在 diff 中留意這五個動作:

  1. 門檻變動了。 預算調低、嚴重性降低、檢查從快速階段移除。將 CONSTRAINTS.md 與其在分支點時的狀態進行比較。
  2. 測試變簡單了。 添加了 .skip、刪除了測試檔案、從留存下來的測試中移除了斷言。
  3. 檢查器被關閉了。 新的 @ts-ignore 或 eslint-disable。四個抑制值得特別注意,因為它們關閉了你依賴的檢查:istanbul ignore 將程式碼從覆蓋率中移除而不是測試它,Stryker disable 隱藏了一個存活的突變,nosemgrep 和 gitleaks:allow 對安全發現也是這樣做的。
  4. 工作未完成。 一個拋出錯誤的樁程式、一個將失敗變成沈默的空 catch、一個代替實作位置的 TODO。
  5. 出現了一個例外。 沒有人討論過的例外表格中的新行。

這些都不需要 git diff 以外的工具。收緊門檻應該無聲;放鬆門檻應該大聲。

與編號的維度不同,底線沒有自己的事實上的工具,因此被要求強制執行底線的 Agent 傾向於從頭開始編寫一個檢查器,而兩個 Agent 會寫兩個不同的。這五項檢查的參考實作隨此技能一同提供,位於 references/floor-guard.md(diff 範圍,結束碼 0/1/2,模式可根據生態系統調整)。請改編它而不是重新發明,原因與每個維度都指定一個事實上的工具相同:這樣機制才能在執行和技術棧之間保持一致。

並非所有檢查都同樣循環。 根據一個問題對它們進行排序:Agent 能否透過編寫無法運作的程式碼來通過此檢查?

  • 外部——axe-core 編碼了 WCAG,osv-scanner 讀取漏洞資料庫,Lighthouse 測量真實瀏覽器。Agent 無法與這些爭論。
  • 專案——你的 lint 規則、你的層級邊界。人類擁有該檔案。
  • 套件——你自己的測試。最有用,也是唯一真正循環的。

一個門檻

…

[為翻譯而截斷]

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

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

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.

相關技能