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 从公开仓库中收录这些内容。

举报或申请下架