typescript

Enforce TypeScript strict patterns and best practices to reduce runtime errors.

1|Updated Jan 18, 2026
One-click install
npx skills add https://github.com/valec3/AGENTS.md --skill typescript-valec3
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/valec3/AGENTS.md/tree/main/REFERENCES/GentlemanProgramming/skill/typescript
Command: npx skills add https://github.com/valec3/AGENTS.md --skill typescript-valec3

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript projects often struggle with inconsistent typing, fragile interfaces, and bloated code when type hints leak into runtime. This Skill provides clear patterns and guidelines to write safer, maintainable TypeScript code.

Core Features & Use Cases

  • Const Types Pattern: create runtime values once and derive types from them to ensure a single source of truth.
  • Flat Interfaces: prefer single-level interfaces with separate types for nested structures to improve readability and refactorability.
  • Never Use any: replace any with unknown and use generics for flexibility while preserving type safety.
  • Utility Types: leverage Pick, Omit, Partial, Required, Readonly, Record, Extract, Exclude, NonNullable, ReturnType, Parameters to shape types.
  • Type Guards & Import Types: implement runtime guards and use import type for type-only imports to optimize bundles.
  • Use-cases: improved API boundaries, safer data parsing, and easier refactoring in large TS projects.

Quick Start

Refactor a sample TypeScript module to apply const types pattern, create flat interfaces, replace any with unknown, and incorporate utility types and a type guard.

Frequently Asked Questions about typescript

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

FAQPage Schema
What is the best way to replace any in TypeScript to maintain type safety?

To maintain type safety in TypeScript, replace any with unknown and apply generics for flexibility. Implement type guards to narrow unknown values down to specific shapes at runtime safely.

How do I design flat TypeScript interfaces for nested data structures?

Design flat TypeScript interfaces by keeping them single-level and creating separate types for nested structures. This prevents deeply nested interface definitions and improves code refactorability.

How do I use const assertions to create a single source of truth for TypeScript types?

Apply const assertions to define runtime values once and derive TypeScript types directly from them. This pattern ensures your types and values stay synchronized automatically across the codebase.

When should I use import type for type-only imports?

Use import type for type-only imports when you want to optimize bundle sizes and ensure type definitions do not leak into runtime code. It removes type imports entirely during compilation.

Which TypeScript utility types should I use to shape existing interfaces?

Use TypeScript utility types like Pick, Omit, Partial, Required, and Readonly to shape existing interfaces. They allow you to modify type definitions without duplicating property structures manually.

Can I refactor a TypeScript module to apply strict typing patterns without breaking existing API boundaries?

Yes, you can refactor a TypeScript module by applying the const types pattern, creating flat interfaces, and replacing any with unknown. This improves API boundaries and enables safer data parsing.