Install
$ agentstack add skill-lonsdale201-wp-agent-skills-br-atomic-idempotency ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
better-route: Atomic idempotency
Use this when a write route must reserve an Idempotency-Key before the handler runs. This is stronger than IdempotencyMiddleware, which is still useful as a replay cache but stores only after handler completion.
Pick the middleware
use BetterRoute\Middleware\Write\AtomicIdempotencyMiddleware;
use BetterRoute\Middleware\Write\WpdbAtomicIdempotencyStore;
register_activation_hook(__FILE__, function (): void {
(new WpdbAtomicIdempotencyStore())->installSchema();
});
$atomic = new AtomicIdempotencyMiddleware(
store: new WpdbAtomicIdempotencyStore(),
ttlSeconds: 900,
requireKey: true
);
Use WpdbAtomicIdempotencyStore in production. ArrayAtomicIdempotencyStore is for tests and local single-process checks only.
Route pattern
$router->post('/actions/confirm', $handler)
->middleware([$jwt, $atomic])
->protectedByMiddleware('bearerAuth');
Order matters: auth first, atomic idempotency after auth. The default storage key includes route path, authenticated identity, and the client key.
Behavior
- First matching request reserves the key, then runs the handler.
- Same key and same fingerprint while the first request is running returns
409 idempotency_in_progress. - Same key and same fingerprint after completion replays the stored response.
- Same key with a different fingerprint returns
409 idempotency_conflict. - Missing key returns
400 idempotency_key_requiredwhenrequireKey: true. - Thrown exceptions release the reservation by default so a client can retry.
Rules
- Use this for side-effectful writes. Keep
IdempotencyMiddlewarefor low-risk replay caching or backwards-compatible adoption. - Install the DB schema on activation before the route is used.
- Keep TTL long enough for realistic client retries.
- Return
BetterRoute\Http\Responsewhen clients need replay headers such asIdempotency-Replayed: true. - Use a custom
keyResolverfor tenant-scoped APIs where user ID alone is not enough. - Use a custom
fingerprintResolverif query/body defaults include unstable values.
Source refs
libraries/better-route/src/Middleware/Write/AtomicIdempotencyMiddleware.phplibraries/better-route/src/Middleware/Write/WpdbAtomicIdempotencyStore.phplibraries/better-route/src/Middleware/Write/AtomicIdempotencyStoreInterface.phplibraries/better-route/src/Middleware/Write/AtomicIdempotencyRecord.phplibraries/better-route/tests/WriteSafetyMiddlewareTest.php
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: Lonsdale201
- Source: Lonsdale201/wp-agent-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.