fail-fast

Enforce fail-fast error handling with throw/catch patterns in APIs and services.

13|2|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/yanko-belov/code-craft --skill fail-fast
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fail-fast
Source: https://github.com/yanko-belov/code-craft/tree/main/skills/fail-fast
Command: npx skills add https://github.com/yanko-belov/code-craft --skill fail-fast

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enforces fail-fast error handling to surface failures immediately and prevent silent corruption.

Core Features & Use Cases

  • Fail fast: throw errors at the point of failure rather than swallowing or returning defaults.
  • Propagate: errors flow to boundaries (API, UI) where they can be translated to meaningful responses.
  • Apply across: useful for input validation, invariants, and critical operations in APIs, services, and background jobs.
  • Use case: When processing a payment, a missing user or invalid card should throw an error rather than returning a false result.

Quick Start

Apply the fail-fast pattern to a function that handles critical operations to ensure invalid inputs throw immediately and errors propagate to the API boundary.

Frequently Asked Questions about fail-fast

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

FAQPage Schema
How do I implement fail-fast error handling in TypeScript APIs?

Fail-fast error handling in TypeScript APIs validates inputs and asserts invariants by throwing well-defined error types immediately at the point of failure, propagating them to the API boundary rather than returning defaults.

Why should errors propagate to boundaries instead of returning default values?

Errors should propagate to boundaries to surface failures immediately and prevent silent data corruption. Swallowing errors or returning defaults masks critical failures, such as missing users during payment processing, making debugging difficult.

When should I use the fail-fast pattern for error handling in services?

Use the fail-fast pattern in services and background jobs for critical operations like input validation, invariant checking, and payment processing where silent failures or default values would cause data corruption or incorrect business logic.

Do I need external libraries to enforce fail-fast error handling?

No external libraries are required to enforce fail-fast error handling. The approach uses conventional throw/catch patterns and well-defined error types natively available in TypeScript to validate inputs and propagate errors to interaction boundaries.

What is the best way to handle invalid inputs in console apps without swallowing errors?

The best way to handle invalid inputs in console apps without swallowing errors is to throw well-defined error types immediately at the point of detection, letting the error propagate to the console interaction boundary for meaningful display.

When should I not use the fail-fast approach for error handling?

Avoid the fail-fast approach when default values or graceful degradation are explicitly desired for non-critical operations, as this pattern strictly throws errors to surface failures immediately rather than allowing the process to continue with fallback data.