Zum Hauptinhalt springen
Dieser Inhalt ist noch nicht in Ihrer Sprache verfügbar und wird auf Englisch angezeigt.

Fail Early Pattern

Skill Verifiziert Aktiv
Teil von:Agent Almanac

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.

Zweck

To help developers write more robust code by systematically detecting and reporting errors as early as possible, preventing silent failures and improving maintainability.

Funktionen

  • Input validation with guard clauses
  • Meaningful error message design
  • Identification of silent failure anti-patterns
  • Examples in R and general/polyglot guidance
  • Guidance on using `stop()` vs. `warning()`

Anwendungsfälle

  • Writing functions that accept external input
  • Adding input validation before package submission
  • Refactoring code that silently produces wrong results
  • Reviewing PRs for error-handling quality
  • Hardening internal APIs against invalid arguments

Nicht-Ziele

  • Performing the validation itself
  • Validating internal helper functions
  • Replacing unit testing frameworks
  • Providing a library of assertion functions

Workflow

  1. Identify Trust Boundaries
  2. Add Guard Clauses at Entry Points
  3. Write Meaningful Error Messages
  4. Prefer stop() Over warning()
  5. Use Assertions for Internal Invariants
  6. Refactor Anti-Patterns
  7. Validate the Fail-Early Refactoring

Installation

/plugin install agent-almanac@pjt222-agent-almanac

Qualitätspunktzahl

Verifiziert
99 /100
Analysiert about 21 hours ago

Vertrauenssignale

Letzter Commit1 day ago
Sterne14
LizenzMIT
Status
Quellcode ansehen

Ähnliche Erweiterungen

Circuit Breaker Pattern

100

Implement circuit breaker logic for agentic tool calls — tracking tool health, transitioning between closed/open/half-open states, reducing task scope when tools fail, routing to alternatives via capability maps, and enforcing failure budgets to prevent error accumulation. Separates orchestration (deciding what to attempt) from execution (calling tools), following the expeditor pattern. Use when building agents that depend on multiple tools with varying reliability, designing fault-tolerant agentic workflows, recovering gracefully from tool outages mid-task, or hardening existing agents against cascading tool failures.

Skill
pjt222

Run Puzzle Tests

100

Run the jigsawR test suite via WSL R execution. Supports full suite, filtered by pattern, or single file. Interprets pass/fail/skip counts and identifies failing tests. Never uses --vanilla flag (renv needs .Rprofile for activation). Use after modifying any R source code, after adding a new puzzle type or feature, before committing changes to verify nothing is broken, or when debugging a specific test failure.

Skill
pjt222

Create Spatial Visualization

100

Create interactive maps, elevation profiles, and spatial visualizations from GPX tracks, waypoints, or route data using R (sf, leaflet, tmap) or Observable (D3, deck.gl). Covers data import, coordinate system handling, map styling, and export to HTML or image formats. Use when visualizing a planned or completed tour route on an interactive map, creating elevation profiles for hiking or cycling routes, overlaying waypoints and POIs on a basemap, or building a web-based trip dashboard.

Skill
pjt222

Containerize MCP Server

100

Containerize an R-based MCP (Model Context Protocol) server using Docker. Covers mcptools integration, port exposure, stdio vs HTTP transport, and connecting Claude Code to the containerized server. Use when deploying an R MCP server without requiring a local R installation, creating a reproducible MCP server environment, running MCP servers alongside other containerized services, or distributing an MCP server to other developers.

Skill
pjt222

Build Shiny Module

100

Build reusable Shiny modules with proper namespace isolation using NS(). Covers module UI/server pairs, reactive return values, inter-module communication, and nested module composition. Use when extracting a reusable component from a growing Shiny app, building a UI widget used in multiple places, encapsulating complex reactive logic behind a clean interface, or composing larger applications from smaller, testable units.

Skill
pjt222

Build Custom Mcp Server

100

Build a custom MCP (Model Context Protocol) server that exposes domain-specific tools to AI assistants. Covers server implementation in Node.js or R, tool definitions, transport configuration, and testing with Claude Code. Use when you need to expose custom functionality beyond what mcptools provides, when building specialized domain-specific AI integrations, or when wrapping existing APIs or services as MCP tools.

Skill
pjt222