typescript-best-practices

Enforce TypeScript type safety and error handling patterns in code.

Updated Mar 11, 2026
One-click install
npx skills add https://github.com/selfagency/agentsy --skill typescript-best-practices-selfagency
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-best-practices
Source: https://github.com/selfagency/agentsy/tree/main/.agents/skills/typescript-best-practices
Command: npx skills add https://github.com/selfagency/agentsy --skill typescript-best-practices-selfagency

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This skill helps reduce TypeScript code quality issues by guiding you toward stronger type safety, clearer architecture, and safer error handling patterns that prevent common bugs and runtime failures.

Core Features & Use Cases

  • Type safety guidance: Prefer unknown over any, use narrowing and typed guards, and avoid risky ! non-null assertions.
  • Robust error handling patterns: Adopt typed Result-style flows and structured error types/codes for predictable recovery paths.
  • Maintainable code organization: Promote single-concept modules, explicit exports, and consistent API/interface design.
  • Static analysis via scripts: Run a Deno-based analyzer to detect anti-patterns (e.g., any, @ts-ignore, eval, innerHTML assignments) across a file or directory.
  • Scaffolding and generation: Generate TypeScript types from JSON inputs and scaffold well-structured modules (including optional tests).

Quick Start

Ask: "Use typescript-best-practices to analyze ./src for TypeScript anti-patterns and suggest fixes for any issues you find."

Frequently Asked Questions about typescript-best-practices

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

FAQPage Schema
How do I find and fix TypeScript anti-patterns like `any` and `@ts-ignore` in my code?

TypeScript type safety is enforced by preferring `unknown` over `any`, using type narrowing and typed guards, and avoiding risky non-null assertions. This approach guides you toward stronger type safety that prevents common bugs and runtime failures.

What's the best way to handle errors in TypeScript to ensure predictable recovery?

The best way to handle errors in TypeScript is adopting typed `Result`-style flows and structured error types with specific codes. This ensures predictable recovery paths and prevents unhandled runtime failures across your modules.

How do I refactor JavaScript to TypeScript with strict type rules?

Yes, Deno supports deterministic TypeScript analysis workflows by running a static analyzer to detect anti-patterns across files or directories. This workflow applies strict type-safety rules to discourage known anti-patterns and ensure architecture consistency.

How do I generate TypeScript types from JSON inputs?

Generating TypeScript types from JSON inputs uses scaffolding workflows to produce well-structured modules with explicit exports. It supports creating single-concept modules with optional tests to maintain architecture-consistent APIs for any project scope.

What are the limitations of using non-null assertions in TypeScript?

Non-null assertions in TypeScript bypass compiler safety checks, creating runtime failure risks. The skill discourages known anti-patterns like `!` assertions and `@ts-ignore`, guiding you toward safer type narrowing and typed guards for robust error handling.