typescript-coding-standards

Reviews and guides TypeScript code toward typed errors, boundary parsing, and safe domain modeling.

Updated May 27, 2026
One-click install
npx skills add https://github.com/ybaspinar/agent-work-skills --skill typescript-coding-standards-ybaspinar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-coding-standards
Source: https://github.com/ybaspinar/agent-work-skills/tree/main/skills/typescript-coding-standards
Command: npx skills add https://github.com/ybaspinar/agent-work-skills --skill typescript-coding-standards-ybaspinar

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript codebases often let raw DTOs, untyped exceptions, boolean state bags, and module-mocked tests erode correctness over time. This Skill gives an agent a concrete standards checklist so every new module, endpoint, adapter, or test pushes invalid data to the boundaries and makes expected failures part of the type signature. ## Core Features & Use Cases - Typed error handling: Return Result<T, E> or Effect values for expected failures and reserve throws for unrecoverable defects. - Boundary parsing and domain types: Parse untrusted input early into branded/refined types like EmailAddress or UserId instead of passing raw DTOs through core logic. - Adapter and dependency discipline: Audit existing adapters before creating new ones, inject narrow dependency interfaces, and record meaningful new services in an ADR. - Testing and config standards: Replace vi.mock/jest.mock module mocks with real seams and fakes, and parse config and secrets at startup with Redacted<T> wrappers. - Use Case: When reviewing a PR that adds a displayName field via JSON.parse(req.body) with truthy checks, the Skill directs the reviewer to parse the touched boundary into a domain type, return a typed error, and translate it at the existing framework boundary. ## Quick Start Ask the agent to review your TypeScript change or new module against these coding standards before committing it.

Frequently Asked Questions about typescript-coding-standards

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

FAQPage Schema
How do I handle expected errors in TypeScript without throwing exceptions?

Return typed error values such as Result<T, E>, Effect, or better-result for expected failures like parsing, validation, and I/O errors. Reserve throw and rejected promises for unrecoverable defects like violated invariants or startup misconfiguration.

What is parse-don't-validate in TypeScript?

Parse-don't-validate means converting unknown input into branded domain types at the system boundary rather than passing raw DTOs through core logic. Use schema libraries like Zod or Effect Schema at edges, then work with refined types like EmailAddress internally.

Should I use vi.mock or jest.mock for TypeScript unit tests?

Avoid vi.mock and jest.mock module mocks for new behavior. Instead inject dependencies through constructors, use in-memory fakes or local adapters, and assert observable behavior like returned values, persisted state, or recorded sent messages.

When should I create a new adapter versus reuse an existing one?

Audit existing adapters first: reuse one through a narrow dependency interface, or extend it only if the method fits its cohesive capability. Create a new adapter only when reuse would cause bad coupling, and record meaningful new services in an ADR.

How do I safely read environment variables and secrets in TypeScript?

Parse all config at startup into typed configuration with branded and Redacted-wrapped secret values, failing fast with useful context when values are missing. Never read process.env scattered through application code or use non-null assertions on secrets.

When should I not apply these TypeScript coding standards?

Do not use them to rewrite an entire codebase during an unrelated change. Follow local conventions first, improve only the touched code, and translate typed errors to existing framework exception behavior at boundaries instead of forcing broad migrations.