Fail Early Pattern

Apply the fail-early (fail-fast) pattern to detect and report errors at the earliest possible point. Covers input validation with guard clauses, meaningful error messages, assertion functions, and anti-patterns that silently swallow failures. Primary examples in R with general/polyglot guidance. Use when writing functions that accept external input, adding input validation before CRAN submission, refactoring code that silently produces wrong results, reviewing PRs for error-handling quality, or hardening internal APIs against invalid arguments.

45 stars 4 forksSoftware Development

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add pjt222/agent-almanac --skill fail-early-pattern
Manual install
git clone --depth 1 https://github.com/pjt222/agent-almanac.git /tmp/agent-almanac
mkdir -p ~/.claude/skills
cp -r /tmp/agent-almanac/i18n/caveman-lite/skills/fail-early-pattern ~/.claude/skills/fail-early-pattern

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Fail Early

If something is going to fail, it should fail as early as possible, as loudly as possible, with as much context as possible. This skill codifies the fail-early pattern: validating inputs at system boundaries, using guard clauses to reject bad state before it propagates, and writing error messages that answer *what* failed, *where*, *why*, and *how to fix it*.

## When to Use

- Writing or reviewing functions that accept external input (user data, API responses, file contents)
- Adding input validation to package functions before CRAN submission
- Refactoring code that silently produces wrong results instead of erroring
- Reviewing pull requests for error-handling quality
- Hardening internal APIs against invalid arguments

## Inputs

- **Required**: Function or module to apply the pattern to
- **Required**: Identification of trust boundaries (where external data enters)
- **Optional**: Existing error-handling code to refactor
- **Optional**: Target language (default: R; also applies to Python, TypeScript, Rust)

## Procedure

### Step 1: Identify Trust Boundaries

Map where external data enters the system. These are the points that need validation:

- Public API functions (exported functions in an R package)
- User-facing parameters
- File I/O (reading configs, data files, user uploads)
- Network responses (API calls, database queries)
- Environment variables and system configuration
Read the full skill on GitHub

Details

Skill name
fail-early-pattern
Path
i18n/caveman-lite/skills/fail-early-pattern/SKILL.md
License
MIT
Repo updated
18 November 2026

FAQ

What does the Fail Early Pattern skill do?

Apply the fail-early (fail-fast) pattern to detect and report errors at the earliest possible point. Covers input validation with guard clauses, meaningful error messages, assertion functions, and anti-patterns that silently swallow failures. Primary examples in R with general/polyglot guidance. Use when writing functions that accept external input, adding input validation before CRAN submission, refactoring code that silently produces wrong results, reviewing PRs for error-handling quality, or hardening internal APIs against invalid arguments.

How do I install the Fail Early Pattern skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add pjt222/agent-almanac --skill fail-early-pattern. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Fail Early Pattern popular?

It lives in pjt222/agent-almanac, which has 45 GitHub stars and 4 forks, and is included in 1 curated skill list.

Related skills

Adapt Architecture

45

pjt222/agent-almanac

Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation. Covers transformation planning, parallel running, progressive cutover, rollback design, and post-metamorphosis stabilization for system architecture evolution. Use when assess-form has classified the system as READY for transformation, when migrating from monolith to microservices, when replacing a core subsystem while dependents continue operating, or when any architectural change must be gradual rather than big-bang.

Software DevelopmentIn 1 list

Adaptic

45

pjt222/agent-almanac

Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains. Orchestrates meditate, expand-awareness, observe, awareness, integrate-gestalt, and express-insight into a coherent process that produces unified understanding rather than sequential compromise. Use when a problem genuinely spans 3+ domains and the interactions between domains matter more than depth in any one, when sequential analysis feels like compromise rather than integration, or before major architectural decisions affecting multiple stakeholders.

OtherIn 1 list

Add Puzzle Type

45

pjt222/agent-almanac

Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR. Creates the core puzzle module, wires it into the unified pipeline (generation, positioning, rendering, adjacency), adds ggpuzzle geom/stat layers, updates DESCRIPTION and config.yml, extends the Shiny app, and creates a comprehensive test suite. Use when adding a completely new puzzle type to the package or following the 10-point integration checklist to ensure nothing is missed end-to-end.

Testing & QAIn 1 list

Formulate Maxwell Equations

45

pjt222/agent-almanac

Work with the full set of Maxwell's equations in integral and differential form to analyze electromagnetic fields, waves, and energy transport. Use when applying Gauss's law, Faraday's law, or the Ampere-Maxwell law to boundary value problems, deriving the electromagnetic wave equation, computing Poynting vector and radiation pressure, solving for fields at material interfaces, or connecting electrostatics and magnetostatics to the unified electromagnetic framework.

Software DevelopmentIn 1 list

Evaluate Agent Framework

45

pjt222/agent-almanac

Assess an open-source agent framework for investment readiness by evaluating community health, supersession risk, architecture alignment, and governance sustainability. Produces a four-tier classification (INVEST / EVALUATE-FURTHER / CONTRIBUTE-CAUTIOUSLY / AVOID) to guide resource allocation decisions before committing engineering effort.

Software DevelopmentIn 1 list

Ip Clause Review

43

AlsKozlov/ru-legal

Review IP clauses в договорах (поставка / услуги / лицензия / разработка ПО / подряд). РФ specifics: ст.1295 ГК служебное произведение (по умолчанию права у работодателя — но условия!); ст.1232 регистрация исключительных лицензий; ст.1234 (отчуждение) vs ст.1235 (лицензионный) — different framework; невыплата вознаграждения за служебное → возможный отзыв прав работником.

Software Development

Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.