Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

idempotency-patterns

/idempotency-patterns

Zabezpiecza ponawiane polecenia HTTP i przetwarzanie komunikatów przed zdublowanymi skutkami: klucze żądań w bazie, konflikty ładunku i równoległe ponowienia.

Licencja
MIT
Ostatnia zmiana repozytorium
22.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
4
Skrypty
1
Komentarze HTML
0
Adresy URL w SKILL.md
3
Przestarzałość

Brak sygnałów. Repozytorium zmienione 22.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co sprawdzić przed instalacją
  • 1 skrypt w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.

Skrypty: examples/bad-idempotency.java

Co robi i kiedy

Zabezpiecza ponawiane polecenia HTTP i przetwarzanie komunikatów przed zdublowanymi skutkami: klucze żądań w bazie, konflikty ładunku i równoległe ponowienia.

Oryginalny opis (EN)

Use when making retried HTTP commands or message processing safe against duplicate effects, including database-backed request keys, payload conflicts and concurrent retries. Do not apply caching as a substitute for business idempotency.

Jak działa

  1. Spring Boot 3 baseline
  2. Define the contract
  3. Database-local effects
  4. External effects and messages
  5. Verification
  6. Gotchas
  7. Official sources
Sekcje z nagłówków SKILL.md, w oryginale · 65 linii, 499 słów
Podgląd SKILL.md
---
name: idempotency-patterns
description: >
  Use when making retried HTTP commands or message processing safe against duplicate effects, including database-backed request keys, payload conflicts and concurrent retries. Do not apply caching as a substitute for business idempotency.
---

# Idempotency Patterns

## Spring Boot 3 baseline

The examples use Java 17 and Jakarta APIs supported by this Boot version. Keep dependencies managed by the project's Boot BOM.

## Define the contract

Identify the authenticated tenant/principal, operation, idempotency key, canonical request hash,
retention window and replayable result. Scope uniqueness by principal/tenant and operation;
a raw client key must never allow reading another user's result. Authenticate and authorize
before both initial execution and replay. Bound key length and stored response size.
Document what same-key/different-payload and still-in-progress requests return.

## Database-local effects

For PostgreSQL, [the schema and claim example](examples/good-idempotency.sql) uses a composite
primary key and INSERT ON CONFLICT DO NOTHING RETURNING. In a single database transaction:
claim the key, apply the business write, store the resulting status/body/selected headers,
then commit. Roll back the claim with the business mutation on failure.

If the insert returns no row, load the existing result in a subsequent statement under READ
COMMITTED, compare the canonical hash and replay only when it matches. A concurrent insert
waits on the uniqueness constraint; bound lock waits and return a documented retryable outcome
on timeout. With snapshot isolation, serialization failures require retrying the whole transaction.
Do not catch a unique-constraint violation and continue in an already-aborted transaction.

A result row and business write must use the same transaction manager and database. Return
the stored result rather than reconstructing it from mutable current entity state.
Keep replay headers allowlisted; do not persist cookies, bearer tokens or hop-by-hop headers.

## External effects and messages

A database transaction cannot atomically include an HTTP payment or email. Write an outbox record
with the business mutation and let a retryable worker perform the external effect using the
provider's idempotency support. Reconcile uncertain outcomes before retrying irreversible effects.
For messages, record a unique consumer/event pair and apply the projection in one transaction;
acknowledge only after commit. Retry failed transactions and route poison messages deliberately.

Define retention from the real client retry window. Deleting a key permits a later repeat to
execute again; do not present TTL as an exactly-once guarantee. Protect stored responses as
application data and delete them according to the project's retention policy.

## Verification

Test simultaneous identical requests, conflicting payloads, tenant separation, rollback after
claim, response replay after a lost connection and retries following a worker crash.
Use the production database engine for lock and isolation tests, not H2 compatibility mode.
[The bad example](examples/bad-idempotency.java) illustrates the check-then-act race.

## Gotchas

- Agent checks existence then inserts - enforce uniqueness in the database.
- Agent uses a JVM map or Redis TTL as the only business guard - coordinate with the actual write transaction.
- Agent replays another tenant's result - scope the key and re-authorize.
- Agent retries an external effect after a timeout blindly - reconcile or use provider idempotency.
- Agent deletes keys too early - document the retry window and expiry semantics.

## Official sources

- [PostgreSQL INSERT and ON CONFLICT](https://www.postgresql.org/docs/current/sql-insert.html)
- [PostgreSQL transaction isolation](https://www.postgresql.org/docs/current/transaction-iso.html)
- [Spring transaction management](https://docs.spring.io/spring-framework/reference/data-access/transaction.html)
Pliki w paczce (4)
  • SKILL.md 4 KB
  • agents/openai.yaml 1 KB
  • examples/bad-idempotency.java 1 KB
  • examples/good-idempotency.sql 1 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · rrezartprebreza/spring-boot-skills100MIT
rrezartprebreza/spring-boot-skills100MIT

Migawka bazy z 13.11.2026 · wersja paczki 303f97f929d7 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90backend-idempotency
    Wdraża klucze idempotentności, by ponowienia żądań nie powodowały podwójnych skutków, np. dwóch obciążeń tej samej płatności.
  • 100idempotency-handling
    Implementuje idempotentne operacje API z kluczami idempotentności, cache w Redis i ograniczeniami w bazie danych, dla płatności, ponowień webhooków i problemów z podwójnym przetwarzaniem.
  • 90idempotency-keys
    Implementuje klucze idempotencji, tak by powtórzone żądania dawały jeden efekt i jedną kanoniczną odpowiedź, w endpointach POST, zwłaszcza dla płatności i tworzenia zamówień.
  • 100br-idempotency
    Konfiguruje idempotencję z pamięcią powtórzeń w better-route przez IdempotencyMiddleware i nagłówek Idempotency-Key, z wyborem magazynu i obsługą konfliktów kluczy.
  • 100idempotency-distributed-systems
    Zapewnia bezpieczne ponowienia w rozproszonych API płatniczych i transakcyjnych dzięki kluczom idempotentności.
  • 100idempotent-apis
    Projektuje i przegląda idempotentne endpointy HTTP zmieniające stan: klucze idempotencji, deduplikacja żądań, bezpieczne ponowienia i wzorzec Stripe, gdy endpoint tworzy zasoby, pobiera płatności lub wysyła powiadomienia.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.