invariant-hunter-ts

Audit TypeScript code for weak invariants and unnecessary type casts.

5|Updated Jan 14, 2026
One-click install
npx skills add https://github.com/skyosev/agent-skills --skill invariant-hunter-ts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: invariant-hunter-ts
Source: https://github.com/skyosev/agent-skills/tree/main/hunter-party-ts/invariant-hunter-ts
Command: npx skills add https://github.com/skyosev/agent-skills --skill invariant-hunter-ts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Audit TypeScript types for weak invariants — unnecessary casts, loose optionality, defensive ?./?? masking missing guarantees, leaky discriminated unions, and runtime checks the type system should enforce.

Core Features & Use Cases

  • Tightening a domain model after prototyping
  • Reducing as assertions and type casts across a codebase
  • Reviewing discriminated unions for completeness, drift, or ergonomics
  • Establishing a type-safety baseline before refactoring

Quick Start

Audit TypeScript code to enforce invariants at construction boundaries and minimize runtime checks.

Frequently Asked Questions about invariant-hunter-ts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I tighten TypeScript invariants and eliminate unnecessary type casts?

The best way to reduce TypeScript type assertions is to enforce validation at construction boundaries and replace defensive optional chaining with explicit undefined handling. This ensures the type system enforces guarantees instead of masking missing data with runtime checks.

Why does defensive optional chaining mask missing TypeScript guarantees?

Defensive optional chaining masks missing TypeScript guarantees by silently returning undefined instead of enforcing required data structures. Replacing loose optional chaining with construction-bound validation and explicit undefined handling ensures strict invariants and surfaces missing data immediately.

How do I review discriminated unions in TypeScript for completeness and drift?

Review discriminated unions for completeness by enforcing exhaustiveness checks and tightening construction boundaries. This prevents union drift and ensures that runtime guards are replaced by strict type system enforcement across optional fields and widespread type assertions.

Do I need construction-bound validation to establish a TypeScript type-safety baseline?

Yes, construction-bound validation is required to establish a TypeScript type-safety baseline. Validating data at construction boundaries allows you to eliminate defensive runtime checks, reduce loose optionality, and enforce strict invariants throughout the codebase.

When should I not use optional chaining and nullish coalescing in TypeScript?

You should not use optional chaining and nullish coalescing when masking missing guarantees during refactors or establishing a type-safety baseline. Disciplined use prevents these operators from hiding leaky discriminated unions and loose optionality that the type system should enforce.