typescript-javascript-coding-patterns

Define TypeScript/JavaScript coding patterns for validation, typing, and async coordination.

33|6|Updated Oct 9, 2025
One-click install
npx skills add https://github.com/CraftsMan-Labs/SimpleAgents --skill typescript-javascript-coding-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-javascript-coding-patterns
Source: https://github.com/CraftsMan-Labs/SimpleAgents/tree/main/.opencode/skills/typescript-javascript-coding-patterns
Command: npx skills add https://github.com/CraftsMan-Labs/SimpleAgents --skill typescript-javascript-coding-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

TypeScript and JavaScript projects often suffer from weak runtime contracts, unsafe type assertions, and unbounded async behavior. This skill provides structured coding patterns to enforce explicit boundaries, reliable concurrency controls, and maintainable interfaces across Node, browser, edge, and shared-library code.

Core Features & Use Cases

  • Runtime and type boundaries: enforce strict input validation at boundaries using TypeScript settings and validation libraries, preventing leakage of untrusted data into core logic.
  • API and module design: emphasize pure functions, discriminated unions for state, and clear, surface-level contracts to minimize cross-module coupling.
  • Use Case: when implementing or reviewing a TS/JS module, apply these patterns to ensure predictable behavior, safer error handling, and easier testing.

Quick Start

Apply strict type boundaries to a sample TS module and run the unit tests.

Frequently Asked Questions about typescript-javascript-coding-patterns

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

FAQPage Schema
How do I enforce strict type boundaries and runtime validation in TypeScript modules?

Enforce strict type boundaries by applying validation libraries at module edges to intercept untrusted data, ensuring runtime checks match compile-time types before data enters core logic.

What is the best way to handle async coordination and concurrency in JavaScript across different environments?

The best way to manage async coordination in JavaScript is implementing bounded concurrency patterns with standardized error handling and observability guidance, ensuring predictable behavior across Node, browser, and edge contexts.

How do I design maintainable TypeScript APIs with clear module contracts?

Design maintainable TypeScript APIs by emphasizing pure functions and discriminated unions for state management, establishing clear surface-level contracts that minimize cross-module coupling and simplify testing.

Can I use these TypeScript coding patterns for refactoring existing JavaScript codebases?

Yes, you can apply these coding patterns during JavaScript refactoring to introduce explicit boundaries, reliable concurrency controls, and strict typing incrementally, improving reliability and maintainability without full rewrites.

Why does unbounded async behavior cause reliability issues in TypeScript and JavaScript applications?

Unbounded async behavior causes reliability issues because it allows concurrent operations to execute without limits, leading to race conditions and resource exhaustion; bounded async coordination with observability prevents these failures.