/hypervibe:add-push-notificationfrom hypervibe
Adds Web Push notifications to a Next.js app: generates VAPID keys, creates subscriptions table, extends PWA service worker, adds enable button and server-side send helper. Depends on PWA, DB, and auth.
Ships in hypervibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You add push notifications to the current project's app: the user can enable notifications on their device, and the server can send notifications even when the app is closed.
/bootstrap carries no language signal by itself). If nothing in the conversation gives a signal, fall back to the OS locale (node -e "console.log(Intl.DateTimeFormat().resolvedOptions().locale)") before defaulting to English. ALWAYS reply in that language for every user-facing message: questions, progress, confirmations, summaries, errors - including any example text quoted in this skill, which is illustrative and must be translated, never sent verbatim.Detect whether push is already in place: the hypervibe:push marker at the top of <WEB_DIR>/src/server/push.ts.
test -f "<WEB_DIR>/src/server/push.ts" && grep -q "hypervibe:push" "<WEB_DIR>/src/server/push.ts" && echo present || echo absent
present → first, the version of web-push the project carries. A project set up while this skill installed it unpinned may have web-push 4, which src/server/push.ts cannot load (no default export): sending fails at run time.
node -e "const v=require('<WEB_DIR>/node_modules/web-push/package.json').version;console.log(v.split('.')[0]==='3'?'ok':'v'+v)" 2>/dev/null || echo missing
Anything but ok: run cd <WEB_DIR> && pnpm add "web-push@^3.6.7" && pnpm add -D "@types/web-push@^3.6.4" and tell the user in one sentence that the push library goes back to version 3, the one the app's code is written for. Then the menu: (1) reinstall the enable button, (2) regenerate the VAPID keys (warning: invalidates existing subscriptions), (3) resend a test notification. Handle it, then skip to the summary.
absent → Step 1.
Templates/scripts path: ${CLAUDE_SKILL_DIR}/../../templates/push/ and ${CLAUDE_SKILL_DIR}/../../scripts/.
Detect project root: invoke _detect-project-root → WEB_DIR, IS_MONOREPO, IS_NEXTJS. Abort if not Next.js.
PWA present? (hard dependency)
test -f "<WEB_DIR>/src/app/manifest.ts" && grep -q "hypervibe:pwa" "<WEB_DIR>/src/app/manifest.ts" \
&& test -f "<WEB_DIR>/src/app/sw.ts" && echo pwa-ok || echo pwa-missing
pwa-ok → continue.
pwa-missing → explain then offer, via AskUserQuestion:
Push notifications are not possible until your app is a PWA (an installable app). It is the invisible component of the PWA, the "service worker", that receives notifications and displays them, even when the app is closed. Without it, there is no technical way to push a notification.
I can turn your app into a PWA now (installable + offline cache), then continue on to notifications. It is quick and risk-free.
Options:
/add-pwa skill, then re-test the marker above. Once pwa-ok, continue./add-push-notification again whenever you want, and I will offer to install the PWA first."Database: invoke _check-deps db. If db_ok = false, offer /add-db (push subscriptions are stored in the database), then re-check.
Auth in users mode: read <WEB_DIR>/src/server/auth.ts and look for the // hypervibe:auth-modes marker. If it does not contain users, offer /add-auth (users mode): a push subscription is tied to a logged-in user. Once it is in place, come back here.
# Major 3 pinned: web-push 4 is ESM with no default export, and templates/push/server-push.ts
# imports it by default (`import webpush`). `import * as webpush` is not the way out yet: it fails at
# run time on 3.x (CommonJS). Move to 4 when server-push.ts and @types/web-push (3.6.x today) both follow it.
pnpm add "web-push@^3.6.7"
pnpm add -D "@types/web-push@^3.6.4"
First check whether they already exist in the environment (NEXT_PUBLIC_VAPID_PUBLIC_KEY): if so, do not regenerate (that would invalidate the subscriptions). Otherwise, generate them:
cd "<WEB_DIR>" && node "${CLAUDE_SKILL_DIR}/../../scripts/generate-vapid-keys.mjs" --env \
| node "${CLAUDE_SKILL_DIR}/../../scripts/push-env-vars.mjs" --stdin
The two keys go from the generator to the local .env and Vercel on a pipe: the private key never appears in the conversation, nor in a process argument. Then push the subject, which is not a secret, via _push-env-vars:
VAPID_SUBJECT=mailto:<project contact email> (read BREVO_SENDER_EMAIL / ADMIN_EMAIL / the project domain; default mailto:contact@<domain>).These are project-specific secrets (like AUTH_SECRET): they go in .env + Vercel, never in the global vault.
templates/push/schema-snippet.ts into the Drizzle schema (<WEB_DIR>/src/server/db/schema.ts, or packages/db/src/schema.ts in a monorepo), after the users table. Check that the imports used (index, text, timestamp, sql, createTable, users) are present (add them otherwise). Adapt createTable to the project conventions if the helper has a different name.cd "<WEB_DIR>" && pnpm db:push
Insert the push handlers into the service worker created by /add-pwa. Read templates/push/sw-push-handlers.ts, replace __APP_NAME__, and insert its contents into <WEB_DIR>/src/app/sw.ts right after the // hypervibe:push-handlers marker line.
Idempotence: if src/app/sw.ts already contains an addEventListener("push", do not reinsert. Exception: if the existing push handler does NOT contain the postMessage({ type: "hv:new-notification" }) broadcast (older installs), add that broadcast block to the existing handler — it is what lets the notification-center bell update in real time without aggressive polling (which keeps the Neon database awake: it only autosuspends after 5 min without a query).
(The public/sw.js is regenerated at the next build: in dev the SW is disabled, so push can only be observed after deployment.)
templates/push/server-push.ts to <WEB_DIR>/src/server/push.ts. Replace __VAPID_SUBJECT__ with the mailto: from Step 3. The template already contains the // hypervibe:push marker on the first line (detected at Step 0 and by /add-notification-center): keep it.templates/push/push-router.ts to <WEB_DIR>/src/server/api/routers/push.ts.appRouter (<WEB_DIR>/src/server/api/root.ts):
import { pushRouter } from "~/server/api/routers/push";
// inside createTRPCRouter({ ... }):
push: pushRouter,
test -f "<WEB_DIR>/src/server/notify.ts" && grep -q "hypervibe:notification-center" "<WEB_DIR>/src/server/notify.ts" && echo center-present || echo center-absent
templates/notif-center/notify-push-block.ts: add the sendPushToUser import at the top of notify.ts and replace the marker line // hypervibe:notify-push with await sendPushToUser(db, userId, payload); (idempotent). That way notifyUser rings the bell and pushes to the phone.To send a push from anywhere on the server side:
await sendPushToUser(db, userId, { title: "...", body: "...", url: "/..." }).
(If the in-app center is present, prefer notifyUser(...) which does both.)
templates/push/enable-notifications.tsx to <WEB_DIR>/src/components/.sonner. If the project does not have sonner or a mounted <Toaster />, either install it (pnpm add sonner + mount <Toaster /> in the layout), or replace the toast.* calls with a simple visual feedback (local state + message). Also adapt the colors to the palette.<EnableNotifications /> in a logged-in area (account page, dashboard, settings). Ask the user where they want the button if the placement is not obvious, or put it on the account page by default.The payload does not travel from your server to the device: it goes through the push service of the browser the person uses (Apple, Google, Mozilla). That service is a recipient, whatever the site publisher decides, so it belongs in the registry.
node "${CLAUDE_SKILL_DIR}/../../scripts/update-privacy-policy.mjs" --add web-push
Worth saying to the user, because it is the reassuring half: the payload is encrypted with the VAPID keys generated at Step 3, so the service that carries it cannot read it. Only the destination device can.
_update-claude-md:
stack: - **Push**: Web Push (web-push + VAPID), subscriptions in the \push_subscription` table, handlers in the service worker.`env-vars: - \NEXT_PUBLIC_VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` / `VAPID_SUBJECT`: Web Push (VAPID) keys`conventions: - Send a notification: \sendPushToUser(db, userId, { title, body, url })` from `~/server/push`. `url` is an internal path (`/orders/12`): a click on the notification opens the home page for anything else, never another site.`cd "<WEB_DIR>" && pnpm tsc --noEmit && pnpm lint
sendPushToUser.Check test -f "<WEB_DIR>/src/server/notify.ts". If absent, offer via AskUserQuestion:
You now have system notifications (push): they arrive on the phone, even with the app closed. You can also add an in-app notification center: a bell with a badge showing the unread count and the list of notifications, viewable at any time.
The difference: push grabs attention outside the app (and disappears); the bell keeps a viewable history inside it (read/unread). The two complement each other, and a single
notifyUsercall will send both.
/add-notification-center (which will detect push and wire push sending into notifyUser)./add-notification-center."What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub flavien-ia/hypervibe-craft --plugin hypervibe90 skills in this plugin
/accessibilityAccessibility audit of a Next.js app: reads the code (images, buttons, links, form fields, keyboard, focus, zoom, motion), measures the live pages with PageSpeed Insights, explains each problem plainly, then applies the fixes the user approves./add-2faAdd two-factor authentication (2FA TOTP) to an existing T3 project's login. Orchestrator - asks which authenticator app the user wants, detects whether the project uses admin auth (single fixed login) or user accounts, and delegates to the right setup. Admin mode - 2FA is mandatory for the single admin, secret + backup codes stored in the Bitwarden vault. User mode - 2FA is optional per user, each user enables it from their account page, secrets + backup codes stored per-user in the database. Requires the project to already have hypervibe auth (`/add-auth`)./Other plugins' skills for the same job