typescript

Enforces schema-first, strictly typed, immutable TypeScript coding practices during writing and review.

3|Updated Nov 8, 2014
One-click install
npx skills add https://github.com/mintuz/.dotfiles --skill typescript-mintuz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/mintuz/.dotfiles/tree/main/agents/.agents/skills/typescript
Command: npx skills add https://github.com/mintuz/.dotfiles --skill typescript-mintuz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires zod, and includes references (resource) components.

What problem does it solve? TypeScript codebases often accumulate unsafe patterns like any types, unvalidated external data, and accidental mutation, leading to runtime crashes and hard-to-trace bugs. This Skill provides a consistent rulebook for writing and reviewing TypeScript with strict type safety, runtime validation at trust boundaries, and immutable data patterns. ## Core Features & Use Cases - Schema-First Validation: Guides defining schemas (e.g., with Zod) at trust boundaries like API responses, user input, and file parsing, deriving types from schemas instead of duplicating declarations. - Strict Typing Rules: Enforces unknown over any, type for data and interface only for behavior contracts, and disciplined use of type assertions with documented checks. - Immutability and Error Handling: Provides patterns for readonly structures, non-mutating array operations, Result types for failures, options objects, and early returns. - Use Case: When reviewing a pull request that fetches data from an external API, use this Skill to ensure the response is validated with a schema, typed via inference, and handled immutably with explicit error contracts. ## Quick Start Review this TypeScript API handler using the typescript skill and fix any type safety or validation issues.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I validate API responses in TypeScript?▼

Validate API responses with a schema library like Zod at the trust boundary, then derive the TypeScript type from the schema using z.infer. If no schema library is available, write a decoder that accepts unknown and narrows each field with typeof checks.

When should I use type vs interface in TypeScript?▼

Use type for data structures, unions, and utility type compositions. Reserve interface for behavior contracts that classes implement, such as loggers or repositories in dependency injection patterns.

Should I use any or unknown in TypeScript?▼

Never use any, since it disables type checking entirely. Use unknown for truly unknown values, which forces you to validate or narrow the value with type guards before using it.

How do I handle errors without throwing exceptions in TypeScript?▼

Use a Result type with success and failure variants so callers handle errors through the function's contract. TypeScript narrows the union, giving safe access to either the data or the error after a check.

When is a schema not needed in TypeScript?▼

Plain types suffice for internal code with no external data, such as utility types, component props, state machines, and behavior contracts. Schemas are required only when data crosses trust boundaries or carries validation rules like formats and ranges.

Why avoid mutating array methods like push in TypeScript?▼

Mutating a caller-owned array causes unpredictable side effects, so prefer spread-based alternatives like [...arr, item]. The exception is a local accumulator created inside the function, where push is safe and avoids quadratic copying in loops.