360 Secure SkillHub
360 安全技能中心

type-system

该 Skill 提供类型系统设计准则:在边界解析外部数据、从 schema 派生类型、为不同状态和语义建立独立类型、避免强制转换和 any,并通过穷尽处理让新增变体在编译期报错。

分类:开发
0xr3ngar
热度 0.00
最近更新 2026-11-20 05:22:38

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add 0xr3ngar/bstack/type-system
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
type-system
description
Apply when you design types or a signature, or write code in a typed language.
disable-model-invocation
true
license
MIT
compatibility
No tools needed.

Type-system

Let the compiler reject wrong states, so that reviews and tests do not have to.

  • Parse external data once, at the boundary, with the project's schema tool. Inside, trust the typed value.
  • Derive a type from the schema that owns the shape. When two languages hold the same model, one is the source, and a test fails when the other differs.
  • Give each state its own type. No optional field that is "set only when", no nullable value that cannot be null, no tuple where names say more.
  • When two values have the same primitive type and different meanings, give each its own type.
  • Use no cast, non-null assertion or any to silence a missing check.
  • Let return types be inferred. Keep inputs read-only. Check a fixed mapping with a typed record, so that a missing case does not compile.
  • Handle every variant, so that a new variant is a compile error.