Communitygithub.com

lguidolin/engineering-constitution

在開始遵循工程憲章的專案工作時使用,用於熟悉其規則,或決定哪些工程實踐適用於特定任務——規格撰寫、提交、測試、安全性、部署、資料庫或UI工作。

engineering-constitution 是什麼?

Engineering Constitution 是一個可攜帶的工程實踐章程,專為 AI 代理工具(如 Claude Code 和 Cursor)設計,旨在將軟體工程最佳實踐分解為專注的技能。該技能充當**索引**,定義八項不可違背的原則(例如「理解後再構建」和「嚴格遵循YAGNI」),並將任務路由至適當的子技能,例如 `designing-before-building`、`conventional-commits-and-releases` 和 `tests-as-a-control`。它支援兩層技能:適用於所有專案的通用層(第一層)和依賴特定堆疊的可切換層(第二層,例如 PostgreSQL 或 Kubernetes 技能)。完整的推理過程位於同捆的 `references/engineering-constitution.md` 文件中。此技能對於任何開發者或 AI 代理使用者都至關重要,因為它透過在程式碼撰寫、提交或變更測試之前強制執行結構化規則,來確保長期的系統健全性,從而防止常見的捷徑——目標是在時間推移中最佳化整合,而不僅僅是首次部署。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/engineering-constitution

在你喜歡的 AI 中提問

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

說明文件

工程憲章

概觀

一份可攜帶的工程實踐章程,分解為專注的技能。本技能是索引:它陳述不可違背的原則,並將你引導至適合你任務的特定技能。完整的推理過程位於 references/engineering-constitution.md 中,與此 SKILL.md 捆綁在一起,以便技能無論安裝在哪裡都能隨身攜帶。

核心概念: 軟體工程是隨著時間推移而整合的程式設計。 為長壽命的系統進行最佳化——操作它、安全地變更它、在故障時恢復它——而不僅僅是首次部署。

八項不可違背的原則

  1. 先理解,後構建。 未經批准的設計,不得編寫程式碼。
  2. 記錄每個決策及其理由——以及你拒絕的方案。
  3. 測試是控制手段,而非形式——行為變更應以測試為先。 失敗的測試是資訊,絕不能擅自編輯掉。結構性變更則以現有測試套件未經編輯而通過為前提。
  4. 嚴格遵循 YAGNI(你不需要它)。
  5. 自動化可重複的事務。
  6. 軟體工程是隨著時間推移而整合的程式設計。
  7. 未經執行的規則只是建議。 將規則綁定到工具,或將其標記為需要審查者判斷。
  8. 使用者的明確指示優先於本文件。 優先級:使用者 → 憲章 → 工具預設值。

我需要哪個技能?

第一層 — 通用(適用於每個專案):

你的任務技能
開始一個功能,將想法轉化為規格/計劃designing-before-building
做出決策;記錄下來(ADR、索引、待辦想法)recording-decisions
提交、撰寫訊息、自動化發布conventional-commits-and-releases
撰寫/變更測試;權限/角色規則;重構時測試失敗tests-as-a-control
撰寫或重構程式碼;組織變更;DRY 決策change-hygiene-and-code-craft
構建 UI、元件、樣式、無障礙性interface-craft-and-accessibility
CI、預推送鉤子、任務執行器、合併閘道merge-gates-and-automation
日誌記錄、指標、追蹤、健康檢查、SLO、警報observability-and-slos
不受信任的輸入、機密、認證、依賴項、威脅建模defense-in-depth-security
熱路徑、分頁、N+1、列表端點、公開介面performance-and-scale
規劃部署、回滾或事件/事後檢討resilience-and-deploy-safety

第二層 — 特定堆疊(僅在工具/主題存在時載入):

你的任務技能
PostgreSQL、PostGraphile、RLS、SQL 檔案、應用程式→GraphQL→資料庫路徑postgres-postgraphile-rls-and-sql
UI 和測試之間共用的 GraphQL 查詢;路由/模式合約測試graphql-contract-testing
包含必須保留資料的綱要變更——遷移、回填zero-downtime-migrations
部署到 Kubernetes/AKS、雲端機密、漸進式發布、每個 PR 環境cloud-delivery-aks

這些技能如何應用於新專案

  • 第一層保持不變。 上述每個技能都適用於任何專案——網頁應用程式、管道、CLI、函式庫。
  • 第二層可替換。 當堆疊不同時,第二層技能不會觸發(其描述是特定於堆疊的),你可以替換為等效技能。它們所實現的原則(單一資料路徑、最終強制執行在底層、合約接縫、可逆部署)仍然適用。
  • 隨生命週期調整規模。 預啟動或僅限本地端的專案,將零停機遷移、金絲雀發布和正式事件流程應用為立即制定規則,按需啟動。在其第一個決策記錄中陳述專案的模式。

紅旗

如果你正要編寫程式碼、提交、部署或變更測試,但尚未查閱上述相關技能——請先停下來載入它。憲章會覆蓋預設習慣(原則 7);習慣正是它要修正的目標。

Individual skills in this repo

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

lguidolin/change-hygiene-and-code-craft

Use when writing or refactoring code, structuring a commit or PR, or deciding whether to abstract duplication. Symptoms — mixing reorg with logic changes, a PR doing several things at once, a file growing large, the second copy of similar code, or unsure whether to DRY something up.

lguidolin/cloud-delivery-aks

Use when deploying to Kubernetes or Azure Kubernetes Service (AKS), configuring cloud secrets, setting up progressive rollout/canary, per-PR ephemeral environments, or k8s health probes. Keywords — Kubernetes, AKS, Key Vault, Argo Rollouts, Flagger, canary, blue-green, liveness, readiness, PodDisruptionBudget, HPA, rollback, GHCR.

lguidolin/commit-history-rewrite

Use when an existing repository has messy commit history that needs to conform to conventional commits before adopting release-please, or when intermediate WIP/fixup/merge commits need to be cleaned up.

lguidolin/conventional-commits-and-releases

Use when committing, writing a commit message, opening a PR that will be squash-merged, or configuring automated versioning/changelogs. Keywords — conventional commits, release-please, semver, feat/fix/chore, breaking change, changelog.

lguidolin/defense-in-depth-security

Use when handling untrusted input, secrets, authentication/authorization, or dependencies — or threat-modeling a new surface. Keywords — STRIDE, threat model, least privilege, secrets management, supply chain, dependency scanning, input validation, audit log, defense in depth.

lguidolin/designing-before-building

Use when starting a feature, fixing a non-trivial bug, or about to write implementation code — before any code exists. Symptoms you need this: "this is simple, I'll just code it", reaching for the editor before a design is approved, or an idea that hasn't been turned into a spec and plan.

lguidolin/graphql-contract-testing

Use when writing a GraphQL query/mutation that the UI and a test will share, or building route/schema contract or smoke tests. Symptoms — copying a query into a test, a test asserting on query text, schema change that didn't break the UI build, or RLS/permission drift. Keywords — graphql-codegen, typed document, contract test, route smoke test.

lguidolin/init-repo-CI

Use when setting up a new repository with conventional commits, release-please, and CI automation, or when retrofitting an existing repository that lacks automated versioning and PR validation workflows.

lguidolin/interface-craft-and-accessibility

Use when building or styling UI — components, layouts, forms, design tokens — or making accessibility decisions. Keywords — a11y, WCAG, keyboard navigation, focus state, contrast, design system, minimalist UI, component reuse, ARIA, semantic HTML.

lguidolin/merge-gates-and-automation

Use when setting up or changing CI, pre-push hooks, or a task runner, or deciding what must pass before merge. Symptoms — tempted to put authoritative checks only in a local hook, skip CI, bypass with --no-verify, or unsure what gates a merge vs. runs locally.

lguidolin/observability-and-slos

Use when adding logging, metrics, tracing, health checks, SLOs, or alerting — or when building a service surface that needs to be operable and debuggable. Keywords — structured logs, OpenTelemetry, correlation id, RED metrics, liveness, readiness, SLI, SLO, error budget, alerting.

lguidolin/performance-and-scale

Use when working on hot paths, list endpoints, pagination, data-access in loops, or public interfaces/schemas. Symptoms — unbounded queries, N+1 access, no latency budget, optimizing without measuring, or changing an interface many consumers depend on. Keywords — pagination, N+1, Hyrum's Law, performance budget, bundle size.

lguidolin/postgres-postgraphile-rls-and-sql

Use when writing PostgreSQL, PostGraphile config, Row-Level Security policies, SQL schema files, or working on the Browser→App→PostGraphile→Postgres data path. Keywords — RLS, SECURITY DEFINER, search_path, pgSettings, grants, roles, GraphQL depth limit, query cost, statement_timeout, SQL file organization.

lguidolin/recording-decisions

Use when a design or architecture decision has been made and needs to be captured — writing a decision record or ADR, updating a decision index, noting a deferred idea, or superseding a past decision. Keywords — ADR, decision record, rationale, rejected alternatives, dependency index.

lguidolin/resilience-and-deploy-safety

Use when planning a deploy, designing a rollback, or responding to an incident or writing a postmortem. Keywords — deploy safety, rollback, immutable artifact, progressive delivery, canary, blast radius, incident response, blameless postmortem, error budget.

lguidolin/ship-it

Use when the user wants to ship work — push, PR, archive decision records, merge, and clean up. Handles the full lifecycle from committing final changes through post-merge cleanup including converting specs/plans to compact decision records.

lguidolin/tests-as-a-control

Use when writing or modifying tests, when a test breaks during a refactor, or when testing permission/role rules. Symptoms — tempted to edit a test to make it pass, testing only the happy path, a deny-test that started passing, flaky tests, or unsure what to assert.

lguidolin/zero-downtime-migrations

Use when changing a database schema where data must survive the change — adding/removing/renaming columns, constraints, indexes, or backfilling. Symptoms — a destructive migration bundled with a code deploy, a NOT NULL column with a backfill, a table-locking UPDATE, or a rename. Keywords — expand/contract, parallel change, backfill, NOT VALID, CREATE INDEX CONCURRENTLY, graphile-migrate.

相關技能