create-retry-pattern

Generate a retry-pattern implementation for PHP 8.4. Creates a resilient component with exponential backoff, jitter, and configurable retry strategies to retry failed operations. Includes unit tests.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-retry-pattern" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-c31a4adb8cbdb32aa35ac53b8f8773cb6da73657d990413466f3cfc220a3a941. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Generate a retry-pattern implementation for PHP 8.4. Creates a resilient component with exponential backoff, jitter, and configurable retry strategies to retry failed operations. Includes unit tests.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Retry pattern for PHP 8.4. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.
Audience
| Scenario | Example | |----------|---------| | Transient failures | Network timeouts, temporary unavailability | | External API calls | HTTP requests to third-party services | | Database operations | Deadlock recovery, connection issues | | Message processing | Queue message handling with retries |
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: create-retry-pattern
description: Generates Retry pattern for PHP 8.4. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.

Retry Pattern Generator

Creates Retry pattern infrastructure for handling transient failures.

When to Use

Scenario Example
Transient failures Network timeouts, temporary unavailability
External API calls HTTP requests to third-party services
Database operations Deadlock recovery, connection issues
Message processing Queue message handling with retries

Component Characteristics

RetryPolicy

  • Configures retry behavior
  • Maximum attempts
  • Delay strategy (fixed, exponential, linear)
  • Jitter support to prevent thundering herd

RetryExecutor

  • Executes operations with retry logic
  • Tracks attempt count
  • Applies delay between retries
  • Logs retry attempts

Backoff Strategies

  • Fixed: Same delay every time
  • Linear: Delay increases linearly
  • Exponential: Delay doubles (with optional jitter)

Generation Process

Step 1: Generate Core Components

Path: src/Infrastructure/Resilience/Retry/

  1. BackoffStrategy.php — Enum for delay strategies
  2. RetryPolicy.php — Configuration with shouldRetry/calculateDelay
  3. RetryContext.php — Attempt context value object
  4. RetryException.php — Exception with attempt history

Step 2: Generate Executor

Path: src/Infrastructure/Resilience/Retry/

  1. RetryExecutor.php — Main retry logic with callbacks
  2. SleepInterface.php — For testability

Step 3: Generate Tests

  1. RetryPolicyTest.php — Policy behavior tests
  2. RetryExecutorTest.php — Executor tests

File Placement

Component Path
All Classes src/Infrastructure/Resilience/Retry/
Unit Tests tests/Unit/Infrastructure/Resilience/Retry/

Naming Conventions

Component Pattern Example
Policy RetryPolicy RetryPolicy
Strategy Enum BackoffStrategy BackoffStrategy
Executor RetryExecutor RetryExecutor
Context RetryContext RetryContext
Exception RetryException RetryException
Test {ClassName}Test RetryExecutorTest

Quick Template Reference

RetryPolicy

final readonly class RetryPolicy
{
    public function __construct(
        public int $maxAttempts = 3,
        public int $baseDelayMs = 100,
        public int $maxDelayMs = 10000,
        public float $multiplier = 2.0,
        public bool $useJitter = true,
        public BackoffStrategy $strategy = BackoffStrategy::Exponential,
        public array $retryableExceptions = [],
        public array $nonRetryableExceptions = []
    ) {}

    public static function exponential(int $maxAttempts = 5, int $baseDelayMs = 100): self;
    public static function linear(int $maxAttempts = 5, int $baseDelayMs = 500): self;
    public function shouldRetry(\Throwable $e, int $attempt): bool;
    public function calculateDelay(int $attempt): int;
}

RetryExecutor

final readonly class RetryExecutor
{
    public function execute(
        callable $operation,
        RetryPolicy $policy,
        ?callable $onRetry = null
    ): mixed;
}

Usage Example

$policy = new RetryPolicy(
    maxAttempts: 3,
    baseDelayMs: 200,
    retryableExceptions: [
        ConnectionException::class,
        TimeoutException::class,
    ],
    nonRetryableExceptions: [
        ClientException::class,
    ]
);

try {
    $result = $retryExecutor->execute(
        operation: fn() => $httpClient->get($url),
        policy: $policy,
        onRetry: fn($e, $ctx) => $logger->warning('Retrying...', ['attempt' => $ctx->attempt])
    );
} catch (RetryException $e) {
    // All retries exhausted
    $deadLetter->send($message, $e);
}

Anti-patterns to Avoid

Anti-pattern Problem Solution
No Max Attempts Infinite retries Always set maxAttempts
No Backoff Hammering service Use exponential backoff
Retrying All Exceptions Retrying unrecoverable errors Specify retryable exceptions
No Jitter Thundering herd Enable jitter
Ignoring Context Can't track attempts Use RetryContext
Blocking Forever Thread exhaustion Set maxDelayMs cap

References

For complete PHP templates and examples, see:

  • references/templates.md — RetryPolicy, BackoffStrategy, RetryExecutor, RetryContext templates
  • references/examples.md — HTTP client, database, message consumer examples and tests

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 PHP 8.4 重试模式生成,适用于网络超时、API 调用、数据库操作等高频场景
  • 包含指数退避、抖动、可配置策略及单元测试,具有明确实用价值
Trigger Precision90/100

Highlights

  • description 明确描述功能,覆盖多种使用场景,边界清晰
Structure and Standards95/100

Highlights

  • 结构清晰,分步骤生成组件,包含完整章节和规范说明
Execution Reliability88/100

Highlights

  • 提供完整类结构、接口设计、测试建议,参数配置合理,覆盖主要异常场景
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.