home / skills / phrazzld / claude-config / stripe-health

stripe-health skill

/skills/stripe-health

This skill performs a comprehensive Stripe webhook health check, diagnosing endpoints, redirects, deliveries, and failures to keep subscriptions in sync.

npx playbooks add skill phrazzld/claude-config --skill stripe-health

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.4 KB
---
name: stripe-health
description: "Stripe webhook health diagnostics. Invoke for: webhook delivery failures, pending_webhooks issues, redirect problems (307/308), subscription sync failures, pre-deployment webhook verification, incident investigation involving Stripe."
effort: high
---

# /stripe-health - Stripe Webhook Health Check

Run a comprehensive diagnostic on Stripe webhook integration.

## When to Use

- Before deploying changes to webhook handlers
- When subscription sync issues are reported
- After configuring new webhook endpoints
- As part of incident investigation

## Diagnostic Steps

### 1. Check Webhook Endpoints

```bash
# List all webhook endpoints for this project
stripe webhook_endpoints list --api-key "$STRIPE_SECRET_KEY" 2>&1 | jq '.data[] | {id, url, status, enabled_events}'
```

**Red flags:**
- Multiple endpoints for same URL (duplicate signing secrets)
- Status != "enabled"
- Missing critical events (checkout.session.completed, customer.subscription.*)

### 2. Check for Redirects (CRITICAL)

```bash
# Get the webhook URL from endpoints, then check for redirects
WEBHOOK_URL=$(stripe webhook_endpoints list --api-key "$STRIPE_SECRET_KEY" 2>&1 | jq -r '.data[0].url')
echo "Testing: $WEBHOOK_URL"
curl -s -I -X POST "$WEBHOOK_URL" 2>&1 | head -5
```

**Red flags:**
- HTTP 307/308/301/302 = REDIRECT = Stripe won't deliver webhooks
- Must return 4xx or 5xx, NOT 3xx

### 3. Check Recent Event Delivery

```bash
# Check last 5 events and their pending_webhooks count
stripe events list --limit 5 --api-key "$STRIPE_SECRET_KEY" 2>&1 | jq '.data[] | {id, type, created: (.created | todate), pending_webhooks}'
```

**Red flags:**
- pending_webhooks > 0 for old events = delivery failing
- pending_webhooks should decrease over time

### 4. Check for Failed Deliveries

```bash
# Look for events with high pending_webhooks (failures)
stripe events list --limit 20 --api-key "$STRIPE_SECRET_KEY" 2>&1 | jq '[.data[] | select(.pending_webhooks > 0)] | length'
```

**Red flags:**
- More than 2-3 events with pending_webhooks > 0

### 5. Test Live Delivery

```bash
# Resend a recent event and watch logs
RECENT_EVENT=$(stripe events list --limit 1 --type checkout.session.completed --api-key "$STRIPE_SECRET_KEY" 2>&1 | jq -r '.data[0].id')
ENDPOINT_ID=$(stripe webhook_endpoints list --api-key "$STRIPE_SECRET_KEY" 2>&1 | jq -r '.data[0].id')

echo "Resending $RECENT_EVENT to $ENDPOINT_ID..."
stripe events resend "$RECENT_EVENT" --webhook-endpoint "$ENDPOINT_ID" --api-key "$STRIPE_SECRET_KEY"

echo ""
echo "Watch Vercel logs for delivery confirmation..."
echo "Run: vercel logs your-app --json | grep webhook"
```

## Health Report Format

```
STRIPE WEBHOOK HEALTH CHECK
===========================
Endpoints: [count] configured
  - [url] (status: [enabled/disabled])

Redirect Check: [PASS/FAIL]
  - [url] returns [status code]

Recent Delivery: [PASS/WARN/FAIL]
  - [X] events with pending_webhooks > 0

Recommendation: [action if any issues found]
```

## Common Issues & Fixes

| Symptom | Likely Cause | Fix |
|---------|--------------|-----|
| pending_webhooks stays high | Redirect or wrong URL | `curl -I` the URL, update to canonical domain |
| Duplicate endpoints | Created endpoint twice | Delete older one, keep one with matching secret |
| Events not appearing | Wrong events enabled | Update endpoint to include required events |
| Signature verification fails | Wrong secret in env | Get secret from Stripe dashboard, update env |

Overview

This skill runs a focused diagnostic on Stripe webhook integrations to identify delivery failures, redirect issues, subscription sync problems, and misconfigured endpoints. It helps verify webhook endpoints, inspect recent event delivery, detect pending_webhooks build-up, and validate live resend behavior. Use it before deployments or during incident investigations to produce an actionable health report.

How this skill works

The skill inspects configured webhook endpoints and their status, checks for HTTP redirects that block Stripe deliveries, and queries recent events for pending_webhooks counts. It surfaces duplicate endpoints, missing critical events, and failed deliveries, and supports resending recent events to a selected endpoint while guiding you to check platform logs. Finally, it formats findings into a concise health report with recommendations.

When to use it

  • Before deploying changes to webhook handlers or routing logic
  • After adding or updating webhook endpoints in the Stripe dashboard
  • When subscription sync or customer.subscription.* events appear out of sync
  • During incident response for webhook delivery failures or spikes in pending_webhooks
  • To validate webhooks on new hosting platforms or domains (pre-deployment verification)

Best practices

  • Ensure each live URL is registered once in Stripe to avoid duplicate signing secrets
  • Verify endpoints return 2xx (or 4xx/5xx for intended failures) and never 3xx redirects
  • Enable required events (checkout.session.completed, customer.subscription.*) on the endpoint
  • Monitor pending_webhooks; investigate if old events keep pending_webhooks > 0
  • Store the correct signing secret from the dashboard in your environment for signature verification

Example use cases

  • Run a pre-deploy check to confirm webhook endpoints are enabled and correctly configured
  • Investigate why customers’ subscription states are not syncing after a billing change
  • Diagnose a sudden increase in failed webhook deliveries after migrating domains
  • Resend a recent checkout.session.completed event to validate handler logic and platform logs
  • Detect and remove duplicate webhook endpoints that cause signature mismatches

FAQ

What does pending_webhooks > 0 mean?

It means Stripe has not successfully delivered that event to all configured endpoints. If pending_webhooks stays > 0 for old events, delivery is failing and needs investigation.

Why are 3xx responses a problem for Stripe webhooks?

Stripe does not follow redirects for webhook delivery. Any 3xx response prevents successful delivery, so endpoints must resolve to a final 2xx/4xx/5xx status without redirecting.