466 developers build on it · $249 once · lifetime updates · 30-day refund

    AnotherWrapper

    How do I stop Claude Code from breaking auth and payment webhooks in a Next.js SaaS?

    Stop Claude Code from silently breaking auth and payment webhooks

    A rule in CLAUDE.md is advice the model can ignore on turn twelve. A PreToolUse hook and four boundary tests turn auth, credits, and billing webhooks into doors the agent cannot walk through unasked.

    466 founders shipping on it · $249 once · 30-day refund

    Direct answer

    To stop Claude Code from breaking auth and payment webhooks in Next.js, add a PreToolUse hook that exits with code 2 on edits to auth, proxy/middleware, and webhook routes, add automated tests for raw-body signature verification, webhook reachability without cookies, and cross-user isolation, and keep a short CLAUDE.md pointing at those boundaries. AnotherWrapper ships all five guardrail hooks (28 commands and 5 locked doors), Better Auth, Drizzle, verified Stripe/Polar/LemonSqueezy webhooks, and 8 finished AI apps for $249 once.

    Why CLAUDE.md alone stops working around turn ten

    Coding agents follow instructions at the start of a session and drift when they fix a nearby bug. A refactor to next.js middleware or proxy.ts suddenly wraps /api/webhooks/* behind a login redirect. A cleanup turns `await request.text()` into `await request.json()`, breaking Stripe or Polar HMAC signature verification in production while local dev still looks green.

    Prose rules rely on the agent remembering them. Deterministic hooks enforce the boundary before a file write lands.

    1. Lock auth and webhook paths with a PreToolUse hook

    Claude Code supports a PreToolUse hook on Edit and Write. When the script exits with status code 2, Claude Code cancels the tool call and returns your refusal message to the model.

    Protect these paths at minimum: `app/api/webhooks/**`, `app/api/auth/**`, `lib/auth*`, `lib/payments*`, `middleware.ts` or `proxy.ts`, and `.env*`. Pair that with a destructive-command hook (blocking force-push, `rm -rf`, and dropped tables) and a secret scanner hook so API keys never land in git history.

    Remember one limit: Edit/Write hooks do not intercept shell commands like `sed` or `mv`. That is why hooks work alongside tests, not instead of them.

    2. Add four boundary tests and a Stop gate

    Four narrow tests catch 90% of vibe-coded production outages before a user ever hits them:

    1. **Webhook signature test:** POST a signed payload and assert 200; POST an unsigned or tampered payload and assert 400. 2. **Webhook reachability test:** Call `/api/webhooks/*` with no session cookie and assert it never redirects to `/auth`. 3. **Idempotency test:** Replay the same checkout event ID twice and assert credits or subscriptions are only granted once. 4. **Cross-user isolation (IDOR) test:** Authenticate as User A, request User B's record by ID, and assert 403 or 404.

    Run those inside a Claude Code Stop hook so the agent cannot report 'done' while any critical check is red.

    3. Or start from a Next.js kit with the five hooks already wired

    AnotherWrapper ships with 5 locked guardrail hooks (`block-destructive`, `scan-secrets`, `protect-files`, `stop-gate`, `checkpoint`), plus `/review-auth`, `/review-payments`, and `/ship-check` commands built for Claude Code, Cursor, and Codex.

    Underneath the hooks is a production Next.js 16 stack (Better Auth, Drizzle ORM on PostgreSQL + pgvector, Stripe/Polar/LemonSqueezy webhooks, atomic credit reservation, and 8 finished AI apps) so your agent copies working vertical slices instead of inventing auth and billing from scratch.

    Vibe-coded apps rarely fail on the prompt. They fail on the plumbing around it.

    Exposed secrets in client bundles, unauthenticated API routes behind hidden buttons, user A reading user B's rows, client-trusted payment amounts, and silent agent rewrites to auth middleware are the exact seven failures that take AI apps down when real signups arrive. Fixing them once in hooks and tests beats debugging them after launch.

    Give your coding agent guardrails it cannot talk its way around.

    Clone AnotherWrapper for $249 once: Better Auth, Drizzle/Postgres, verified Stripe/Polar/LemonSqueezy webhooks, eight finished AI apps, and the Agent Kit (28 commands and 5 locked doors) already configured.

    • The foundation is a full Next.js SaaS kit — auth, database, payments, analytics, email. Use it for any product. The eight apps are extra.
    • Better Auth — OAuth, magic links, requireUser() on every server boundary. Drizzle + Postgres. Any Postgres host. Not locked to one vendor.
    • Stripe, Polar and LemonSqueezy. Credits and a paywall gate.
    • PostHog, Plausible or DataFast — one env switch. Loops, Resend or Brevo — one env switch. Sentry.
    • AGENTS.md + CLAUDE.md, architecture docs, .env locked in settings, Agent Kit + Growth Kit (28 commands and 5 locked doors: destructive commands, secrets, protected files, stop gate, checkpoints), Anti-Slop Design Kit (/art-direction), security and payment review skills
    • 8 finished apps: chat, image, video, voice, transcription, vision, resume reviewer, site auditor
    • Seven provider SDKs + ElevenLabs, streaming, tool calling, one model registry

    $249 today · lifetime updates · 30-day refund

    You probably have a question or two

    These are the ones people type into ChatGPT. If yours is not here, email me.

    Worst case it costs you nothing. 30-day refund.

    Open the repo. If it is not the job, email me inside 30 days. The licence is $249 once — not a subscription, not a tax on using Next.js.

    $249 once · lifetime updates · 30-day refund

    P.S. If you scrolled straight here, and I do that too, here is the whole thing. A private GitHub repo with 8 finished AI apps in it, the auth, payments, model and RAG layers underneath them, the Agent Kit that stops your agent wrecking any of it, and the five bonuses above. $27,150 of finished work, for $249 once.

    Nothing to cancel and nothing to renew. Read it, and if it is not what I just described, you have 30 days to say so and get every dollar back.

    And the reason to do it tonight rather than next month is the one I opened with: you are already paying $100–$200 a month to an agent that keeps rebuilding this foundation for you. Wait a month and you buy it again.

    Fekri, AnotherWrapper

    Buying for a team? Startup and Agency licences from $549

    Want to click around first? All 8 are running at app.anotherwrapper.com

    Would rather not build it at all? BuildFound builds it with you

    Not buying today

    Then take the free scan and go and check the app you already have.

    One prompt you paste into Claude Code, Codex or Cursor. It reads your repo and checks it against the seven failures above, then tells you which ones you have, with file names and line numbers. Most people find at least two.

    The scan is yours to keep. After that I send what I am building and what I learn shipping it, so new prompts and new playbooks. Unsubscribe in one click.