MCPInstall

typescript-patterns

Advanced TypeScript patterns for strict mode development. Covers type utilities (Pick, Omit, Partial, Record, Awaited), generics with constraints and inference, type guards and narrowing, discriminated unions, conditional and mapped types, template literal types, const assertions, satisfies operator, module patterns, and modern JavaScript idioms (eslint-plugin-unicorn). Use when building type-safe APIs, preventing runtime errors through types, working with strict TypeScript configuration, debugging complex type errors, or enforcing modern JS idioms. Use for generics, type guards, utility types, strict mode, type inference, narrowing, type safety, const assertions, satisfies, module augmentation, unicorn, for-of, modern-js.

Installs
182
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/oakoss/agent-skills --skill typescript-patterns
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads typescript-patterns automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

TypeScript Patterns

Overview

Advanced TypeScript patterns that use the type system to prevent runtime errors. Focuses on strict mode TypeScript with patterns for type inference, narrowing, and compile-time validation. Not a beginner tutorial.

When to use: Building type-safe APIs, complex data transformations, library authoring, preventing runtime errors through types, working with strict mode flags.

When NOT to use: Learning TypeScript basics (primitives, interfaces, classes), JavaScript-to-TypeScript migration guidance, tooling setup, or build configuration.

Quick Reference

PatternAPIKey Points
Utility typesPick<T, K>, Omit<T, K>Extract or exclude properties
Partial/RequiredPartial<T>, Required<T>Make properties optional or required
Record typeRecord<K, V>Object with known keys
Awaited typeAwaited<T>Unwrap Promise return types
ReturnType/ParametersReturnType<F>, Parameters<F>Extract function types
Generic constraints<T extends Type>Constrain generic parameters
Type inferencetype Inferred = typeof valueLet TypeScript infer from values
Type guardstypeof, instanceof, inNarrow types at runtime
Custom type guards(x): x is TypeUser-defined narrowing functions
Inferred predicates(x) => x !== nullAuto-inferred type predicate filters
Discriminated unionsUnion with literal type propertyExhaustive pattern matching
Conditional typesT extends U ? X : YType-level conditionals
Mapped types{ [K in keyof T]: T[K] }Transform all properties
Template literals`${A}-${B}`String literal type manipulation
Const assertionsas constNarrowest possible literal types
Satisfies operatorvalue satisfies TypeType check without widening
NoInfer utilityNoInfer<T>Prevent inference from a position
Const type params<const T extends Type>Narrow inference without as const
Inline type importsimport { type User }Import types explicitly
Module augmentationdeclare module 'lib' { ... }Extend third-party types
Assertion functionsfunction assert(x): asserts x is TThrow if type guard fails

Common Mistakes

MistakeCorrect Pattern
Using any without justificationUse unknown and narrow with type guards
Manual type assertions everywhereLet inference work, type function returns
Destructuring before type narrowingKeep object intact for discriminated unions
Index access without undefined checkEnable noUncheckedIndexedAccess
as Type casting unsafe valuesUse satisfies Type to preserve narrow types
Inline objects in genericsExtract to const or type alias
Omitting extends in constraintsAlways constrain generics when possible
Using Parameters<typeof fn>[0]Type the parameter directly in function
Not handling union exhaustivenessUse never checks in switch/if-else
value as const satisfies TypeUse satisfies Type then as const if needed

Delegation

  • Pattern discovery: Use Explore agent to find existing patterns in codebase
  • Type error debugging: Use Task agent for multi-step type resolution
  • Code review: Delegate to code-reviewer skill for type safety audit

References

  • Type utilities (Pick, Omit, Partial, Required, Record, Extract, Exclude, ReturnType, Parameters, Awaited)
  • Generics (constraints, inference, default parameters, variance)
  • Type guards and narrowing (typeof, instanceof, in, custom guards, assertion functions)
  • Discriminated unions (exhaustive checking, never type, tagged unions)
  • Conditional types (distributive conditionals, infer keyword, type-level logic)
  • Mapped types (key remapping, template literals, modifiers)
  • Strict mode patterns (noUncheckedIndexedAccess, exactOptionalPropertyTypes, const assertions, satisfies)
  • Module patterns (inline type imports, declaration files, module augmentation, ambient types)
  • Modern idioms (eslint-plugin-unicorn patterns, modern array/string/DOM APIs, ES modules)

FAQ

What does the typescript-patterns skill do?

Advanced TypeScript patterns for strict mode development. Covers type utilities (Pick, Omit, Partial, Record, Awaited), generics with constraints and inference, type guards and narrowing, discriminated unions, conditional and mapped types, template literal types, const assertions, satisfies operator, module patterns, and modern JavaScript idioms (eslint-plugin-unicorn). Use when building type-safe APIs, preventing runtime errors through types, working with strict TypeScript configuration, debugging complex type errors, or enforcing modern JS idioms. Use for generics, type guards, utility types, strict mode, type inference, narrowing, type safety, const assertions, satisfies, module augmentation, unicorn, for-of, modern-js.

How do I install typescript-patterns?

Run npx skills add https://github.com/oakoss/agent-skills --skill typescript-patterns in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/typescript-patterns/ (personal) or .claude/skills/typescript-patterns/ (project).

Which AI agents can use typescript-patterns?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is typescript-patterns safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains typescript-patterns?

It is published by oakoss in oakoss/agent-skills. It has 182 recorded installs.

More from oakoss/agent-skills

View all →

ui-ux-polish

oakoss/agent-skills

Iterative UI/UX polishing workflow for web applications. Use when improving visual polish, refining desktop and mobile UX separately, running iterative enhancement cycles, applying design patterns like glassmorphism or bento grids, or auditing accessibility and WCAG compliance. Use for Stripe-level visual quality, responsive optimization, and design system alignment.

Frontend & Design541 installs

playwright

oakoss/agent-skills

Open the skill to read its SKILL.md instructions.

Testing & QA453 installs

coolify

oakoss/agent-skills

Coolify self-hosted PaaS for deploying applications, databases, and services via REST API and Git integration. Covers API authentication, deployment triggers, build packs (Nixpacks, Dockerfile, Compose), CI/CD with GitHub Actions webhooks, environment management, and Traefik proxy configuration. Use when deploying apps to Coolify, triggering deployments via API, configuring build packs, setting up GitHub Actions CI/CD pipelines, managing environment variables, or troubleshooting deployment failures.

DevOps & Cloud361 installs

application-security

oakoss/agent-skills

Application security covering threat modeling (STRIDE), OWASP Top 10 (2025), OWASP API Security Top 10 (2023), secure coding review, authentication/authorization patterns, input validation, encryption, security headers, supply chain security, compliance (GDPR/HIPAA/SOC2/PCI-DSS), and security monitoring. Use when reviewing code for vulnerabilities, implementing auth patterns, securing APIs, configuring security headers, hardening supply chain, preventing injection attacks, or preparing for compliance audits.

Security272 installs

find-skills

oakoss/agent-skills

Discovers and installs agent skills from the open ecosystem. Enriches search results with descriptions fetched from skills.sh. Use when a user asks "how do I do X", "find a skill for X", "is there a skill that can...", or wants to extend agent capabilities. Use for skill discovery, skill search, skill install, finding tools.

AI & Agents256 installs

drizzle-orm

oakoss/agent-skills

Open the skill to read its SKILL.md instructions.

Data & Databases238 installs

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.