typescript-runtime-boundary-modeling

Designs runtime trust boundaries that convert unknown TypeScript input into validated internal types.

1|1|Updated Apr 8, 2026
One-click install
npx skills add https://github.com/GonkaGate/opencode-setup --skill typescript-runtime-boundary-modeling-gonkagate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-runtime-boundary-modeling
Source: https://github.com/GonkaGate/opencode-setup/tree/main/.agents/skills/typescript-runtime-boundary-modeling
Command: npx skills add https://github.com/GonkaGate/opencode-setup --skill typescript-runtime-boundary-modeling-gonkagate

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Untrusted data from HTTP requests, environment variables, external APIs, databases, caches, JSON.parse, and catch blocks often leaks into TypeScript code as any or unchecked casts, making type safety an illusion. This Skill forces disciplined reasoning about exactly where runtime data becomes trustworthy, what gets validated, and which policies govern unknown keys, normalization, and failure handling. ## Core Features & Use Cases - Boundary Design Workflow: A step-by-step pass that names the untrusted source, states the exact trusted claim, picks the minimal checked surface, and chooses between manual guards, assertion functions, schema-derived parsers, or boundary mappers. - Policy Decision Guidance: Concrete rules for throw versus structured result, reject versus strip versus passthrough for unknown keys, sync versus async parsing, and where normalization should live. - Trust-Leak Detection: Red-flag catalogs for as any, postfix !, truthiness narrowing, top-level-only validation, and DTO or DB record types leaking into core domain code. - Use Case: When a user says "make this API payload type-safe" or "why is unknown leaking from my cache reader", the Skill produces a concrete boundary design with a named parser signature like parseX(input: unknown): TrustedX, explicit unknown-key policy, and an honest confidence assessment. ## Quick Start Ask the assistant to design a validation boundary for an untrusted input, for example: "Design a runtime boundary that parses this external API response into a trusted internal type in strict-mode TypeScript."

Frequently Asked Questions about typescript-runtime-boundary-modeling

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

FAQPage Schema
How do I validate unknown input in strict-mode TypeScript?

Accept the input as `unknown` at the runtime edge, then prove the exact fields the next layer relies on using a manual guard, assertion function, or schema-derived parser. Export only the trusted output shape, for example `parseX(input: unknown): TrustedX`, and keep raw DTO or record types out of core code.

When should I use a schema library versus manual type guards?

Use manual guards when the shape is tiny, the proof fits in one readable function, and unknown-key policy is trivial. Choose schema-derived parsing when the shape is nested or reused, the trusted type should derive from the runtime proof, or unknown-key and transform policies must be explicit.

Should a validation boundary throw or return a result type?

Throw when the boundary is terminal for the request path and a central error handler owns failure rendering. Return a structured result like `Result<TrustedX, Issues>` when the caller must branch on parse success or accumulate multiple validation failures.

Why is `as unknown as T` dangerous at runtime boundaries?

Type assertions add no runtime checks, so `as unknown as T` lets unvalidated data cross the trust boundary invisibly. The same applies to `as any` and postfix `!`; trust must come from an actual parse or guard that runs before the type is claimed.

How should process.env be typed in a Node.js TypeScript app?

Treat `process.env` as string input, not typed config. Parse it once in a dedicated startup config module, apply defaults and number or URL coercion there, and export only the resulting trusted config object to the rest of the application.

What unknown-key policy should a parser use: reject, strip, or passthrough?

Reject when extra keys likely indicate caller error or dangerous drift. Strip when you want a stable minimal internal shape and leniency is acceptable. Use passthrough only when preserved fields stay explicitly untrusted and downstream code never treats the whole object as trusted.