agentleFS
gerard-labsgerard-labs/superpowers-api-platform/skills/api-platform-resilience/SKILL.md

api-platform-resilience

Skill2 starsChanged 6 months agoMITView on GitHub

Build resilience patterns around an API Platform 4.3 app — Circuit Breaker (Closed → Open → Half-Open) on external dependencies (ERP, payment, search), cached fallback on Open state with a `_notice.type: degraded_mode` marker in the response, asynchronous writes for slow upstreams (HTTP 202 + status: pending_erp_processing dispatched via Messenger with exponential-backoff retry + DLQ + Symfony Workflow lifecycle), and exposure of the current status through the API. Trigger when the API depends on a third-party service (ERP, CRM, payment gateway, mailer, search engine), on "circuit breaker", "degraded mode", "async write", "retry policy", "DLQ", or "what if the ERP is down".

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No silent fallback: Always surface degraded mode in the response so the client can decide.

    line 30

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Platform 4.3 — Resilience

Use when

  • The API depends on a third-party service (ERP, CRM, payment, mailer, search).
  • Writes are slow and should not block the user request.
  • The third-party is intermittently unreliable.
  • A degraded-mode response is preferable to a 5xx.

Default workflow

  1. Identify each external dependency. Decide its criticality (must succeed sync vs degraded fallback acceptable).
  2. Wrap external calls in a Circuit Breaker with three states (Closed / Open / Half-Open).
  3. On Open: serve a cached fallback and add _notice.type: degraded_mode to the response.
  4. For slow writes: persist a pending_* status, dispatch a Messenger command, return HTTP 202.
  5. Model the lifecycle with Symfony Workflow (draft → pending_erp_processing → processed | failed).
  6. Configure exponential backoff retry + DLQ on the Messenger transport.

Guardrails

  • No silent fallback. Always surface degraded mode in the response so the client can decide.
  • Idempotency on external calls — assume retries will happen.
  • Timeouts on every HTTP / RPC call — never block indefinitely.
  • DLQ monitored. Failures accumulating in failed must trigger an alert; don't messenger:failed:retry blindly.

Progressive disclosure

  • SKILL.md covers posture and rules.
  • reference.md carries the full patterns: Circuit Breaker implementation (states, transitions, fallback cache), degraded-mode JSON shape, async write end-to-end (Processor, status, Messenger transport, retry strategy, failed transport, Workflow), exposing the status through the API.

Output contract

  • Each external dependency wrapped in a Circuit Breaker (and tested).
  • Async writes return HTTP 202 with a queryable status field.
  • Messenger retry strategy + DLQ configured per transport.
  • Workflow definition (draft → pending → processed | failed) explicit.
  • Tests cover the Open state (degraded fallback), the failure transport, and the recovery path.

References

  • reference.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.