Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
nickcrew avatar

Typescript Advanced Patterns

  • 5 installs
  • 28 repo stars
  • Updated June 29, 2026
  • nickcrew/claude-cortex

Helps with ai & agent building tasks.

About

typescript-advanced-patterns is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.

  • typescript-advanced-patterns
  • AI & Agent Building
  • AI-coding skill

Typescript Advanced Patterns by the numbers

  • 5 all-time installs (skills.sh)
  • Ranked #13,035 of 16,556 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/nickcrew/claude-cortex --skill typescript-advanced-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs5
repo stars28
Last updatedJune 29, 2026
Repositorynickcrew/claude-cortex

What it does

Helps with ai & agent building tasks.

Files

SKILL.mdMarkdownGitHub ↗

TypeScript Advanced Patterns

Expert guidance for leveraging TypeScript's advanced type system features to build robust, type-safe applications with sophisticated type inference, compile-time guarantees, and maintainable domain models.

When to Use This Skill

  • Building type-safe APIs with strict contracts and validation
  • Implementing complex domain models with compile-time enforcement
  • Creating reusable libraries with sophisticated type inference
  • Enforcing business rules through the type system
  • Building type-safe state machines and builders
  • Developing framework integrations requiring advanced types
  • Implementing runtime validation with type-level guarantees

Core Concepts

TypeScript's type system enables compile-time safety through:

1. Conditional Types: Type selection based on conditions (type-level if/else) 2. Mapped Types: Transform object types systematically (Partial, Readonly, Pick, Omit) 3. Template Literal Types: String manipulation at compile time 4. Type Guards: Runtime checking with type narrowing (value is Type) 5. Discriminated Unions: Type-safe state machines with exhaustiveness checking 6. Branded Types: Nominal types for preventing primitive mixing 7. Builder Pattern: Type-safe fluent APIs with progressive type constraints 8. Advanced Generics: Constraints, inference, and higher-kinded type patterns 9. Utility Types: Deep transformations and compositions 10. Type Inference: Const assertions and contextual typing

Quick Reference

Load detailed references on-demand:

TopicReference File
Conditional Typesskills/typescript-advanced-patterns/references/conditional-types.md
Mapped Typesskills/typescript-advanced-patterns/references/mapped-types.md
Template Literal Typesskills/typescript-advanced-patterns/references/template-literal-types.md
Type Guardsskills/typescript-advanced-patterns/references/type-guards.md
Discriminated Unionsskills/typescript-advanced-patterns/references/discriminated-unions.md
Branded Typesskills/typescript-advanced-patterns/references/branded-types.md
Builder Patternskills/typescript-advanced-patterns/references/builder-pattern.md
Advanced Genericsskills/typescript-advanced-patterns/references/advanced-generics.md
Utility Typesskills/typescript-advanced-patterns/references/utility-types.md
Type Inferenceskills/typescript-advanced-patterns/references/type-inference.md
Decoratorsskills/typescript-advanced-patterns/references/decorators.md
Performance Best Practicesskills/typescript-advanced-patterns/references/performance-best-practices.md
Common Pitfallsskills/typescript-advanced-patterns/references/common-pitfalls.md
Testing Typesskills/typescript-advanced-patterns/references/testing-types.md

Implementation Workflow

1. Identify Pattern Need

  • Analyze type safety requirements
  • Identify runtime vs compile-time constraints
  • Choose appropriate pattern from Quick Reference

2. Load Reference

  • Read specific reference file for pattern
  • Review examples and use cases
  • Understand trade-offs

3. Implement Pattern

  • Start simple, add complexity as needed
  • Use strict mode (tsconfig.json with "strict": true)
  • Test with type assertions

4. Validate

  • Ensure type errors caught at compile time
  • Verify runtime behavior matches types
  • Check performance (avoid excessive type complexity)

5. Document

  • Add JSDoc comments for public APIs
  • Document type constraints and assumptions
  • Provide usage examples

Common Mistakes to Avoid

1. Using `any` instead of `unknown`: Loses all type safety

  • Use unknown and type guards instead

2. Type assertions without validation: Unsafe runtime behavior

  • Prefer type guards (value is Type) over as Type

3. Overusing generics: Unnecessary complexity

  • Only use generics when types truly vary

4. Deep type nesting: Slow compilation, hard to debug

  • Keep types composable and shallow

5. Forgetting `readonly`: Accidental mutations

  • Mark immutable data structures as readonly

6. Not enabling strict mode: Missing null checks and type errors

  • Always use "strict": true in tsconfig.json

7. Mixing type and interface incorrectly: Confusing semantics

  • Use type for unions/utilities, interface for object shapes

Quick Patterns

Type-Safe ID

type UserId = string & { readonly __brand: 'UserId' };
function createUserId(id: string): UserId { return id as UserId; }

Discriminated Union

type State =
  | { status: 'loading' }
  | { status: 'success'; data: string }
  | { status: 'error'; error: Error };

Mapped Type Transformation

type Readonly<T> = { readonly [P in keyof T]: T[P] };
type Partial<T> = { [P in keyof T]?: T[P] };

Type Guard

function isString(value: unknown): value is string {
  return typeof value === 'string';
}

Resources

  • TypeScript Handbook: https://www.typescriptlang.org/docs/handbook/
  • Type Challenges: https://github.com/type-challenges/type-challenges
  • ts-toolbelt: Advanced type utilities library
  • zod: Runtime validation with TypeScript inference
  • tsd: Test TypeScript type definitions

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.