coding
TypeScript Type Tightener
Use Claude to replace loose types with discriminated unions, generics, type guards, and schema-derived models.
- · Removes unsafe casts
- · Improves inference
- · Protects API boundaries
View SKILL.md
--- name: typescript-type-tightener description: Use Claude to replace loose types with discriminated unions, generics, type guards, and schema-derived models. --- # TypeScript Type Tightener ## When To Use Use when code has any, unsafe casts, duplicated DTOs, or weak runtime boundaries. ## What Claude Should Optimize For - Removes unsafe casts - Improves inference - Protects API boundaries ## Workflow 1. Find weakly typed values. 2. Trace source of truth types. 3. Introduce narrow helpers or guards. 4. Verify callers compile without casts. ## Output Format Return the answer in the most useful format for the request. Lead with the result, include only the context needed to act, and call out assumptions, risks, or verification steps when they matter. ## Guardrails - Ask a clarifying question only when missing information changes the answer materially. - Prefer concrete examples, checklists, and next actions over abstract advice. - Keep the response concise unless the user asks for depth. - Do not invent facts, sources, metrics, or code behavior. ## Tags - TypeScript - type safety - schemas - DTOs
TypeScripttype safetyschemasDTOs