Agent skill

Saga Pattern Knowledge

by dykyi-roman in dykyi-roman/awesome-claude-code

Saga Pattern knowledge base. An agent skill from dykyi-roman/awesome-claude-code.

MITAuto-check passedBackend & APIs

Install Saga Pattern Knowledge

skills CLI
$ npx skills add dykyi-roman/awesome-claude-code --skill saga-pattern-knowledge -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dykyi-roman/awesome-claude-code saga-pattern-knowledge --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dykyi-roman/awesome-claude-code.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/saga-pattern-knowledge .claude/skills/saga-pattern-knowledge && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
saga-pattern-knowledge
GitHub stars
103
Token cost
~3k tokens
SKILL.md length
333 words
Files
6 (incl. references, assets)
Skills in repo
11
Repo updated
First seen
Licence
MIT

At a glance

Saga Pattern knowledge base. An agent skill from dykyi-roman/awesome-claude-code.

  • Tasks that involve Microservices
  • SKILL.md covers Core Principles, Quick Checklists, PHP 8.4 Saga Patterns and Common Violations Quick…, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Saga Pattern Knowledge is an agent skill from dykyi-roman/awesome-claude-code. Saga Pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for saga orchestration, choreography, and distributed transaction audits.

Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including reference files and assets (for example `assets/report-template.md`, `references/antipatterns.md` and `references/compensation.md`).

It sits in Backend & APIs, covering Microservices. It works with PHP. The repository describes itself as: PHP Architecture Toolkit for Claude Code (DDD, CQRS, Event Sourcing, Hexagonal, Clean Architecture, SOLID, GRASP, PSR, Design Patterns, Testing, Documentation, Code Review). The licence is MIT.

When your agent uses it

  • Tasks that involve Microservices

Example prompts

  • “/saga-pattern-knowledge”

What it can do on your machine

Read from SKILL.md and the folder at commit 7e1fea8. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are php and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Saga Pattern Knowledge loads about 3k tokens when it runs, and up to ~17k if it reads all its reference files. Until then it costs about 47 tokens; SKILL.md has 333 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~47
When it runs · the whole SKILL.md, loaded when a task matches
~3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~17k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dykyi-roman/awesome-claude-code at commit 7e1fea8, republished under its MIT licence (© dykyi-roman). 333 words, ~3,036 tokens.

Download SKILL.mdSave it as .claude/skills/saga-pattern-knowledge/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
saga-pattern-knowledge
description
Saga Pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for saga orchestration, choreography, and distributed transaction audits.

Saga Pattern Knowledge Base

Quick reference for Saga pattern and PHP implementation guidelines for distributed transactions.

Core Principles

Saga Pattern Overview
┌─────────────────────────────────────────────────────────────────────────┐
│                         SAGA PATTERN                                     │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   CHOREOGRAPHY (Event-driven)                                            │
│   ┌─────────┐    event    ┌─────────┐    event    ┌─────────┐           │
│   │ Service │───────────▶ │ Service │───────────▶ │ Service │           │
│   │    A    │             │    B    │             │    C    │           │
│   └─────────┘             └─────────┘             └─────────┘           │
│        │                       │                       │                │
│        └───────── compensate ──┴─── compensate ────────┘                │
│                                                                          │
│   ORCHESTRATION (Central coordinator)                                    │
│                    ┌───────────────┐                                    │
│                    │  Saga         │                                    │
│                    │  Orchestrator │                                    │
│                    └───────┬───────┘                                    │
│              ┌─────────────┼─────────────┐                              │
│              ▼             ▼             ▼                              │
│        ┌─────────┐   ┌─────────┐   ┌─────────┐                          │
│        │ Service │   │ Service │   │ Service │                          │
│        │    A    │   │    B    │   │    C    │                          │
│        └─────────┘   └─────────┘   └─────────┘                          │
│                                                                          │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   Saga = Sequence of local transactions + compensating actions           │
│                                                                          │
│   T1 → T2 → T3 → ... → Tn                                               │
│    ↓    ↓    ↓          ↓                                               │
│   C1   C2   C3        Cn                                                │
│                                                                          │
│   If Ti fails: execute Ci-1, Ci-2, ..., C1 (reverse order)              │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘
Key Concepts
ConceptDescription
SagaSequence of local transactions with compensations
StepSingle local transaction within saga
Compensating ActionUndoes the effect of a previous step
OrchestratorCentral coordinator managing saga execution
ChoreographyDecentralized, event-driven saga coordination
Saga StateCurrent execution status (enum)
IdempotencySteps can be retried safely
Semantic LockPrevents concurrent saga conflicts
Choreography vs Orchestration
AspectChoreographyOrchestration
CoordinationDecentralized (events)Centralized (orchestrator)
CouplingLooseTighter to orchestrator
VisibilityDistributed (hard to trace)Centralized (easy to monitor)
ComplexitySimpler servicesSimpler overall flow
TestingHarder (distributed)Easier (centralized logic)
Best forSimple sagas (2-3 steps)Complex sagas (4+ steps)

Quick Checklists

Saga Design Checklist
  • Each step is a local transaction
  • Every step has compensating action
  • Compensations are idempotent
  • Forward actions are idempotent
  • Saga state is persisted
  • Failure handling defined for each step
  • Timeout handling for long-running steps
Orchestrator Checklist
  • State machine for saga lifecycle
  • Persistent saga state storage
  • Step execution tracking
  • Compensation ordering (reverse)
  • Retry logic with limits
  • Dead letter for failed sagas
  • Correlation ID propagation
Compensation Checklist
  • Semantic undo (not rollback)
  • Handles partial completion
  • Idempotent (can run multiple times)
  • Doesn't fail silently
  • Logs compensation actions
  • Eventual consistency acceptable

PHP 8.4 Saga Patterns

Saga State Enum
php
<?php

declare(strict_types=1);

namespace Domain\Shared\Saga;

enum SagaState: string
{
    case Pending = 'pending';
    case Running = 'running';
    case Compensating = 'compensating';
    case Completed = 'completed';
    case Failed = 'failed';
    case CompensationFailed = 'compensation_failed';

    public function canTransitionTo(self $next): bool
    {
        return match ($this) {
            self::Pending => $next === self::Running,
            self::Running => in_array($next, [self::Completed, self::Compensating], true),
            self::Compensating => in_array($next, [self::Failed, self::CompensationFailed], true),
            self::Completed, self::Failed, self::CompensationFailed => false,
        };
    }

    public function isTerminal(): bool
    {
        return in_array($this, [self::Completed, self::Failed, self::CompensationFailed], true);
    }
}
Saga Step Interface
php
<?php

declare(strict_types=1);

namespace Domain\Shared\Saga;

interface SagaStepInterface
{
    public function name(): string;

    public function execute(SagaContext $context): StepResult;

    public function compensate(SagaContext $context): StepResult;

    public function isIdempotent(): bool;
}
Saga Context
php
<?php

declare(strict_types=1);

namespace Domain\Shared\Saga;

final class SagaContext
{
    /** @var array<string, mixed> */
    private array $data = [];

    public function __construct(
        public readonly string $sagaId,
        public readonly string $correlationId,
        public readonly \DateTimeImmutable $startedAt
    ) {}

    public function set(string $key, mixed $value): void
    {
        $this->data[$key] = $value;
    }

    public function get(string $key, mixed $default = null): mixed
    {
        return $this->data[$key] ?? $default;
    }

    public function has(string $key): bool
    {
        return array_key_exists($key, $this->data);
    }

    public function all(): array
    {
        return $this->data;
    }
}
Saga Orchestrator
php
<?php

declare(strict_types=1);

namespace Application\Shared\Saga;

use Domain\Shared\Saga\SagaContext;
use Domain\Shared\Saga\SagaState;
use Domain\Shared\Saga\SagaStepInterface;
use Domain\Shared\Saga\StepResult;

final class SagaOrchestrator
{
    /** @var array<SagaStepInterface> */
    private array $steps = [];

    /** @var array<string> */
    private array $completedSteps = [];

    private SagaState $state = SagaState::Pending;

    public function __construct(
        private readonly SagaContext $context,
        private readonly SagaPersistenceInterface $persistence
    ) {}

    public function addStep(SagaStepInterface $step): self
    {
        $this->steps[] = $step;
        return $this;
    }

    public function execute(): SagaResult
    {
        $this->state = SagaState::Running;
        $this->persistence->save($this->context->sagaId, $this->state, []);

        foreach ($this->steps as $step) {
            $result = $step->execute($this->context);

            if ($result->isFailure()) {
                return $this->compensate($step->name(), $result->error());
            }

            $this->completedSteps[] = $step->name();
            $this->persistence->save(
                $this->context->sagaId,
                $this->state,
                $this->completedSteps
            );
        }

        $this->state = SagaState::Completed;
        $this->persistence->save($this->context->sagaId, $this->state, $this->completedSteps);

        return SagaResult::completed($this->context);
    }

    private function compensate(string $failedStep, string $error): SagaResult
    {
        $this->state = SagaState::Compensating;
        $this->persistence->save($this->context->sagaId, $this->state, $this->completedSteps);

        $stepsToCompensate = array_reverse($this->completedSteps);

        foreach ($stepsToCompensate as $stepName) {
            $step = $this->findStep($stepName);
            $result = $step->compensate($this->context);

            if ($result->isFailure()) {
                $this->state = SagaState::CompensationFailed;
                $this->persistence->save($this->context->sagaId, $this->state, $this->completedSteps);

                return SagaResult::compensationFailed($this->context, $error, $result->error());
            }
        }

        $this->state = SagaState::Failed;
        $this->persistence->save($this->context->sagaId, $this->state, $this->completedSteps);

        return SagaResult::failed($this->context, $error);
    }

    private function findStep(string $name): SagaStepInterface
    {
        foreach ($this->steps as $step) {
            if ($step->name() === $name) {
                return $step;
            }
        }
        throw new \RuntimeException("Step not found: {$name}");
    }
}

Common Violations Quick Reference

ViolationWhere to LookSeverity
Missing compensationSaga step without compensate()Critical
Non-idempotent stepsRetry causes duplicate effectsCritical
No saga state persistenceState lost on crashCritical
Synchronous distributed txTwo-phase commit attemptCritical
Forward-only sagaNo compensation at allWarning
Missing correlation IDCan't trace saga executionWarning
No timeout handlingSaga hangs foreverWarning
Compensation order wrongNot reversedWarning

Detection Patterns

bash
# Find saga implementations
Glob: **/Saga/**/*.php
Glob: **/*Saga.php
Grep: "SagaStep|SagaOrchestrator|Saga.*Interface" --glob "**/*.php"

# Check for saga state management
Grep: "SagaState|saga_state|enum.*Saga" --glob "**/*.php"

# Find compensating actions
Grep: "compensate|compensation|rollback.*step" --glob "**/Saga/**/*.php"

# Detect missing compensations
Grep: "implements.*SagaStep" --glob "**/*.php"
# Then check each for compensate() method

# Find choreography events
Grep: "SagaEvent|SagaCompleted|SagaFailed" --glob "**/Event/**/*.php"

# Check for saga persistence
Grep: "SagaPersistence|SagaRepository|saga.*save" --glob "**/*.php"

# Find potential issues
Grep: "Transaction.*begin.*Transaction" --glob "**/*.php"  # Distributed tx attempt

Example: Order Saga

Order Saga: Reserve Inventory → Charge Payment → Ship Order

Step 1: Reserve Inventory
  - Action: Decrement stock
  - Compensation: Release stock (increment)

Step 2: Charge Payment
  - Action: Charge credit card
  - Compensation: Refund charge

Step 3: Ship Order
  - Action: Create shipment
  - Compensation: Cancel shipment

If Step 2 fails:
  1. Compensate Step 1 (release inventory)
  2. Mark saga as Failed

References

For detailed information, load these reference files:

  • references/saga-patterns.md — Choreography and orchestration patterns
  • references/compensation.md — Compensating transaction strategies
  • references/antipatterns.md — Common violations with detection patterns
  • references/php-specific.md — PHP 8.4 specific implementations

Assets

  • assets/report-template.md — Structured audit report template

© dykyi-roman, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references, assets) in skills/saga-pattern-knowledge of dykyi-roman/awesome-claude-code.

  • SKILL.md
  • assets/report-template.md
  • references/antipatterns.md
  • references/compensation.md
  • references/php-specific.md
  • references/saga-patterns.md

Open the folder on GitHubat commit 7e1fea8

Compare with similar skills

Saga Pattern Knowledge next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Saga Pattern Knowledge compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Saga Pattern Knowledge this skilldykyi-roman/awesome-claude-code103—~3kAutomated safety check: PassMIT
AWS Lambda Php Integrationgiuseppe-trisciuoglio/developer-kit355—~2.3kAutomated safety check: NotesMIT
Dt Obs ServicesDynatrace/dynatrace-for-ai161—~3.3kAutomated safety check: PassApache-2.0
Configuring Horizoncoollabsio/coolify63k4 repos~898Automated safety check: PassMIT
Fortify Developmentcoollabsio/coolify63k4 repos~1.9kAutomated safety check: PassMIT
Node Backend Development Guidelinesdiet103/claude-code-infrastructure-showcase10k2 repos~2kAutomated safety check: PassMIT

Similar skills

  • AWS Lambda Php Integration

    giuseppe-trisciuoglio/developer-kit

    Provides AWS Lambda integration patterns for PHP with Symfony using the Bref framework.

    355 GitHub stars~2.3k tokensUpdated 28 days ago
    Backend & APIsAuto-check: notes
  • Dt Obs Services

    Dynatrace/dynatrace-for-ai

    Service performance monitoring with RED metrics (Rate, Errors, Duration) and runtime-specific telemetry for Java, .NET, Node.js, Python, PHP, and Go.

    161 GitHub stars~3.3k tokensUpdated 7 days ago
    DevOps & CloudAuto-check passed
  • Configuring Horizon

    coollabsio/coolify

    A skill your agent uses whenever the user mentions Horizon by name in a Laravel context.

    63k GitHub starsUsed in 4 repos~898 tokens
    Backend & APIsAuto-check passed
  • Fortify Development

    coollabsio/coolify

    ACTIVATE when the user works on authentication in Laravel. An agent skill from coollabsio/coolify.

    63k GitHub starsUsed in 4 repos~1.9k tokens
    Backend & APIsAuto-check passed
  • Node Backend Development Guidelines

    diet103/claude-code-infrastructure-showcase

    Sets layered architecture and coding rules for Node.js, Express and TypeScript microservices, covering routes, controllers, services, repositories, Prisma, Sentry and Zod.

    10k GitHub starsUsed in 2 repos~2k tokens
    Backend & APIsAuto-check passed
  • Laravel Best Practices

    anonaddy/anonaddy

    Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code.

    4.9k GitHub starsUsed in 13 repos~1.2k tokens
    Backend & APIsAuto-check passed

More from dykyi-roman/awesome-claude-code

All 11 skills in this repo
  • Grasp Knowledge

    dykyi-roman/awesome-claude-code

    GRASP principles knowledge base for PHP 8.4 projects. An agent skill from dykyi-roman/awesome-claude-code.

    103 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Psr Autoloading Knowledge

    dykyi-roman/awesome-claude-code

    PSR-4 autoloading standard knowledge base for PHP 8.4 projects.

    103 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Psr Coding Style Knowledge

    dykyi-roman/awesome-claude-code

    PSR-1 and PSR-12 coding standards knowledge base for PHP 8.4 projects.

    103 GitHub stars~2.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Psr Overview Knowledge

    dykyi-roman/awesome-claude-code

    PHP Standards Recommendations (PSR) overview knowledge base.

    103 GitHub stars~2.7k tokensUpdated 1 mo ago
    Auto-check passed
  • Solid Knowledge

    dykyi-roman/awesome-claude-code

    SOLID principles knowledge base for PHP 8.4 projects. An agent skill from dykyi-roman/awesome-claude-code.

    103 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Claude Code Knowledge

    dykyi-roman/awesome-claude-code

    Comprehensive knowledge base for Claude Code formats, patterns, and configuration.

    103 GitHub stars~4k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Saga Pattern Knowledge

What does Saga Pattern Knowledge do?

Saga Pattern knowledge base. An agent skill from dykyi-roman/awesome-claude-code. Saga Pattern Knowledge is an agent skill from dykyi-roman/awesome-claude-code. Saga Pattern knowledge base.

When should I use Saga Pattern Knowledge?

Saga Pattern Knowledge fits situations like: tasks that involve Microservices.

How do I install Saga Pattern Knowledge in Claude Code?

Run `npx skills add dykyi-roman/awesome-claude-code --skill saga-pattern-knowledge -a claude-code`. Or copy the skill folder (skills/saga-pattern-knowledge in dykyi-roman/awesome-claude-code) into .claude/skills/saga-pattern-knowledge in your project. Claude Code loads it when a task matches its description.

How do I install Saga Pattern Knowledge in Codex?

Run `npx skills add dykyi-roman/awesome-claude-code --skill saga-pattern-knowledge -a codex`. Or copy the skill folder (skills/saga-pattern-knowledge in dykyi-roman/awesome-claude-code) into .agents/skills/saga-pattern-knowledge in your project. Codex loads it when a task matches its description.

Can I use Saga Pattern Knowledge in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dykyi-roman/awesome-claude-code --skill saga-pattern-knowledge -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/saga-pattern-knowledge, .gemini/skills/saga-pattern-knowledge, .github/skills/saga-pattern-knowledge and .opencode/skills/saga-pattern-knowledge in your project.

What does Saga Pattern Knowledge need to run?

SKILL.md names no scripts, command-line tools or credentials: Saga Pattern Knowledge is instructions for the agent only.

Does Saga Pattern Knowledge access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Saga Pattern Knowledge safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Saga Pattern Knowledge use?

Saga Pattern Knowledge is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Saga Pattern Knowledge use?

About 3k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 14k tokens, read only when the agent opens those files.

What are the alternatives to Saga Pattern Knowledge?

Skills that share tags, products or a category with Saga Pattern Knowledge: AWS Lambda Php Integration (giuseppe-trisciuoglio/developer-kit, 355 stars), Dt Obs Services (Dynatrace/dynatrace-for-ai, 161 stars), Configuring Horizon (coollabsio/coolify, 63k stars) and Fortify Development (coollabsio/coolify, 63k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Saga Pattern Knowledge?

dykyi-roman (a GitHub user) maintains it in dykyi-roman/awesome-claude-code, which has 103 GitHub stars. The repository holds 11 skills in this directory. The repository was last updated on August 16, 2026.

Source: dykyi-roman/awesome-claude-code on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.