@poteto/ts-best-practices

Orchestrate agents using skills

View in AI SkillSafe app
Scanned · no findings
0 stars
SKILL.md
namets-best-practices
description>

Type Safety

This project's TypeScript policy. Apply when writing or reviewing TypeScript.

Rule Summary
No as casts Every as is a potential runtime crash. Validate at boundaries, then cast only if earned. Prefer Zod/Valibot over manual validation.
unknown over any any disables type checking for everything it touches. External data is always unknown.
Discriminated unions Model variants with a shared literal discriminant. No optional-field bags.
Narrowing hierarchy Prefer: discriminated union switch > in operator > typeof/instanceof > type guard > as
Type guards Must actually verify the claim. Name them isX or hasX. Prefer discriminant narrowing when possible.
Exhaustiveness checks Always add default: never arm to switches over discriminated unions. Use an absurd() helper to reduce boilerplate.
satisfies over as When verifying a value matches a type without widening, use satisfies to preserve literal types.
Impossible states If a bug requires asking "can this combination happen?" the type is too loose. Tighten it.

Read references/patterns.md for code examples of each rule.

Embed badges

Add these to your README to show the skill's verification status.

SkillSafe verified badge
Verified badge
[![SkillSafe verified badge](https://api.skillsafe.ai/v1/badge/@poteto/ts-best-practices/verified)](https://skillsafe.ai/skill/@poteto/ts-best-practices/)
Installs badge
Installs badge
[![Installs badge](https://api.skillsafe.ai/v1/badge/@poteto/ts-best-practices/installs)](https://skillsafe.ai/skill/@poteto/ts-best-practices/)
Scan badge
Scan badge
[![Scan badge](https://api.skillsafe.ai/v1/badge/@poteto/ts-best-practices/scan)](https://skillsafe.ai/skill/@poteto/ts-best-practices/)
Eval pass rate badge
Eval pass rate
[![Eval pass rate badge](https://api.skillsafe.ai/v1/badge/@poteto/ts-best-practices/eval)](https://skillsafe.ai/skill/@poteto/ts-best-practices/)