Skip to content
Development
Skill

/typescript-patterns

TypeScript best practices and patterns. Use when writing TypeScript, fixing type errors, or working with generics.

From plugin
gsd-skill-creator
70102 skills61 agents26 commands1 MCP
Install
$ npx -y skills add Tibsfox/gsd-skill-creator --skill typescript-patterns --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/typescript-patterns

Context preview

The summary Claude sees to decide when to auto-load this skill.

TypeScript best practices and patterns. Use when writing TypeScript, fixing type errors, or working with generics.

SKILL.md

typescript-patterns.SKILL.md
name: typescript-patterns
description: TypeScript best practices and patterns. Use when writing TypeScript, fixing type errors, or working with generics.
version: 1.0.0
format: 2025-10-02
triggers:
  - "writing TypeScript, fixing type errors, or working with generics"
updated: 2026-04-25
status: ACTIVE

TypeScript Patterns

Type vs Interface

| Use Case | Prefer | |----------|--------| | Object shape | interface | | Union types | type | | Extending shapes | interface | | Intersection | type | | Tuple/primitives | type |

Key Patterns

**Discriminated Unions** — model state with tagged types:

type Result<T> = { ok: true; value: T } | { ok: false; error: Error };

**Type Guards** — narrow at runtime:

function isUser(obj: unknown): obj is User {
  return typeof obj === 'object' && obj !== null && 'id' in obj;
}

**Generic Constraints:**

function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] { return obj[key]; }

Utility Types

| Type | Purpose | |------|---------| | Partial\<T\> | All optional | | Required\<T\> | All required | | Pick\<T,K\> | Select properties | | Omit\<T,K\> | Remove properties | | Record\<K,V\> | Key-value map | | ReturnType\<T\> | Function return type |

Avoid

  • `any` — use `unknown` and narrow
  • Type assertions (`as`) — use type guards
  • `!` operator — handle null properly
  • Missing return types on complex functions
Read more
Ships withgsd-skill-creator

An adaptive learning and coprocessor architecture for Claude Code, built as an extension to GSD (open-gsd)

Get the whole plugin

Other skills on gsd-skill-creator.