reviewing-type-safety

thkt's avatarfrom thkt

TypeScript type safety patterns and best practices for maximum type coverage. Triggers: 型安全, type safety, any, unknown, 型推論, 型ガード, type guard, discriminated union, 判別可能なUnion, strictNullChecks, 型定義, 型カバレッジ, TypeScript, 暗黙のany, implicit any, 型アサーション, type assertion.

⭐3stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026⬇️1downloads

When & Why to Use This Skill

This Claude skill specializes in enhancing TypeScript code quality by implementing rigorous type safety patterns and best practices. It helps developers achieve maximum type coverage by identifying and replacing unsafe 'any' types with robust type guards, enforcing strict null checks, and ensuring exhaustive pattern matching. By automating the detection of implicit types and missing annotations, it streamlines the code review process and minimizes runtime errors in enterprise-level applications.

Use Cases

  • Refactoring legacy TypeScript projects: Systematically identifying and eliminating 'any' types and type assertions to improve codebase maintainability.
  • Automated Code Quality Audits: Reviewing pull requests to ensure compliance with strict mode settings and achieving a type coverage threshold of 95% or higher.
  • Type-Safe Data Handling: Implementing custom type guard functions and discriminated unions to safely process external API data or complex state objects.
  • Exhaustiveness Checking: Utilizing 'assertNever' patterns in switch-case statements to ensure all possible union types are handled, preventing logic gaps during future updates.
namereviewing-type-safety
description>
allowed-tools[Read, Grep, Glob, Task]
agenttype-safety-reviewer
contextfork
user-invocablefalse

Type Safety Review

Detection

ID Pattern Fix
TS1 any unknown + type guard
TS1 Implicit any Explicit type annotation
TS2 value as Type Type guard function
TS2 value! (non-null assertion) Explicit null check
TS3 function fn(data) (untyped) function fn(data: Type)
TS3 Missing return type Explicit : ReturnType
TS4 default: without exhaustive default: assertNever(value)

Criteria

Type coverage >= 95%. Any usage = 0. Strict mode all enabled.

References

Topic File
Coverage references/type-coverage.md
Guards references/type-guards.md
Strict references/strict-mode.md
Result references/result-type.md