agent-audit
Audit agents spawned in the current/last run against the agent-selection taxonomy
Scaffold a complete webhook handler (Hono route + sig verification + D1 idempotency + R2 dead-letter) for a named vendor
> /plugin marketplace add heymegabyte/claude-skillsHow it fires
How this command gets triggered: by you, by Claude, or both.
/forge-webhook-handlerContext preview
What this command does when you run it.
Scaffold a complete webhook handler (Hono route + sig verification + D1 idempotency + R2 dead-letter) for a named vendor
description: Scaffold a complete webhook handler (Hono route + sig verification + D1 idempotency + R2 dead-letter) for a named vendor argument-hint: <vendor> # stripe | square | github | resend | twilio allowed-tools: Bash, Read, Write, Edit, Glob
Forge a production-ready webhook handler for the named vendor. Reads `[[webhook-receiver-architecture]]` for vendor configs and outputs all files. Run `/forge-webhook-handler stripe` and get everything in one shot.
| Vendor | Sig header | Algo | Replay window | |---|---|---|---| | `stripe` | `Stripe-Signature` | HMAC-SHA256 | 5 min | | `square` | `X-Square-Hmacsha256-Signature` | HMAC-SHA256 base64 | 6 hr | | `github` | `X-Hub-Signature-256` | HMAC-SHA256 hex | delivery ID | | `resend` | `svix-id` / `svix-timestamp` / `svix-signature` | HMAC-SHA256 Svix | 5 min | | `twilio` | `X-Twilio-Signature` | HMAC-SHA1 base64 | idempotency only |
src/worker/routes/webhooks/ _core.ts ← shared processWebhook + DLQ + sha256Hex (create if missing) <vendor>.ts ← signature verification + event router for this vendor index.ts ← Hono mount (patched to include new vendor if existing) migrations/ XXXX_webhook_events.sql ← D1 table + indexes (create once, skip if exists) tests/ webhooks/<vendor>.test.ts ← Vitest unit tests with valid + invalid sig cases
VENDOR="${ARGUMENTS%% *}"
echo "Forging webhook handler for: $VENDOR"# Find wrangler.jsonc or wrangler.toml to anchor the project find . -maxdepth 3 -name "wrangler.jsonc" -o -name "wrangler.toml" | head -1
ls src/worker/routes/webhooks/ 2>/dev/null || echo "no webhooks dir yet" ls migrations/ | grep webhook 2>/dev/null || echo "no webhook migration yet"
Only create if `src/worker/routes/webhooks/_core.ts` does not exist. Full content from `[[webhook-receiver-architecture]]` § Generalized Handler Core. Skip if present.
Write `src/worker/routes/webhooks/<vendor>.ts` with:
**stripe**: `payment_intent.succeeded`, `payment_intent.payment_failed`, `customer.subscription.created`, `customer.subscription.updated`, `customer.subscription.deleted`, `invoice.payment_failed`, `checkout.session.completed`
**square**: `payment.completed`, `payment.updated`, `refund.created`, `order.updated`, `subscription.created`, `subscription.updated`
**github**: `push`, `pull_request`, `workflow_run`, `release`, `issues`, `check_run`
**resend**: `email.sent`, `email.delivered`, `email.delivery_delayed`, `email.bounced`, `email.complained`, `email.opened`, `email.clicked`
**twilio**: `sms.status` (Delivered/Failed/Undelivered), `call.status` (completed/failed/busy/no-answer)
If `index.ts` exists, add the missing `.post('/<vendor>', ...)` line. If not, create the full mount file.
Check highest existing migration number, write `migrations/<N+1>_webhook_events.sql`. Use `CREATE TABLE IF NOT EXISTS` + `CREATE INDEX IF NOT EXISTS` — safe to run multiple times:
-- Full schema from [[webhook-receiver-architecture]] § D1 Schema CREATE TABLE IF NOT EXISTS webhook_events ( ... ); CREATE INDEX IF NOT EXISTS idx_webhook_events_provider_status ON webhook_events (...); CREATE INDEX IF NOT EXISTS idx_webhook_events_received_at ON webhook_events (...);
// tests/webhooks/<vendor>.test.ts
import { describe, it, expect, beforeEach } from 'vitest'
import { handle<Vendor>Webhook } from '../../src/worker/routes/webhooks/<vendor>'
describe('<vendor> webhook handler', () => {
it('rejects missing signature header', async () => { ... })
it('rejects bad signature', async () => { ... })
it('rejects replayed event outside window', async () => { ... })
it('accepts valid signature and returns 200', async () => { ... })
it('returns 200 on duplicate event_id (idempotency)', async () => { ... })
it('dead-letters unknown event type gracefully', async () => { ... })
})Use `crypto.subtle` to generate valid HMAC sigs in test setup — never hardcode sigs.
echo "" echo "=== Secrets to provision (wrangler secret put) ==="
Print the exact `wrangler secret put <NAME>` commands for the chosen vendor from `[[webhook-receiver-architecture]]` § Wrangler bindings required.
Print the `wrangler.jsonc` additions needed for `DB` and `WEBHOOK_DLQ` if not already present in the project's `wrangler.jsonc`.
wrangler d1 execute prod --file=migrations/<N+1>_webhook_events.sql --local 2>&1 || true
npx vitest run tests/webhooks/<vendor>.test.ts 2>&1
Report what was created, what was skipped (already existed), and any test failures with exact line references. If tests fail, fix inline and re-run before declaring done.
14-category autonomous product-building OS for 32+ AI coding tools. One-line prompts → deployed products.
Repo: heymegabyte/claude-skills
Audit agents spawned in the current/last run against the agent-selection taxonomy
Run the Agent Diversity Review gate and emit the result table
Meta-analyze the effectiveness of a /loop arc — per-iteration metrics, LOC delta trend, saturation detection, and a keep/lengthen/delete recommendation.
Audit the rules/ directory for missing foundational principles; output gap list with priority and justification
Validate ~/.claude/settings.json hooks block — event names, file existence, executability, matcher syntax; --fix repairs common issues
Catch Resend-class bug (isError: false on HTTP 4xx/5xx) across all MCP server tool handlers