Works with the AI Agents you already use

    API Retry, Webhook & Idempotency Surgeon

    by Badung

    1

    If your app handles payments, emails, or background tasks, small errors in how it retries can cause big problems.

    $3.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    What it does

    • Catches missing idempotency keys that let a network glitch charge a customer twice
    • Detects race conditions where two identical requests might pass through at the same time
    • Spots unsafe retry loops that can overwhelm your server during a crash
    • Checks if your webhooks are properly secured against hackers replaying old messages
    • Provides a line by line code fix to patch reliability gaps in your specific framework

    Who it's for

    Founders managing payment systems

    Stop double charges and lost orders before they hurt your reputation.

    Try asking: “Check my payment processing code for double charge risks.”

    Shop owners with custom checkouts

    Ensure your customer orders are processed exactly once, even if the site crashes.

    Try asking: “Audit my checkout webhook for race conditions.”

    Freelance developers building backends

    Fix tricky retry bugs and security gaps in your API handlers.

    Try asking: “Scan my webhook handler for signature verification and retry issues.”

    API Retry, Webhook & Idempotency Surgeon

    API Retry, Webhook & Idempotency Surgeon

    Example session with this skill installed

    Review app/api/webhooks/billing/route.ts before we ship:

    export async function POST(req: Request) {
      const event = await req.json();
      if (event.type === "invoice.paid") {
        const sub = await db.subscription.findUnique({ where: { id: event.data.id } });
        if (sub && sub.status !== "active") {
          await db.subscription.update({
            where: { id: sub.id },
            data: { status: "active", credits: sub.credits + 100 },
          });
          await sendReceiptEmail(sub.userEmail);
        }
      }
      return Response.json({ ok: true });
    }
    
    • Read your context and instructions
    • Compiled the api retry webhook

    Summary: Audited app/api/webhooks/billing/route.ts —

    BLOCK: missing webhook signature verification, TOCTOU duplicate credit grant under concurrent deliveries, and non-transactional email side effect.

    Findings

    • [BLOCKER] REPLAY_OR_SIGNATURE_GAP (lines 2–3): req.json() parses the payload with no HMAC signature or timestamp check on the raw body, allowing forged invoice.paid requests to grant credits.
    • [BLOCKER] PARTIAL_COMMIT_OR_RACE (lines 5–10): Read-then-write (sub.status !== "active" followed by credits: sub.credits + 100) is not atomic. Two concurrent retries of the same event.id can both pass the check and add +200 credits.
    • [HIGH] MISSING_IDEMPOTENCY_KEY (line 10): sendReceiptEmail(sub.userEmail) runs outside any deduplicated event log and has no idempotency key; a crash or retry after DB commit resends duplicate emails.
    • [MED] UNBOUNDED_TIMEOUT_OR_DLQ_BLACKHOLE: No explicit timeout or dead-letter handling if sendReceiptEmail fails transiently after the DB update.

    Minimal Diff Patch

    --- a/app/api/webhooks/billing/route.ts
    +++ b/app/api/webhooks/billing/route.ts
    @@ -1,14 +1,32 @@
     export async function POST(req: Request) {
    -  const event = await req.json();
    +  const rawBody = await req.text();
    +  const sig = req.headers.get("x-webhook-signature") ?? "";
    +  if (!verifyWebhookSignature(rawBody, sig, process.env.WEBHOOK_SECRET!, { toleranceSec: 300 })) {
    +    return Response.json({ error: "invalid_signature" }, { status: 401 });
    +  }
    +
    +  const event = JSON.parse(rawBody);
       if (event.type === "invoice.paid") {
    -    const sub = await db.subscription.findUnique({ where: { id: event.data.id } });
    -    if (sub && sub.status !== "active") {
    -      await db.subscription.update({
    -        where: { id: sub.id },
    -        data: { status: "active", credits: sub.credits + 100 },
    -      });
    -      await sendReceiptEmail(sub.userEmail);
    -    }+    const claimed = await db.$transaction(async (tx) => {
    +      const inserted = await tx.webhookEvent.createMany({
    +        data: [{ eventId: event.id, type: event.type }],
    +        skipDuplicates: true,
    +      });
    +      if (inserted.count === 0) return null;
    +
    +      return tx.subscription.update({
    +        where: { id: event.data.id },
    +        data: { status: "active", credits: { increment: 100 } },
    +      });
    +    });
    +
    +    if (claimed) {
    +      await sendReceiptEmail(claimed.userEmail, { idempotencyKey: `receipt:${event.id}` });
    +    }
       }
       return Response.json({ ok: true });
     }
    

    Verification (Pending local run)

    • Replay the exact same invoice.paid payload concurrently (Promise.all with 5 requests) against a test DB and confirm credits increments once and webhookEvent holds 1 row.
    • Send a request with a tampered body or timestamp older than 300s and confirm 401 invalid_signature.

    Assumptions

    • webhookEvent.eventId has a UNIQUE index in the database schema.
    • verifyWebhookSignature uses constant-time comparison (crypto.timingSafeEqual).

    Connects securely to your tools. The creator never sees your data.

    About this skill

    If your app handles payments, emails, or background tasks, small errors in how it retries can cause big problems. You might charge a customer twice, send ten emails instead of one, or lose an order entirely when a server hiccups. This skill audits your code to find these hidden reliability risks. It looks for missing safety keys, bad retry loops, and security gaps in your webhooks.

    How it works

    1. Provide a code snippet, a file path, or ask your AI agent to search your project for payment and webhook code.
    2. The skill scans the code for five specific reliability flaws like missing double-check guards or unsafe retries.
    3. You get a list of risks ranked by how badly they could break your system.
    4. The skill provides a precise code fix that you can copy and paste to solve the issue.

    What you get: A structured reliability report with a ready-to-use code patch that prevents duplicate actions.

    This skill only reads your code. It cannot run tests or fix your database settings for you.

    Audits code for idempotency and reliability using Read, Grep, and Glob tools. It specifically targets MISSING_IDEMPOTENCY_KEY, UNSAFE_RETRY_STORM, PARTIAL_COMMIT_OR_RACE, REPLAY_OR_SIGNATURE_GAP, and UNBOUNDED_TIMEOUT. Built to work with typical backend patterns like Stripe webhooks, Axios/Fetch clients, and Prisma/SQL transactions. Returns surgical diffs for Node.js, Python, and other common languages.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 1 day ago

    Nothing to install. It runs in your AI agent.

    No shell, network or API keys needed: paste the handler, client or worker (or give its file path) and the skill reads it with Read, Grep and Glob.

    Permissions

    Read Files
    Listed1 day ago

    What's inside

    Frequently Asked Questions

    This skill scans your code to find errors in how your app handles payments, emails, and background tasks. It looks for problems like missing safety keys that cause double charges or retry loops that send the same email over and over.

    You only need to provide a code snippet, a file path, or tell your agent to search your project for payment and webhook files. The skill uses built-in tools to read and search your existing files to find risks.

    You get a reliability report that lists specific risks, such as missing double-check guards or unsafe retries. It also includes a ready-to-use code patch that you can copy and paste to fix the issues.

    The skill focuses on five specific reliability areas: missing safety keys, unsafe retry loops, race conditions where tasks overlap, signature gaps in webhooks, and missing timeouts. It provides a surgical code fix for each problem it finds.

    The skill does not run your code or execute shell commands. Every fix it provides is marked as pending local run, and you will receive instructions on how to manually verify the fix in your own environment.

    You can start by pasting a piece of code and asking the agent to check it for idempotency risks. You can also ask your agent to find all webhook and payment handlers in your project to perform a full audit.

    New in APIs & Backend

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.