typescript

Enforce TypeScript type safety and naming conventions in code.

4|2|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/alexanderguy/skills --skill typescript-alexanderguy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/alexanderguy/skills/tree/main/skills/typescript
Command: npx skills add https://github.com/alexanderguy/skills --skill typescript-alexanderguy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript codebases often drift into unsafe patterns like any, brittle type assertions, non-null assertions, inconsistent naming, and unvalidated external data, which leads to bugs that only show up at runtime.

Core Features & Use Cases

  • Type safety guardrails: Encourages runtime validation for external inputs (fetch, filesystem, env vars, user input) using a validation library (e.g., zod/arktype/typebox) and provides patterns for type guards that narrow unknown safely.
  • Maintainable structure and naming: Defines conventions for file naming, type/interface naming, and function/variable prefixes (create*, is*, get*, lookup*, generate*, handle*), plus acronym casing rules (URL, HTTP, JSON, API, etc.).
  • Pragmatic correctness in error handling: Recommends rethrowing with { cause }, returning null when a request does not match a handler, and using a logger instead of console.log.
  • Import and async discipline: Promotes named exports (no default exports), type-only imports via import type, extension-free relative imports when possible, and careful use of dynamic imports.

Quick Start

Use the typescript skill to refactor a TypeScript file so it validates all external data at runtime and removes any, as, and non-null assertions while applying the repository’s naming and import conventions.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I remove any and type assertions from my TypeScript code?

To remove unsafe TypeScript patterns, replace any and type assertions with runtime validation schemas using libraries like zod, and use type guards to safely narrow unknown types. This ensures external data is verified before use.

What's the best way to validate external data in TypeScript?

The best way to validate external data in TypeScript is deriving types from runtime validation schemas using libraries like zod, arktype, or typebox. This guarantees that validated fetch responses, filesystem reads, and env vars match their static types.

How do I structure TypeScript imports for better type safety?

Structure TypeScript imports by using named exports instead of default exports, applying import type for type-only imports, and using extension-free relative imports. This import discipline prevents runtime circular dependencies and clarifies type boundaries.

Why should I use import type in TypeScript modules?

Use import type in TypeScript modules to ensure types are erased at compile time and not included in the runtime bundle. This discipline avoids unnecessary runtime dependencies and clarifies which imports are strictly for type checking.

How do I handle errors and logging conventions in TypeScript?

Handle errors in TypeScript by rethrowing them with a { cause } property to preserve stack traces, returning null when a request does not match a handler, and using a dedicated logger instead of console.log for structured output.

What naming conventions should I follow for TypeScript functions and interfaces?

Follow TypeScript naming conventions by prefixing functions with their action like create*, is*, get*, lookup*, generate*, or handle*, applying consistent acronym casing rules for terms like URL and HTTP, and standardizing file naming across the codebase.