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.
To help developers write more robust code by systematically detecting and reporting errors as early as possible, preventing silent failures and improving maintainability.
功能
- 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()`
使用场景
- 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
非目标
- Performing the validation itself
- Validating internal helper functions
- Replacing unit testing frameworks
- Providing a library of assertion functions
工作流
- Identify Trust Boundaries
- Add Guard Clauses at Entry Points
- Write Meaningful Error Messages
- Prefer stop() Over warning()
- Use Assertions for Internal Invariants
- Refactor Anti-Patterns
- Validate the Fail-Early Refactoring
安装
/plugin install agent-almanac@pjt222-agent-almanac质量评分
已验证类似扩展
Circuit Breaker Pattern
100Implement 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.
Run Puzzle Tests
100Run 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.
Create Spatial Visualization
100Create 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.
Containerize MCP Server
100Containerize 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.
Build Shiny Module
100Build 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.
Build Custom Mcp Server
100Build 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.