Principle Boundary Discipline

作者 cursorccb5507cec15無授權條款10K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Apply when wiring validation, error handling, or framework adapters. Concentrate guards at system boundaries (CLI, config, network, external APIs); trust internal types and keep business logic in pure functions.

AI 產生的概覽

一套編碼原則:把驗證與錯誤處理放在系統邊界,業務邏輯保持為純函式。

功能
此技能說明一項軟體設計原則:將驗證、型別收窄與錯誤處理集中在系統邊界,例如命令列參數、設定檔、網路協定與外部 API。它建議信任內部型別、不在內部重複驗證,在系統內部傳遞錯誤,並讓業務邏輯位於純函式中,外殼保持輕薄且機械化。它也提供檢驗問題,用來判斷驗證是否多餘、邏輯能否抽取為純函式。
適用情境
適用於在程式庫中接入驗證、錯誤處理或框架轉接層時。它用來決定要在哪裡驗證資料,以及如何相對於框架程式碼組織業務邏輯。
執行需求
不需要任何工具、套件、執行環境、憑證或網路存取;僅為說明性指示,不附帶指令碼。

Boundary Discipline

Place validation, type narrowing, and error handling at system boundaries. Trust internal code unconditionally. Business logic lives in pure functions. The shell is thin and mechanical.

Why: Scattered validation is noisy, redundant, and gives a false sense of safety. Keep logic out of framework wiring so it can be tested without the framework.

The pattern:

  • At boundaries (CLI args, config files, external APIs, network protocols): validate, return errors, handle defensively.
  • Inside the system: typed data, error propagation, no re-validation. Trust the types.
  • Across the boundary. Expose domain concepts, not the boundary's private representation. Keep general-purpose mechanism inside and special-purpose policy at the edge.

Applications:

Validation and error handling:

  • Validate config at parse time (the boundary), not inside business logic
  • Parse raw data into domain types at the boundary
  • Do not re-export transport, storage, framework, or wire types through the public surface
  • No redundant nil checks deep in call chains if the boundary already validated

Code organization:

  • Business logic in pure functions with no framework dependencies
  • Parse functions: pure transforms from raw bytes to typed state
  • Prompt construction: structured state in, string out
  • Scoring and assessment: pure transforms from state to results

The tests:

  • "Is this data crossing a system boundary right now?" If not, validation is redundant.
  • "Can this be a pure function that the shell just calls?" If yes, extract it.

來源與署名

來源:cursor/plugins位於pstack/skills/principle-boundary-discipline提交ccb5507

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架