auto-typescript
Installation
SKILL.md
TypeScript — Type Safety Discipline
Claude writes TypeScript that compiles but lies about types. Your most common failure: reaching for as any or as unknown as X when you can't immediately figure out the correct type. This skill fixes that and covers the patterns you don't reach for unprompted.
The Cardinal Rule: No Lying to the Compiler
Every type assertion (as X) is a claim: "I know better than the compiler." Most of the time, you don't — you're just silencing an error you haven't investigated.
Before writing any as assertion, ask: "Can I make the compiler agree with me instead?"
| You reach for... | Do this instead |
|---|---|
as any |
Fix the actual type. This is never acceptable in production code. |
as unknown as X |
Find the actual relationship between the types. Double-cast means your types are wrong. |
as X on a function return |
Add a return type annotation and fix the implementation. |
as X on an API response |
Parse with Zod or write a type guard. |
as X on a DOM element |
Use a type guard: if (el instanceof HTMLInputElement) |