typescript-rust-pattern

Apply Rust-inspired safety patterns to TypeScript codebases.

10|Updated Jul 7, 2020
One-click install
npx skills add https://github.com/ghaerdi/dotfiles --skill typescript-rust-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-rust-pattern
Source: https://github.com/ghaerdi/dotfiles/tree/main/opencode/.agents/skills/typescript-rust-pattern
Command: npx skills add https://github.com/ghaerdi/dotfiles --skill typescript-rust-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @ghaerdi/rustify, zod, yup, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps TypeScript developers write more robust and maintainable code by applying safety patterns inspired by Rust's type system.

Core Features & Use Cases

  • Discriminated Unions: Eliminate impossible states and enforce exhaustive checks.
  • Result Types: Handle errors explicitly and make failure paths visible.
  • Boundary Validation: Validate data once at the system boundary for reliability.
  • Explicit Mutability: Control and document when functions mutate data.
  • Use Case: Ideal for refactoring legacy TypeScript code or developing new applications that require high safety and reliability standards.

Quick Start

Run the 'typescript-rust-pattern' skill to apply Rust-inspired patterns to your TypeScript codebase.

Frequently Asked Questions about typescript-rust-pattern

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

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

To handle errors explicitly in TypeScript, you can apply Rust-inspired Result types to make failure paths visible, forcing the caller to handle both success and error outcomes instead of relying on exceptions.

What is the best way to eliminate impossible states in a TypeScript codebase?

Eliminating impossible states in TypeScript is achieved by applying discriminated unions, which enforce exhaustive type checks and structurally prevent invalid data combinations at compile time.

How do I validate data at the boundary in TypeScript for better reliability?

Validating data at the TypeScript system boundary involves checking inputs once upon entry, ensuring internal code processes only trusted data for improved reliability and safety.

Does this TypeScript safety approach work with validation libraries like zod and yup?

Yes, this approach to TypeScript code safety integrates with validation libraries like zod and yup to validate data at the boundary and enforce system reliability.

When should I use Rust-inspired patterns in my TypeScript application?

Use Rust-inspired patterns in TypeScript when developing new applications or refactoring legacy code that requires high safety, explicit error handling, and strict maintainability standards.