VALIDATION-type-assertions

Community

Master safe type assertions, avoid runtime crashes.

Authordjankies
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Misusing as Type on unvalidated external data bypasses TypeScript's safety, leading to runtime crashes when data structures don't match expectations. This Skill clarifies when assertions are safe and when they are dangerous.

Core Features & Use Cases

  • Assertion Safety Decision Tree: Guides you through determining if an assertion is safe based on data origin and validation status.
  • Dangerous Assertions: Identifies and prohibits unsafe practices like asserting external API data, JSON.parse results, or user input without prior validation.
  • Safe Assertions: Demonstrates acceptable uses of assertions, such as as const for hardcoded data or after thorough runtime validation.
  • Double Assertion Anti-Pattern: Exposes and prevents the as unknown as Type pattern, which intentionally bypasses type safety.
  • Use Case: Refactor src/utils/dataParser.ts to remove unsafe type assertions on JSON parsed data, replacing them with proper runtime validation using type guards or a validation library, ensuring runtime stability.

Quick Start

Analyze the src/api/client.ts file for as User assertions on API responses and suggest replacing them with runtime validation.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: VALIDATION-type-assertions
Download link: https://github.com/djankies/claude-configs/archive/main.zip#validation-type-assertions

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.