poteto/noodle

ts-best-practices

TypeScript type safety guidelines for writing maximally type-safe code. Apply these patterns when writing or reviewing any TypeScript: discriminated unions, type narrowing, type guards, exhaustiveness checks, avoiding `as` casts, preferring `unknown` over `any`, and making impossible states unrepresentable. Use this skill whenever writing TypeScript code, reviewing TypeScript for type safety issues, or when the user mentions type safety, type narrowing, discriminated unions, or asks to make typ…

First seen Mar 3, 2026

Installation

$ npx skills add poteto/noodle --skill ts-best-practices

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from poteto/noodle · top by installs.

npx skills add poteto/noodle

Browse all from poteto/noodle

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 269
License LICENSE
Default branch main
Open issues 4
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,807 B
  • docs SUMMARY.md 550 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 103 installs

SKILL.md

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](references/patterns.md) for code examples of each rule.