360 Secure SkillHub
360 安全技能中心

principle-type-system-discipline

一份纯文字的类型设计原则说明,用于设计类型、评审函数签名或编写静态类型语言代码时参考:品牌化语义基本类型、在边界解析外部数据、从权威 schema 派生类型并穷尽变体。仅含原则条目,无示例代码、脚本或检查工具,并引用了未随包提供的 typescript-best-practices Skill。

分类:开发
cursor
热度 46.06
最近更新 2026-11-17 11:40:39

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add cursor/plugins/principle-type-system-discipline
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
principle-type-system-discipline
description
Apply when designing types, reviewing a function signature, or writing code in any statically-typed language. Make illegal states unrepresentable, brand semantic primitives, parse external data at boundaries, exhaust variants, derive from authoritative schemas.
disable-model-invocation
true

Type System Discipline

Make the compiler reject impossible states, mismatched primitives, and unhandled variants.

  • Brand semantic primitives. If two arguments share a primitive type but mean different things, give each its own type. Validate once at creation.
  • External data is untyped until parsed. JSON, RPC payloads, CLI args, config, environment variables, and database rows go through a parse function at the boundary that returns the typed model.
  • Derive types from authoritative schemas. When a schema file owns a shape, derive the type from it instead of hand-rolling a parallel one.

For TypeScript syntax, see the typescript-best-practices skill.