$ recombobulate _
home / tips / ask-claude-to-build-webhook-handlers-with-signature-verification-and-idempotency
169

Ask Claude to Build Webhook Handlers with Signature Verification and Idempotency

recombobulate @recombobulate · Mar 29, 2026 · Workflows
ask-claude-to-build-webhook-handlers-with-signature-verification-and-idempotency

Webhook handlers look simple but hide nasty edge cases — replay attacks, duplicate deliveries, out-of-order events, and payload verification. Claude Code builds handlers that get all of this right from the start.

Build a webhook handler for Stripe payment events. Include signature 
verification, idempotent event processing (don't process the same event 
twice), and proper HTTP responses so Stripe knows we received it.

Claude generates a handler that covers the cases you'd forget:

// Claude builds the complete handler
Route::post('/webhooks/stripe', function (Request $request) {
    // Verify signature to prevent spoofed events
    $payload = $request->getContent();
    $signature = $request->header('Stripe-Signature');
    $event = Webhook::constructEvent($payload, $signature, config('stripe.webhook_secret'));

    // Idempotency — skip if we've already processed this event
    if (ProcessedEvent::where('event_id', $event->id)->exists()) {
        return response('Already processed', 200);
    }

    // Process the event
    match ($event->type) {
        'payment_intent.succeeded' => handlePaymentSuccess($event),
        'invoice.payment_failed' => handlePaymentFailure($event),
        default => null, // Ignore unknown events gracefully
    };

    // Record that we processed it
    ProcessedEvent::create(['event_id' => $event->id]);

    return response('OK', 200);
});

Target different webhook needs:

# Multiple providers
Build webhook handlers for Stripe, GitHub, and SendGrid. 
Each needs its own signature verification method and event routing.

# Queue heavy processing
The webhook handler should acknowledge receipt immediately (200 OK) 
and queue the actual processing as a background job.

# Event ordering
Some events depend on earlier events (invoice.created before invoice.paid). 
Add logic to handle out-of-order delivery gracefully.

Webhooks are the internet calling your code — let Claude build handlers that verify, deduplicate, and process every event reliably.

via Claude Code

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago