Agent Skills
› UsefulSoftwareCo/executor
› wrdn-effect-schema-boundaries
wrdn-effect-schema-boundaries
GitHub修复边界处对未知数据的类型断言与探测,使用 Effect Schema 进行统一解码和类型校验,消除双重转换、内联对象断言及属性检查,确保域代码获得强类型数据。
Trigger Scenarios
代码中存在 double casts (如 as unknown as X)
存在 inline object assertions
对 unknown 形状进行 probing 或 ad hoc property checks
使用 JSON.parse 后直接断言类型
Install
npx skills add UsefulSoftwareCo/executor --skill wrdn-effect-schema-boundaries -g -y
SKILL.md
Frontmatter
{
"name": "wrdn-effect-schema-boundaries",
"description": "Normalize unknown or loosely typed data at boundaries with Effect Schema, named guards, or typed adapters. Use when lint flags double casts, inline object assertions, unknown shape probing, or ad hoc property checks on unknown values.",
"allowed-tools": "Read Grep Glob Bash"
}
You fix one pattern: domain code is asserting or probing an unknown shape instead of parsing it once at the boundary.
Fix Shape
- Prefer
Schema.decodeUnknownEffect(MySchema)(value)for untrusted input. - Prefer
Schema.decodeUnknownEffect(Schema.fromJsonString(MySchema))(text)orSchema.decodeUnknownOption(Schema.parseJson())(text)for JSON strings. - Keep domain code typed after the decode; do not keep
unknownand probe it repeatedly. - Replace
JSON.parse,value as string,as unknown as X,as Record<string, unknown>, inline object assertions,"field" in value, andReflect.getwith a schema, typed adapter, or named guard. - A named guard is acceptable only when parsing is not the right abstraction and the guard has a precise return type.
Good
const ParsedConfig = Schema.Struct({
endpoint: Schema.String,
});
const config = yield * Schema.decodeUnknownEffect(ParsedConfig)(raw);
const config = yield * Schema.decodeUnknownEffect(Schema.fromJsonString(ParsedConfig))(rawText);
Bad
const config = raw as unknown as { endpoint: string };
const config = JSON.parse(rawText) as { endpoint: string };
const pattern = updated.pattern as string;
Version History
- fd4fb02 Current 2026-07-05 10:55


