2428424081cn/skill-mcp/typescript-strict-guard

Claude Code and agent skill by 2428424081cn/skill-mcp

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Install

npx vskill@latest install 2428424081cn/skill-mcp/typescript-strict-guard

SKILL.md

The same SKILL.md was published earlier as 2428424081cn/skill-mcp/typescript-strict-guard.

TypeScript 严格类型防御准则

在生成任何 TypeScript 代码时,AI 必须严格执行零妥协(Zero-Tolerance)类型安全规则。

一、 铁律(Zero Tolerance)

  1. 严禁 `any`:绝对禁止直接或间接使用 any。未知数据必须使用 unknown 并通过 Type Guard / Zod 校验收窄。
  2. 严禁不安全断言:禁止使用 as unknown as T 或随意使用非空断言 !(除非能严格证明其前置不变式)。
  3. 强制导出显式返回类型:所有导出的函数、类方法必须显式标注返回类型,严禁依赖隐式推导。
  4. 不可变数据优先:对象数组参数优先标注 readonly T[] 或 Readonly<T>,禁止在函数内直接 mutate 入参。

二、 核心设计模式要求

  • Discriminated Unions(可辨识联合):状态模型必须通过唯一的 kind / status / type 字段进行状态分支隔离。
  • `satisfies` 优于类型标注:在需要保留字面量类型且满足契约时,优先使用 satisfies 操作符。

三、 范例对比

  • ❌ 反例:
typescript
function handleData(data: any) {
return (data as any).user.name!;
}
  • ✅ 正例:
typescript
interface UserData {
user: { name: string };
}
function isUserData(obj: unknown): obj is UserData {
return typeof obj === "object" && obj !== null && "user" in obj;
}
export function handleData(raw: unknown): string {
if (!isUserData(raw)) throw new Error("Invalid payload");
return raw.user.name;
}

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/2428424081cn/skill-mcp/typescript-strict-guard/badge)](https://verified-skill.com/skills/2428424081cn/skill-mcp/typescript-strict-guard)

Something wrong with this skill or its page? Tell us.