cfsa-antigravity 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -10
- package/bin/cli.mjs +7 -6
- package/package.json +1 -1
- package/template/.agent/PRDS/codex-runtime-support.md +2 -2
- package/template/.agent/TASKS/codex-runtime-support.md +2 -2
- package/template/.agent/instructions/workflow.md +3 -3
- package/template/.agent/kit-sync.md +3 -3
- package/template/.agent/rules/completion-checklist.md +3 -3
- package/template/.agent/skills/parallel-agents/SKILL.md +1 -1
- package/template/.agent/skills/session-continuity/SKILL.md +6 -6
- package/template/.agent/skills/session-continuity/protocols/01-session-resumption.md +1 -1
- package/template/.agent/skills/session-continuity/protocols/02-progress-generation.md +3 -3
- package/template/.agent/skills/session-continuity/protocols/03-progress-update.md +4 -4
- package/template/.agent/skills/session-continuity/protocols/07-spec-pipeline-generation.md +1 -1
- package/template/.agent/skills/session-continuity/protocols/08-spec-pipeline-update.md +2 -2
- package/template/.agent/skills/session-continuity/protocols/11-parallel-synthesis.md +1 -1
- package/template/.agent/workflows/create-prd-architecture.md +2 -2
- package/template/.agent/workflows/create-prd-design-system.md +2 -2
- package/template/.agent/workflows/create-prd-security.md +2 -2
- package/template/.agent/workflows/create-prd-stack.md +2 -2
- package/template/.agent/workflows/create-prd.md +2 -2
- package/template/.agent/workflows/decompose-architecture-validate.md +1 -1
- package/template/.agent/workflows/decompose-architecture.md +2 -2
- package/template/.agent/workflows/ideate.md +2 -2
- package/template/.agent/workflows/implement-slice-setup.md +1 -1
- package/template/.agent/workflows/implement-slice-tdd.md +3 -3
- package/template/.agent/workflows/implement-slice.md +2 -2
- package/template/.agent/workflows/plan-phase-preflight.md +2 -2
- package/template/.agent/workflows/plan-phase-write.md +2 -2
- package/template/.agent/workflows/plan-phase.md +2 -2
- package/template/.agent/workflows/setup-workspace.md +2 -2
- package/template/.agent/workflows/update-architecture-map.md +1 -1
- package/template/.agent/workflows/validate-phase-quality.md +1 -1
- package/template/.agent/workflows/validate-phase-readiness.md +2 -2
- package/template/.agent/workflows/validate-phase.md +2 -2
- package/template/.agent/workflows/verify-infrastructure.md +1 -1
- package/template/.agent/workflows/write-architecture-spec-deepen.md +3 -3
- package/template/.agent/workflows/write-architecture-spec-design.md +1 -1
- package/template/.agent/workflows/write-architecture-spec.md +3 -3
- package/template/.agent/workflows/write-be-spec-classify.md +1 -1
- package/template/.agent/workflows/write-be-spec-write.md +3 -3
- package/template/.agent/workflows/write-be-spec.md +3 -3
- package/template/.agent/workflows/write-fe-spec-classify.md +1 -1
- package/template/.agent/workflows/write-fe-spec-write.md +2 -2
- package/template/.agent/workflows/write-fe-spec.md +3 -3
- package/template/.claude/README.md +3 -1
- package/template/.claude/instructions/workflow.md +3 -3
- package/template/.claude/kit-sync.md +3 -3
- package/template/.claude/rules/completion-checklist.md +3 -3
- package/template/.claude/skills/parallel-agents/SKILL.md +1 -1
- package/template/.claude/skills/plan-phase/SKILL.md +2 -2
- package/template/.claude/skills/plan-phase-preflight/SKILL.md +2 -2
- package/template/.claude/skills/session-continuity/SKILL.md +6 -6
- package/template/.claude/skills/session-continuity/protocols/01-session-resumption.md +1 -1
- package/template/.claude/skills/session-continuity/protocols/02-progress-generation.md +3 -3
- package/template/.claude/skills/session-continuity/protocols/03-progress-update.md +4 -4
- package/template/.claude/skills/session-continuity/protocols/07-spec-pipeline-generation.md +1 -1
- package/template/.claude/skills/session-continuity/protocols/08-spec-pipeline-update.md +2 -2
- package/template/.claude/skills/session-continuity/protocols/11-parallel-synthesis.md +1 -1
- package/template/.claude/skills/setup/setup-cfsa.md +1 -1
- package/template/.claude/skills/write-architecture-spec/SKILL.md +2 -2
- package/template/.claude/skills/write-architecture-spec-deepen/SKILL.md +1 -1
- package/template/.claude/skills/write-architecture-spec-design/SKILL.md +1 -1
- package/template/.claude/skills/write-be-spec/SKILL.md +3 -3
- package/template/.claude/skills/write-be-spec-classify/SKILL.md +1 -1
- package/template/.claude/skills/write-be-spec-write/SKILL.md +1 -1
- package/template/.claude/skills/write-fe-spec/SKILL.md +3 -3
- package/template/.claude/skills/write-fe-spec-write/SKILL.md +1 -1
- package/template/.codex/README.md +99 -0
- package/template/.codex/instructions/commands.md +24 -0
- package/template/.codex/instructions/example.md +21 -0
- package/template/.codex/instructions/patterns.md +61 -0
- package/template/.codex/instructions/structure.md +29 -0
- package/template/.codex/instructions/tech-stack.md +93 -0
- package/template/.codex/instructions/workflow.md +64 -0
- package/template/.codex/kit-sync.md +6 -0
- package/template/.codex/rules/boundary-not-placeholder.md +146 -0
- package/template/.codex/rules/completion-checklist.md +60 -0
- package/template/.codex/rules/debug-by-test.md +49 -0
- package/template/.codex/rules/decision-classification.md +113 -0
- package/template/.codex/rules/extensibility.md +52 -0
- package/template/.codex/rules/memory-capture.md +84 -0
- package/template/.codex/rules/question-vs-command.md +91 -0
- package/template/.codex/rules/security-first.md +54 -0
- package/template/.codex/rules/single-question.md +59 -0
- package/template/.codex/rules/skill-mcp-first.md +45 -0
- package/template/.codex/rules/source-before-ask.md +93 -0
- package/template/.codex/rules/specificity-standards.md +64 -0
- package/template/.codex/rules/tdd-contract-first.md +67 -0
- package/template/.codex/rules/vertical-slices.md +83 -0
- package/template/.codex/skill-library/MANIFEST.md +498 -0
- package/template/.codex/skill-library/README.md +38 -0
- package/template/.codex/skill-library/meta/claude-code/README.md +9 -0
- package/template/.codex/skill-library/meta/claude-code/agent-development/SKILL.md +415 -0
- package/template/.codex/skill-library/meta/claude-code/hook-development/SKILL.md +712 -0
- package/template/.codex/skill-library/meta/claude-code/plugin-structure/SKILL.md +476 -0
- package/template/.codex/skill-library/meta/mcp-builder/SKILL.md +236 -0
- package/template/.codex/skill-library/meta/product-marketing-context/SKILL.md +241 -0
- package/template/.codex/skill-library/meta/tmux-processes/SKILL.md +210 -0
- package/template/.codex/skill-library/meta/using-tmux-for-interactive-commands/SKILL.md +178 -0
- package/template/.codex/skill-library/stack/3d/threejs-pro/SKILL.md +300 -0
- package/template/.codex/skill-library/stack/ai/ai-sdk/SKILL.md +77 -0
- package/template/.codex/skill-library/stack/ai/langchain/SKILL.md +530 -0
- package/template/.codex/skill-library/stack/ai/ollama/SKILL.md +321 -0
- package/template/.codex/skill-library/stack/ai/openai-sdk/SKILL.md +549 -0
- package/template/.codex/skill-library/stack/analytics/google-analytics/SKILL.md +153 -0
- package/template/.codex/skill-library/stack/api/graphql/SKILL.md +1061 -0
- package/template/.codex/skill-library/stack/api/trpc/SKILL.md +576 -0
- package/template/.codex/skill-library/stack/auth/authjs/SKILL.md +569 -0
- package/template/.codex/skill-library/stack/auth/clerk/SKILL.md +590 -0
- package/template/.codex/skill-library/stack/auth/firebase-auth/SKILL.md +734 -0
- package/template/.codex/skill-library/stack/auth/lucia/SKILL.md +230 -0
- package/template/.codex/skill-library/stack/auth/supabase-auth/SKILL.md +293 -0
- package/template/.codex/skill-library/stack/cms/payload-cms/SKILL.md +573 -0
- package/template/.codex/skill-library/stack/cms/shopify/SKILL.md +1193 -0
- package/template/.codex/skill-library/stack/cms/wordpress/SKILL.md +1104 -0
- package/template/.codex/skill-library/stack/css/sass-scss/SKILL.md +1121 -0
- package/template/.codex/skill-library/stack/css/tailwind-css-patterns/SKILL.md +863 -0
- package/template/.codex/skill-library/stack/css/tailwind-design-system/SKILL.md +490 -0
- package/template/.codex/skill-library/stack/css/vanilla-css/SKILL.md +1078 -0
- package/template/.codex/skill-library/stack/databases/clickhouse/SKILL.md +311 -0
- package/template/.codex/skill-library/stack/databases/influxdb/SKILL.md +280 -0
- package/template/.codex/skill-library/stack/databases/lancedb/SKILL.md +415 -0
- package/template/.codex/skill-library/stack/databases/mongodb/SKILL.md +1169 -0
- package/template/.codex/skill-library/stack/databases/neo4j/SKILL.md +839 -0
- package/template/.codex/skill-library/stack/databases/pgvector/SKILL.md +241 -0
- package/template/.codex/skill-library/stack/databases/pinecone/SKILL.md +212 -0
- package/template/.codex/skill-library/stack/databases/postgresql/SKILL.md +658 -0
- package/template/.codex/skill-library/stack/databases/qdrant/SKILL.md +312 -0
- package/template/.codex/skill-library/stack/databases/redis/SKILL.md +1079 -0
- package/template/.codex/skill-library/stack/databases/spacetimedb/SKILL.md +532 -0
- package/template/.codex/skill-library/stack/databases/sqlite/SKILL.md +1132 -0
- package/template/.codex/skill-library/stack/databases/supabase/SKILL.md +640 -0
- package/template/.codex/skill-library/stack/databases/surrealdb-expert/SKILL.md +945 -0
- package/template/.codex/skill-library/stack/databases/timescaledb/SKILL.md +745 -0
- package/template/.codex/skill-library/stack/databases/weaviate/SKILL.md +218 -0
- package/template/.codex/skill-library/stack/devops/git-advanced/SKILL.md +972 -0
- package/template/.codex/skill-library/stack/devops/git-workflow/SKILL.md +420 -0
- package/template/.codex/skill-library/stack/devops/github-actions/SKILL.md +554 -0
- package/template/.codex/skill-library/stack/devops/kubernetes/SKILL.md +950 -0
- package/template/.codex/skill-library/stack/devops/nginx/SKILL.md +841 -0
- package/template/.codex/skill-library/stack/devops/terraform/SKILL.md +860 -0
- package/template/.codex/skill-library/stack/email/resend/SKILL.md +391 -0
- package/template/.codex/skill-library/stack/extensions/chrome-extension/SKILL.md +375 -0
- package/template/.codex/skill-library/stack/extensions/plasmo/SKILL.md +195 -0
- package/template/.codex/skill-library/stack/extensions/vscode-extension/SKILL.md +453 -0
- package/template/.codex/skill-library/stack/extensions/wxt/SKILL.md +216 -0
- package/template/.codex/skill-library/stack/feature-flags/flagsmith/SKILL.md +187 -0
- package/template/.codex/skill-library/stack/feature-flags/launchdarkly/SKILL.md +183 -0
- package/template/.codex/skill-library/stack/feature-flags/posthog-flags/SKILL.md +189 -0
- package/template/.codex/skill-library/stack/frameworks/astro-framework/SKILL.md +162 -0
- package/template/.codex/skill-library/stack/frameworks/electron/SKILL.md +1286 -0
- package/template/.codex/skill-library/stack/frameworks/fastapi/SKILL.md +650 -0
- package/template/.codex/skill-library/stack/frameworks/hono/SKILL.md +90 -0
- package/template/.codex/skill-library/stack/frameworks/nestjs/SKILL.md +878 -0
- package/template/.codex/skill-library/stack/frameworks/nextjs/SKILL.md +635 -0
- package/template/.codex/skill-library/stack/frameworks/nuxt/SKILL.md +564 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/SKILL.md +81 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/references/events.md +353 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/references/migration.md +339 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/references/performance.md +443 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/references/runes.md +394 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/references/snippets.md +291 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/references/sveltekit.md +401 -0
- package/template/.codex/skill-library/stack/frameworks/svelte5/references/typescript.md +305 -0
- package/template/.codex/skill-library/stack/frameworks/sveltekit/SKILL.md +614 -0
- package/template/.codex/skill-library/stack/frameworks/tauri/SKILL.md +920 -0
- package/template/.codex/skill-library/stack/gamedev/godot/SKILL.md +1032 -0
- package/template/.codex/skill-library/stack/gamedev/unity/SKILL.md +1175 -0
- package/template/.codex/skill-library/stack/hosting/aws/SKILL.md +467 -0
- package/template/.codex/skill-library/stack/hosting/cloudflare/SKILL.md +201 -0
- package/template/.codex/skill-library/stack/hosting/docker-expert/SKILL.md +409 -0
- package/template/.codex/skill-library/stack/hosting/vercel/SKILL.md +484 -0
- package/template/.codex/skill-library/stack/languages/bash-scripting/SKILL.md +773 -0
- package/template/.codex/skill-library/stack/languages/c-cpp/SKILL.md +712 -0
- package/template/.codex/skill-library/stack/languages/gdscript/SKILL.md +789 -0
- package/template/.codex/skill-library/stack/languages/go/SKILL.md +664 -0
- package/template/.codex/skill-library/stack/languages/java/SKILL.md +778 -0
- package/template/.codex/skill-library/stack/languages/kotlin/SKILL.md +665 -0
- package/template/.codex/skill-library/stack/languages/python/SKILL.md +678 -0
- package/template/.codex/skill-library/stack/languages/rust/SKILL.md +673 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/SKILL.md +141 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/advanced-generics.md +90 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/branded-types.md +57 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/builder-pattern.md +71 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/common-pitfalls.md +135 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/conditional-types.md +27 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/decorators.md +98 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/discriminated-unions.md +62 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/mapped-types.md +53 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/performance-best-practices.md +104 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/template-literal-types.md +49 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/testing-types.md +112 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/type-guards.md +70 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/type-inference.md +101 -0
- package/template/.codex/skill-library/stack/languages/typescript-advanced-patterns/references/utility-types.md +98 -0
- package/template/.codex/skill-library/stack/languages/vanilla-javascript/SKILL.md +803 -0
- package/template/.codex/skill-library/stack/messaging/kafka/SKILL.md +235 -0
- package/template/.codex/skill-library/stack/messaging/nats/SKILL.md +147 -0
- package/template/.codex/skill-library/stack/messaging/rabbitmq/SKILL.md +178 -0
- package/template/.codex/skill-library/stack/messaging/sqs/SKILL.md +187 -0
- package/template/.codex/skill-library/stack/mobile/expo-react-native/SKILL.md +665 -0
- package/template/.codex/skill-library/stack/mobile/flutter/SKILL.md +316 -0
- package/template/.codex/skill-library/stack/mobile/kotlin-compose/SKILL.md +215 -0
- package/template/.codex/skill-library/stack/mobile/react-native/SKILL.md +337 -0
- package/template/.codex/skill-library/stack/mobile/swiftui/SKILL.md +261 -0
- package/template/.codex/skill-library/stack/monitoring/posthog/SKILL.md +396 -0
- package/template/.codex/skill-library/stack/monitoring/sentry/SKILL.md +509 -0
- package/template/.codex/skill-library/stack/notifications/fcm/SKILL.md +229 -0
- package/template/.codex/skill-library/stack/notifications/sendgrid/SKILL.md +220 -0
- package/template/.codex/skill-library/stack/notifications/twilio/SKILL.md +204 -0
- package/template/.codex/skill-library/stack/observability/datadog/SKILL.md +179 -0
- package/template/.codex/skill-library/stack/observability/distributed-tracing/SKILL.md +140 -0
- package/template/.codex/skill-library/stack/observability/opentelemetry/SKILL.md +164 -0
- package/template/.codex/skill-library/stack/observability/prometheus-grafana/SKILL.md +246 -0
- package/template/.codex/skill-library/stack/observability/python-observability/SKILL.md +158 -0
- package/template/.codex/skill-library/stack/orm/drizzle-orm/SKILL.md +613 -0
- package/template/.codex/skill-library/stack/orm/prisma/SKILL.md +744 -0
- package/template/.codex/skill-library/stack/payments/lemonsqueezy/SKILL.md +393 -0
- package/template/.codex/skill-library/stack/payments/stripe-integration/SKILL.md +457 -0
- package/template/.codex/skill-library/stack/queue/bullmq/SKILL.md +385 -0
- package/template/.codex/skill-library/stack/queue/inngest/SKILL.md +438 -0
- package/template/.codex/skill-library/stack/realtime/socketio/SKILL.md +595 -0
- package/template/.codex/skill-library/stack/search/algolia/SKILL.md +206 -0
- package/template/.codex/skill-library/stack/search/elasticsearch/SKILL.md +248 -0
- package/template/.codex/skill-library/stack/search/meilisearch/SKILL.md +385 -0
- package/template/.codex/skill-library/stack/search/typesense/SKILL.md +189 -0
- package/template/.codex/skill-library/stack/security/crypto-patterns/SKILL.md +437 -0
- package/template/.codex/skill-library/stack/security/csp-cors-headers/SKILL.md +588 -0
- package/template/.codex/skill-library/stack/security/dependency-auditing/SKILL.md +560 -0
- package/template/.codex/skill-library/stack/security/input-sanitization/SKILL.md +430 -0
- package/template/.codex/skill-library/stack/security/owasp-web-security/SKILL.md +421 -0
- package/template/.codex/skill-library/stack/state/tanstack-query/SKILL.md +637 -0
- package/template/.codex/skill-library/stack/state/zustand/SKILL.md +483 -0
- package/template/.codex/skill-library/stack/storage/aws-s3/SKILL.md +415 -0
- package/template/.codex/skill-library/stack/storage/cloudflare-r2/SKILL.md +252 -0
- package/template/.codex/skill-library/stack/storage/gcs/SKILL.md +229 -0
- package/template/.codex/skill-library/stack/testing/playwright/SKILL.md +641 -0
- package/template/.codex/skill-library/stack/testing/storybook/SKILL.md +923 -0
- package/template/.codex/skill-library/stack/testing/testing-library/SKILL.md +872 -0
- package/template/.codex/skill-library/stack/testing/vitest/SKILL.md +714 -0
- package/template/.codex/skill-library/stack/ui/react-best-practices/SKILL.md +877 -0
- package/template/.codex/skill-library/stack/ui/react-composition-patterns/SKILL.md +1107 -0
- package/template/.codex/skill-library/stack/ui/react-flow/SKILL.md +425 -0
- package/template/.codex/skill-library/stack/ui/shadcn-ui/SKILL.md +703 -0
- package/template/.codex/skill-library/stack/ui/svelte-flow/SKILL.md +390 -0
- package/template/.codex/skill-library/surface/api/api-caching/SKILL.md +458 -0
- package/template/.codex/skill-library/surface/api/api-documentation-openapi/SKILL.md +697 -0
- package/template/.codex/skill-library/surface/api/api-error-handling/SKILL.md +478 -0
- package/template/.codex/skill-library/surface/api/api-security-checklist/SKILL.md +147 -0
- package/template/.codex/skill-library/surface/api/email-best-practices/SKILL.md +59 -0
- package/template/.codex/skill-library/surface/api/rate-limiting-abuse-protection/SKILL.md +147 -0
- package/template/.codex/skill-library/surface/api/webhook-design/SKILL.md +752 -0
- package/template/.codex/skill-library/surface/cli/cli-configuration-management/SKILL.md +445 -0
- package/template/.codex/skill-library/surface/cli/cli-error-diagnostics/SKILL.md +515 -0
- package/template/.codex/skill-library/surface/cli/cli-shell-integration/SKILL.md +479 -0
- package/template/.codex/skill-library/surface/cli/cli-ux-design/SKILL.md +477 -0
- package/template/.codex/skill-library/surface/desktop/desktop-app-distribution/SKILL.md +416 -0
- package/template/.codex/skill-library/surface/desktop/desktop-security-sandboxing/SKILL.md +407 -0
- package/template/.codex/skill-library/surface/desktop/desktop-ux-conventions/SKILL.md +361 -0
- package/template/.codex/skill-library/surface/desktop/native-os-integration/SKILL.md +563 -0
- package/template/.codex/skill-library/surface/extension/browser-extension-patterns/SKILL.md +482 -0
- package/template/.codex/skill-library/surface/extension/plugin-architecture-design/SKILL.md +632 -0
- package/template/.codex/skill-library/surface/extension/vscode-extension-development/SKILL.md +728 -0
- package/template/.codex/skill-library/surface/mobile/app-store-submission/SKILL.md +304 -0
- package/template/.codex/skill-library/surface/mobile/mobile-offline-sync/SKILL.md +443 -0
- package/template/.codex/skill-library/surface/mobile/mobile-responsive-patterns/SKILL.md +432 -0
- package/template/.codex/skill-library/surface/mobile/push-notifications/SKILL.md +495 -0
- package/template/.codex/skill-library/surface/web/accessibility-compliance/SKILL.md +827 -0
- package/template/.codex/skill-library/surface/web/ai-seo/SKILL.md +398 -0
- package/template/.codex/skill-library/surface/web/ai-seo/references/content-patterns.md +285 -0
- package/template/.codex/skill-library/surface/web/ai-seo/references/platform-ranking-factors.md +152 -0
- package/template/.codex/skill-library/surface/web/analytics-tracking/SKILL.md +309 -0
- package/template/.codex/skill-library/surface/web/analytics-tracking/references/event-library.md +260 -0
- package/template/.codex/skill-library/surface/web/analytics-tracking/references/ga4-implementation.md +300 -0
- package/template/.codex/skill-library/surface/web/analytics-tracking/references/gtm-implementation.md +390 -0
- package/template/.codex/skill-library/surface/web/authentication-ui-flows/SKILL.md +530 -0
- package/template/.codex/skill-library/surface/web/dark-mode-theming/SKILL.md +516 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/SKILL.md +105 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/data/charts.csv +26 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/data/colors.csv +97 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/data/landing.csv +31 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/data/styles.csv +59 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/data/typography.csv +58 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/data/ux-guidelines.csv +100 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/scripts/core.py +258 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/scripts/design_system.py +1067 -0
- package/template/.codex/skill-library/surface/web/design-reference-data/scripts/search.py +106 -0
- package/template/.codex/skill-library/surface/web/form-handling-validation/SKILL.md +675 -0
- package/template/.codex/skill-library/surface/web/frontend-design/SKILL.md +1393 -0
- package/template/.codex/skill-library/surface/web/frontend-design/templates/cppn-hero.tsx +299 -0
- package/template/.codex/skill-library/surface/web/frontend-design/templates/wave-hero.tsx +875 -0
- package/template/.codex/skill-library/surface/web/frontend-verification/SKILL.md +111 -0
- package/template/.codex/skill-library/surface/web/frontend-verification/scripts/ux_audit.py +739 -0
- package/template/.codex/skill-library/surface/web/i18n-localization/SKILL.md +332 -0
- package/template/.codex/skill-library/surface/web/i18n-localization/references/icu-message-format.md +223 -0
- package/template/.codex/skill-library/surface/web/i18n-localization/references/intl-api-patterns.md +326 -0
- package/template/.codex/skill-library/surface/web/i18n-localization/references/rtl-support.md +298 -0
- package/template/.codex/skill-library/surface/web/offline-first-pwa/SKILL.md +657 -0
- package/template/.codex/skill-library/surface/web/page-cro/SKILL.md +182 -0
- package/template/.codex/skill-library/surface/web/page-cro/references/experiments.md +248 -0
- package/template/.codex/skill-library/surface/web/programmatic-seo/SKILL.md +238 -0
- package/template/.codex/skill-library/surface/web/programmatic-seo/references/playbooks.md +308 -0
- package/template/.codex/skill-library/surface/web/schema-markup/SKILL.md +179 -0
- package/template/.codex/skill-library/surface/web/schema-markup/references/schema-examples.md +398 -0
- package/template/.codex/skill-library/surface/web/seo-audit/SKILL.md +394 -0
- package/template/.codex/skill-library/surface/web/seo-audit/references/ai-writing-detection.md +200 -0
- package/template/.codex/skill-library/surface/web/web-performance-optimization/SKILL.md +646 -0
- package/template/.codex/skill-library/surface/web/web-scraping/SKILL.md +58 -0
- package/template/.codex/skills/README.md +78 -0
- package/template/.codex/skills/accessibility/SKILL.md +522 -0
- package/template/.codex/skills/accessibility/references/WCAG.md +162 -0
- package/template/.codex/skills/accessibility/references/ia-spec-checklist.md +35 -0
- package/template/.codex/skills/adversarial-review/SKILL.md +90 -0
- package/template/.codex/skills/antigravity-workflows/SKILL.md +81 -0
- package/template/.codex/skills/antigravity-workflows/resources/implementation-playbook.md +36 -0
- package/template/.codex/skills/api-design-principles/SKILL.md +169 -0
- package/template/.codex/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/template/.codex/skills/api-design-principles/assets/rest-api-template.py +182 -0
- package/template/.codex/skills/api-design-principles/references/graphql-schema-design.md +583 -0
- package/template/.codex/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/template/.codex/skills/api-design-principles/resources/implementation-playbook.md +513 -0
- package/template/.codex/skills/api-versioning/SKILL.md +166 -0
- package/template/.codex/skills/api-versioning/references/typescript.md +157 -0
- package/template/.codex/skills/architecture-mapping/SKILL.md +219 -0
- package/template/.codex/skills/audit-ambiguity/SKILL.md +54 -0
- package/template/.codex/skills/audit-ambiguity-execute/SKILL.md +86 -0
- package/template/.codex/skills/audit-ambiguity-rubrics/SKILL.md +58 -0
- package/template/.codex/skills/bootstrap-agents/SKILL.md +258 -0
- package/template/.codex/skills/bootstrap-agents-fill/SKILL.md +25 -0
- package/template/.codex/skills/bootstrap-agents-provision/SKILL.md +22 -0
- package/template/.codex/skills/brainstorming/SKILL.md +177 -0
- package/template/.codex/skills/brand-guidelines/SKILL.md +44 -0
- package/template/.codex/skills/clean-code/SKILL.md +196 -0
- package/template/.codex/skills/clean-code/references/typescript.md +126 -0
- package/template/.codex/skills/code-review-pro/SKILL.md +152 -0
- package/template/.codex/skills/concise-planning/SKILL.md +107 -0
- package/template/.codex/skills/create-prd/SKILL.md +94 -0
- package/template/.codex/skills/create-prd-architecture/SKILL.md +72 -0
- package/template/.codex/skills/create-prd-compile/SKILL.md +85 -0
- package/template/.codex/skills/create-prd-design-system/SKILL.md +69 -0
- package/template/.codex/skills/create-prd-security/SKILL.md +66 -0
- package/template/.codex/skills/create-prd-stack/SKILL.md +84 -0
- package/template/.codex/skills/cross-layer-consistency/SKILL.md +117 -0
- package/template/.codex/skills/database-schema-design/SKILL.md +205 -0
- package/template/.codex/skills/database-schema-design/references/relational.md +228 -0
- package/template/.codex/skills/decompose-architecture/SKILL.md +72 -0
- package/template/.codex/skills/decompose-architecture-structure/SKILL.md +62 -0
- package/template/.codex/skills/decompose-architecture-validate/SKILL.md +72 -0
- package/template/.codex/skills/deployment-procedures/SKILL.md +241 -0
- package/template/.codex/skills/design-anti-cliche/SKILL.md +159 -0
- package/template/.codex/skills/design-direction/SKILL.md +45 -0
- package/template/.codex/skills/error-handling-patterns/SKILL.md +226 -0
- package/template/.codex/skills/error-handling-patterns/references/go.md +162 -0
- package/template/.codex/skills/error-handling-patterns/references/python.md +262 -0
- package/template/.codex/skills/error-handling-patterns/references/rust.md +112 -0
- package/template/.codex/skills/error-handling-patterns/references/typescript.md +178 -0
- package/template/.codex/skills/evolve-contract/SKILL.md +24 -0
- package/template/.codex/skills/evolve-feature/SKILL.md +18 -0
- package/template/.codex/skills/evolve-feature-cascade/SKILL.md +24 -0
- package/template/.codex/skills/evolve-feature-classify/SKILL.md +21 -0
- package/template/.codex/skills/find-skills/SKILL.md +145 -0
- package/template/.codex/skills/git-advanced/SKILL.md +972 -0
- package/template/.codex/skills/git-workflow/SKILL.md +420 -0
- package/template/.codex/skills/idea-extraction/SKILL.md +644 -0
- package/template/.codex/skills/ideate/SKILL.md +77 -0
- package/template/.codex/skills/ideate-discover/SKILL.md +89 -0
- package/template/.codex/skills/ideate-extract/SKILL.md +77 -0
- package/template/.codex/skills/ideate-validate/SKILL.md +75 -0
- package/template/.codex/skills/implement-slice/SKILL.md +64 -0
- package/template/.codex/skills/implement-slice-setup/SKILL.md +70 -0
- package/template/.codex/skills/implement-slice-tdd/SKILL.md +78 -0
- package/template/.codex/skills/logging-best-practices/SKILL.md +192 -0
- package/template/.codex/skills/logging-best-practices/references/go.md +49 -0
- package/template/.codex/skills/logging-best-practices/references/python.md +52 -0
- package/template/.codex/skills/logging-best-practices/references/typescript.md +215 -0
- package/template/.codex/skills/migration-management/SKILL.md +200 -0
- package/template/.codex/skills/migration-management/references/relational.md +214 -0
- package/template/.codex/skills/minimalist-surgical-development/SKILL.md +135 -0
- package/template/.codex/skills/parallel-agents/SKILL.md +165 -0
- package/template/.codex/skills/parallel-debugging/SKILL.md +135 -0
- package/template/.codex/skills/parallel-feature-development/SKILL.md +157 -0
- package/template/.codex/skills/performance-budgeting/SKILL.md +144 -0
- package/template/.codex/skills/pipeline-rubrics/SKILL.md +51 -0
- package/template/.codex/skills/pipeline-rubrics/references/architecture-rubric.md +19 -0
- package/template/.codex/skills/pipeline-rubrics/references/be-rubric.md +21 -0
- package/template/.codex/skills/pipeline-rubrics/references/fe-rubric.md +20 -0
- package/template/.codex/skills/pipeline-rubrics/references/ia-rubric.md +19 -0
- package/template/.codex/skills/pipeline-rubrics/references/scoring.md +32 -0
- package/template/.codex/skills/pipeline-rubrics/references/vision-rubric.md +12 -0
- package/template/.codex/skills/plan-phase/SKILL.md +62 -0
- package/template/.codex/skills/plan-phase-preflight/SKILL.md +75 -0
- package/template/.codex/skills/plan-phase-write/SKILL.md +85 -0
- package/template/.codex/skills/prd-templates/SKILL.md +107 -0
- package/template/.codex/skills/prd-templates/references/architecture-completeness-checklist.md +28 -0
- package/template/.codex/skills/prd-templates/references/architecture-design-template.md +88 -0
- package/template/.codex/skills/prd-templates/references/be-spec-classification.md +41 -0
- package/template/.codex/skills/prd-templates/references/be-spec-template.md +107 -0
- package/template/.codex/skills/prd-templates/references/bootstrap-verification-protocol.md +50 -0
- package/template/.codex/skills/prd-templates/references/constraint-exploration.md +41 -0
- package/template/.codex/skills/prd-templates/references/data-placement-template.md +74 -0
- package/template/.codex/skills/prd-templates/references/decision-confirmation-protocol.md +68 -0
- package/template/.codex/skills/prd-templates/references/decision-propagation.md +121 -0
- package/template/.codex/skills/prd-templates/references/decomposition-templates.md +226 -0
- package/template/.codex/skills/prd-templates/references/deep-ideation-loading-protocol.md +114 -0
- package/template/.codex/skills/prd-templates/references/design-system-decisions.md +198 -0
- package/template/.codex/skills/prd-templates/references/design-system-prerequisite-check.md +18 -0
- package/template/.codex/skills/prd-templates/references/domain-exhaustion-criteria.md +37 -0
- package/template/.codex/skills/prd-templates/references/engagement-tier-protocol.md +58 -0
- package/template/.codex/skills/prd-templates/references/engineering-standards-template.md +126 -0
- package/template/.codex/skills/prd-templates/references/evolution-layer-guidance.md +91 -0
- package/template/.codex/skills/prd-templates/references/expansion-modes.md +27 -0
- package/template/.codex/skills/prd-templates/references/fe-classification-procedures.md +47 -0
- package/template/.codex/skills/prd-templates/references/fe-spec-template.md +90 -0
- package/template/.codex/skills/prd-templates/references/feature-ledger-protocol.md +149 -0
- package/template/.codex/skills/prd-templates/references/folder-seeding-protocol.md +77 -0
- package/template/.codex/skills/prd-templates/references/fractal-cx-template.md +58 -0
- package/template/.codex/skills/prd-templates/references/fractal-feature-template.md +93 -0
- package/template/.codex/skills/prd-templates/references/fractal-node-index-template.md +55 -0
- package/template/.codex/skills/prd-templates/references/gate-applicability.md +92 -0
- package/template/.codex/skills/prd-templates/references/ideation-crosscut-template.md +36 -0
- package/template/.codex/skills/prd-templates/references/ideation-index-template.md +111 -0
- package/template/.codex/skills/prd-templates/references/ideation-meta-template.md +126 -0
- package/template/.codex/skills/prd-templates/references/infrastructure-report-template.md +71 -0
- package/template/.codex/skills/prd-templates/references/input-classification.md +23 -0
- package/template/.codex/skills/prd-templates/references/map-guard-protocol.md +65 -0
- package/template/.codex/skills/prd-templates/references/operational-templates.md +116 -0
- package/template/.codex/skills/prd-templates/references/persona-completeness-gate.md +20 -0
- package/template/.codex/skills/prd-templates/references/placeholder-guard-template.md +21 -0
- package/template/.codex/skills/prd-templates/references/placeholder-workflow-mapping.md +50 -0
- package/template/.codex/skills/prd-templates/references/shard-boundary-analysis.md +103 -0
- package/template/.codex/skills/prd-templates/references/shard-split-remediation.md +157 -0
- package/template/.codex/skills/prd-templates/references/skill-loading-protocol.md +36 -0
- package/template/.codex/skills/prd-templates/references/slice-completion-gates.md +29 -0
- package/template/.codex/skills/prd-templates/references/spec-coverage-sweep.md +44 -0
- package/template/.codex/skills/prd-templates/references/surface-model.md +61 -0
- package/template/.codex/skills/prd-templates/references/tdd-testing-policy.md +39 -0
- package/template/.codex/skills/prd-templates/references/vision-template.md +57 -0
- package/template/.codex/skills/prd-templates/references/workflow-checkpoint-protocol.md +112 -0
- package/template/.codex/skills/prd-templates/references/write-verification-protocol.md +57 -0
- package/template/.codex/skills/prompt-engineer/SKILL.md +203 -0
- package/template/.codex/skills/propagate-decision/SKILL.md +18 -0
- package/template/.codex/skills/propagate-decision-apply/SKILL.md +22 -0
- package/template/.codex/skills/propagate-decision-scan/SKILL.md +20 -0
- package/template/.codex/skills/regex-patterns/SKILL.md +333 -0
- package/template/.codex/skills/regex-patterns/references/go.md +44 -0
- package/template/.codex/skills/regex-patterns/references/javascript.md +63 -0
- package/template/.codex/skills/regex-patterns/references/python.md +77 -0
- package/template/.codex/skills/regex-patterns/references/rust.md +43 -0
- package/template/.codex/skills/remediate-pipeline/SKILL.md +18 -0
- package/template/.codex/skills/remediate-pipeline-assess/SKILL.md +21 -0
- package/template/.codex/skills/remediate-pipeline-execute/SKILL.md +23 -0
- package/template/.codex/skills/remediate-shard-split/SKILL.md +21 -0
- package/template/.codex/skills/resolve-ambiguity/SKILL.md +278 -0
- package/template/.codex/skills/security-scanning-security-hardening/SKILL.md +231 -0
- package/template/.codex/skills/session-continuity/SKILL.md +732 -0
- package/template/.codex/skills/session-continuity/protocols/01-session-resumption.md +38 -0
- package/template/.codex/skills/session-continuity/protocols/02-progress-generation.md +85 -0
- package/template/.codex/skills/session-continuity/protocols/03-progress-update.md +70 -0
- package/template/.codex/skills/session-continuity/protocols/04-pattern-extraction.md +60 -0
- package/template/.codex/skills/session-continuity/protocols/05-session-close.md +37 -0
- package/template/.codex/skills/session-continuity/protocols/06-decision-analysis.md +84 -0
- package/template/.codex/skills/session-continuity/protocols/07-spec-pipeline-generation.md +48 -0
- package/template/.codex/skills/session-continuity/protocols/08-spec-pipeline-update.md +65 -0
- package/template/.codex/skills/session-continuity/protocols/09-parallel-claim.md +122 -0
- package/template/.codex/skills/session-continuity/protocols/10-placeholder-verification-gate.md +83 -0
- package/template/.codex/skills/session-continuity/protocols/11-parallel-synthesis.md +21 -0
- package/template/.codex/skills/session-continuity/protocols/ambiguity-gates.md +48 -0
- package/template/.codex/skills/setup/README.md +24 -0
- package/template/.codex/skills/setup/setup-cfsa.md +200 -0
- package/template/.codex/skills/setup/setup-fill-placeholders.md +192 -0
- package/template/.codex/skills/setup/setup-provision-skills.md +82 -0
- package/template/.codex/skills/setup/setup-verify.md +89 -0
- package/template/.codex/skills/setup-workspace/SKILL.md +83 -0
- package/template/.codex/skills/setup-workspace-cicd/SKILL.md +56 -0
- package/template/.codex/skills/setup-workspace-data/SKILL.md +69 -0
- package/template/.codex/skills/setup-workspace-hosting/SKILL.md +59 -0
- package/template/.codex/skills/setup-workspace-scaffold/SKILL.md +72 -0
- package/template/.codex/skills/skill-creator/SKILL.md +203 -0
- package/template/.codex/skills/spec-writing/SKILL.md +110 -0
- package/template/.codex/skills/sync-kit/SKILL.md +23 -0
- package/template/.codex/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/template/.codex/skills/systematic-debugging/SKILL.md +297 -0
- package/template/.codex/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/template/.codex/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/template/.codex/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/template/.codex/skills/systematic-debugging/find-polluter.sh +63 -0
- package/template/.codex/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/template/.codex/skills/systematic-debugging/test-academic.md +14 -0
- package/template/.codex/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/template/.codex/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/template/.codex/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/template/.codex/skills/tdd-workflow/SKILL.md +186 -0
- package/template/.codex/skills/tdd-workflow/references/typescript.md +231 -0
- package/template/.codex/skills/tech-stack-catalog/SKILL.md +49 -0
- package/template/.codex/skills/tech-stack-catalog/references/constraint-questions.md +237 -0
- package/template/.codex/skills/tech-stack-catalog/references/dev-tooling-decisions.md +37 -0
- package/template/.codex/skills/tech-stack-catalog/references/surface-decision-tables.md +69 -0
- package/template/.codex/skills/technical-writer/SKILL.md +242 -0
- package/template/.codex/skills/testing-strategist/SKILL.md +319 -0
- package/template/.codex/skills/testing-strategist/references/typescript.md +328 -0
- package/template/.codex/skills/update-architecture-map/SKILL.md +21 -0
- package/template/.codex/skills/utilities/resolve-skill.md +195 -0
- package/template/.codex/skills/validate-phase/SKILL.md +62 -0
- package/template/.codex/skills/validate-phase-quality/SKILL.md +67 -0
- package/template/.codex/skills/validate-phase-readiness/SKILL.md +74 -0
- package/template/.codex/skills/verification-before-completion/SKILL.md +97 -0
- package/template/.codex/skills/verify-infrastructure/SKILL.md +25 -0
- package/template/.codex/skills/workflow-automation/SKILL.md +166 -0
- package/template/.codex/skills/workflow-automation/references/inngest.md +88 -0
- package/template/.codex/skills/workflow-automation/references/temporal.md +64 -0
- package/template/.codex/skills/write-architecture-spec/SKILL.md +78 -0
- package/template/.codex/skills/write-architecture-spec-deepen/SKILL.md +82 -0
- package/template/.codex/skills/write-architecture-spec-design/SKILL.md +80 -0
- package/template/.codex/skills/write-be-spec/SKILL.md +75 -0
- package/template/.codex/skills/write-be-spec-classify/SKILL.md +80 -0
- package/template/.codex/skills/write-be-spec-write/SKILL.md +99 -0
- package/template/.codex/skills/write-fe-spec/SKILL.md +79 -0
- package/template/.codex/skills/write-fe-spec-classify/SKILL.md +77 -0
- package/template/.codex/skills/write-fe-spec-write/SKILL.md +88 -0
- package/template/.factory/README.md +2 -3
- package/template/.factory/instructions/workflow.md +3 -3
- package/template/.factory/kit-sync.md +3 -3
- package/template/.factory/skills/completion-checklist/SKILL.md +3 -3
- package/template/.factory/skills/parallel-agents/SKILL.md +1 -1
- package/template/.factory/skills/plan-phase/SKILL.md +2 -2
- package/template/.factory/skills/plan-phase-preflight/SKILL.md +2 -2
- package/template/.factory/skills/session-continuity/SKILL.md +6 -6
- package/template/.factory/skills/session-continuity/protocols/01-session-resumption.md +1 -1
- package/template/.factory/skills/session-continuity/protocols/02-progress-generation.md +3 -3
- package/template/.factory/skills/session-continuity/protocols/03-progress-update.md +4 -4
- package/template/.factory/skills/session-continuity/protocols/07-spec-pipeline-generation.md +1 -1
- package/template/.factory/skills/session-continuity/protocols/08-spec-pipeline-update.md +2 -2
- package/template/.factory/skills/session-continuity/protocols/11-parallel-synthesis.md +1 -1
- package/template/.factory/skills/setup-cfsa/SKILL.md +1 -1
- package/template/.factory/skills/write-architecture-spec/SKILL.md +2 -2
- package/template/.factory/skills/write-architecture-spec-deepen/SKILL.md +1 -1
- package/template/.factory/skills/write-architecture-spec-design/SKILL.md +1 -1
- package/template/.factory/skills/write-be-spec/SKILL.md +3 -3
- package/template/.factory/skills/write-be-spec-classify/SKILL.md +1 -1
- package/template/.factory/skills/write-be-spec-write/SKILL.md +1 -1
- package/template/.factory/skills/write-fe-spec/SKILL.md +3 -3
- package/template/.factory/skills/write-fe-spec-write/SKILL.md +1 -1
- package/template/.memory/README.md +1 -0
- package/template/.memory/mcp-server/README.md +10 -2
- package/template/.memory/mcp-server/client.mjs +61 -18
- package/template/.memory/mcp-server/daemon.mjs +8 -3
- package/template/.memory/mcp-server/runtime.mjs +51 -14
- package/template/.memory/mcp-server/start.mjs +4 -2
- package/template/.memory/migrate/migrate-legacy.mjs +1 -0
- package/template/.memory/pipeline/README.md +1 -0
- package/template/CLAUDE.md +4 -4
- package/template/CODEX.md +6 -53
- package/template/GEMINI.md +2 -2
- package/template/docs/README.md +5 -2
- package/template/docs/kit-architecture.md +36 -19
- package/template/docs/progress-state-catalog.md +48 -0
- package/template/.factory/progress/memory/.gitkeep +0 -0
- /package/template/{.agent/progress → .codex/skills/skill-creator/references}/.gitkeep +0 -0
- /package/template/{.agent/progress/memory → .codex/skills/skill-creator/scripts}/.gitkeep +0 -0
- /package/template/{.agent/progress/sessions → .memory/pipeline/progress}/.gitkeep +0 -0
- /package/template/{.claude/progress → .memory/pipeline/progress/memory}/.gitkeep +0 -0
- /package/template/{.claude/progress/memory → .memory/pipeline/progress/phases}/.gitkeep +0 -0
- /package/template/{.claude → .memory/pipeline}/progress/sessions/.gitkeep +0 -0
- /package/template/{.factory/progress → .memory/pipeline/progress/slices}/.gitkeep +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fcm
|
|
3
|
+
description: "Firebase Cloud Messaging patterns covering push notification setup, topic messaging, data messages, notification payloads, service worker handling, and multicast sending. Use when implementing push notifications with FCM."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
source: self
|
|
6
|
+
date_added: "2026-03-14"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Firebase Cloud Messaging (FCM)
|
|
10
|
+
|
|
11
|
+
Push notification service for web, Android, and iOS. Send targeted notifications via device tokens, topics, or conditions with customizable payloads.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- Sending push notifications to web browsers or mobile apps
|
|
16
|
+
- Need topic-based pub/sub for notification channels
|
|
17
|
+
- Using Firebase ecosystem (Auth, Firestore, etc.)
|
|
18
|
+
- Need cross-platform push (web + Android + iOS)
|
|
19
|
+
|
|
20
|
+
## When NOT to Use
|
|
21
|
+
|
|
22
|
+
- Sending email or SMS (use SendGrid, Twilio)
|
|
23
|
+
- In-app real-time messaging (use WebSockets or Firestore)
|
|
24
|
+
- Need guaranteed delivery for critical alerts (FCM is best-effort)
|
|
25
|
+
|
|
26
|
+
## Setup
|
|
27
|
+
|
|
28
|
+
### Server SDK (Firebase Admin)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install firebase-admin
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import * as admin from 'firebase-admin';
|
|
36
|
+
|
|
37
|
+
admin.initializeApp({
|
|
38
|
+
credential: admin.credential.cert({
|
|
39
|
+
projectId: process.env.FIREBASE_PROJECT_ID,
|
|
40
|
+
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
41
|
+
privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, '\n'),
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const messaging = admin.messaging();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Web Client Setup
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// firebase-messaging-sw.js (Service Worker)
|
|
52
|
+
importScripts('https://www.gstatic.com/firebasejs/10.12.0/firebase-app-compat.js');
|
|
53
|
+
importScripts('https://www.gstatic.com/firebasejs/10.12.0/firebase-messaging-compat.js');
|
|
54
|
+
|
|
55
|
+
firebase.initializeApp({
|
|
56
|
+
apiKey: 'your-api-key',
|
|
57
|
+
projectId: 'your-project-id',
|
|
58
|
+
messagingSenderId: 'your-sender-id',
|
|
59
|
+
appId: 'your-app-id',
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const messaging = firebase.messaging();
|
|
63
|
+
|
|
64
|
+
// Handle background messages
|
|
65
|
+
messaging.onBackgroundMessage((payload) => {
|
|
66
|
+
const { title, body, icon } = payload.notification ?? {};
|
|
67
|
+
self.registration.showNotification(title ?? 'Notification', {
|
|
68
|
+
body,
|
|
69
|
+
icon: icon ?? '/icon-192.png',
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// Client-side: request permission and get token
|
|
76
|
+
import { getMessaging, getToken, onMessage } from 'firebase/messaging';
|
|
77
|
+
|
|
78
|
+
const messaging = getMessaging();
|
|
79
|
+
|
|
80
|
+
async function requestNotificationPermission(): Promise<string | null> {
|
|
81
|
+
const permission = await Notification.requestPermission();
|
|
82
|
+
if (permission !== 'granted') return null;
|
|
83
|
+
|
|
84
|
+
const token = await getToken(messaging, {
|
|
85
|
+
vapidKey: process.env.NEXT_PUBLIC_FIREBASE_VAPID_KEY,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Save token to your server
|
|
89
|
+
await fetch('/api/push/register', {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
body: JSON.stringify({ token }),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return token;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Handle foreground messages
|
|
98
|
+
onMessage(messaging, (payload) => {
|
|
99
|
+
console.log('Foreground message:', payload);
|
|
100
|
+
// Show in-app notification UI
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Send Notifications
|
|
105
|
+
|
|
106
|
+
### To Single Device
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
await messaging.send({
|
|
110
|
+
token: deviceToken,
|
|
111
|
+
notification: {
|
|
112
|
+
title: 'Order Shipped',
|
|
113
|
+
body: 'Your order #1234 has been shipped!',
|
|
114
|
+
imageUrl: 'https://example.com/order-shipped.png',
|
|
115
|
+
},
|
|
116
|
+
data: {
|
|
117
|
+
orderId: '1234',
|
|
118
|
+
type: 'order_update',
|
|
119
|
+
url: '/orders/1234',
|
|
120
|
+
},
|
|
121
|
+
webpush: {
|
|
122
|
+
fcmOptions: { link: 'https://example.com/orders/1234' },
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### To Multiple Devices (Multicast)
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const response = await messaging.sendEachForMulticast({
|
|
131
|
+
tokens: deviceTokens, // Up to 500 tokens
|
|
132
|
+
notification: {
|
|
133
|
+
title: 'New Feature Available',
|
|
134
|
+
body: 'Check out our new dashboard!',
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Handle failures
|
|
139
|
+
response.responses.forEach((resp, i) => {
|
|
140
|
+
if (!resp.success) {
|
|
141
|
+
const failedToken = deviceTokens[i];
|
|
142
|
+
if (resp.error?.code === 'messaging/registration-token-not-registered') {
|
|
143
|
+
removeStaleToken(failedToken); // Token expired, clean up
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Topic Messaging
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Subscribe device to topic (server-side)
|
|
153
|
+
await messaging.subscribeToTopic(deviceTokens, 'news-updates');
|
|
154
|
+
|
|
155
|
+
// Send to all subscribers of a topic
|
|
156
|
+
await messaging.send({
|
|
157
|
+
topic: 'news-updates',
|
|
158
|
+
notification: { title: 'Breaking News', body: 'Important update...' },
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Condition-based targeting
|
|
162
|
+
await messaging.send({
|
|
163
|
+
condition: "'news-updates' in topics && !('muted' in topics)",
|
|
164
|
+
notification: { title: 'News', body: 'For unmuted news subscribers' },
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Data-Only Messages (Silent Push)
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// No notification shown — app processes data in background
|
|
172
|
+
await messaging.send({
|
|
173
|
+
token: deviceToken,
|
|
174
|
+
data: {
|
|
175
|
+
type: 'sync_required',
|
|
176
|
+
resource: 'conversations',
|
|
177
|
+
timestamp: Date.now().toString(),
|
|
178
|
+
},
|
|
179
|
+
// Android: set priority for background delivery
|
|
180
|
+
android: { priority: 'high' },
|
|
181
|
+
// APNs: required for background delivery on iOS
|
|
182
|
+
apns: {
|
|
183
|
+
headers: { 'apns-priority': '10' },
|
|
184
|
+
payload: { aps: { contentAvailable: true } },
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Token Management
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// API route to register/update tokens
|
|
193
|
+
export async function POST(request: Request) {
|
|
194
|
+
const { userId, token, platform } = await request.json();
|
|
195
|
+
|
|
196
|
+
await db.pushTokens.upsert({
|
|
197
|
+
where: { token },
|
|
198
|
+
create: { userId, token, platform, createdAt: new Date() },
|
|
199
|
+
update: { userId, updatedAt: new Date() },
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
return new Response('OK');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Clean up stale tokens
|
|
206
|
+
async function cleanStaleTokens() {
|
|
207
|
+
const tokens = await db.pushTokens.findMany();
|
|
208
|
+
const results = await messaging.sendEachForMulticast({
|
|
209
|
+
tokens: tokens.map(t => t.token),
|
|
210
|
+
data: { type: 'ping' }, // Dry run
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const staleTokens = tokens.filter((_, i) => !results.responses[i].success);
|
|
214
|
+
await db.pushTokens.deleteMany({ where: { token: { in: staleTokens.map(t => t.token) } } });
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Anti-Patterns
|
|
219
|
+
|
|
220
|
+
| Don't | Do |
|
|
221
|
+
|-------|-----|
|
|
222
|
+
| Store device tokens without a user association | Link tokens to user IDs for targeted messaging |
|
|
223
|
+
| Ignore `registration-token-not-registered` errors | Remove stale tokens to keep your token list clean |
|
|
224
|
+
| Send notifications without user consent | Request permission explicitly, respect denials |
|
|
225
|
+
| Put sensitive data in notification payload | Notification payloads are visible — use data messages for secrets |
|
|
226
|
+
| Use `sendAll` (deprecated) | Use `sendEachForMulticast` for batch sends |
|
|
227
|
+
| Hardcode VAPID keys in client code | Use environment variables for VAPID and project config |
|
|
228
|
+
| Skip the service worker for web push | `firebase-messaging-sw.js` is required for background web messages |
|
|
229
|
+
| Trust device tokens indefinitely | Tokens rotate — implement refresh and cleanup logic |
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sendgrid
|
|
3
|
+
description: "SendGrid email patterns covering transactional email, dynamic templates, email validation, webhook events, and suppression management. Use when implementing email delivery with SendGrid."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
source: self
|
|
6
|
+
date_added: "2026-03-14"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# SendGrid
|
|
10
|
+
|
|
11
|
+
Email delivery platform for transactional and marketing email. REST API with dynamic template support, event webhooks, and deliverability analytics.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- Sending transactional email (password resets, receipts, notifications)
|
|
16
|
+
- Building email campaigns with dynamic templates
|
|
17
|
+
- Need email delivery tracking (opens, clicks, bounces)
|
|
18
|
+
- Need email address validation
|
|
19
|
+
|
|
20
|
+
## When NOT to Use
|
|
21
|
+
|
|
22
|
+
- Need a simpler developer experience with React email templates (use Resend)
|
|
23
|
+
- Building in-app chat or real-time messaging (use a messaging SDK)
|
|
24
|
+
- SMS/voice communications (use Twilio)
|
|
25
|
+
|
|
26
|
+
## Setup
|
|
27
|
+
|
|
28
|
+
### Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @sendgrid/mail
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Client Initialization
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import sgMail from '@sendgrid/mail';
|
|
38
|
+
sgMail.setApiKey(process.env.SENDGRID_API_KEY!);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Environment Variables
|
|
42
|
+
|
|
43
|
+
```env
|
|
44
|
+
SENDGRID_API_KEY=SG.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
45
|
+
SENDGRID_FROM_EMAIL=noreply@example.com
|
|
46
|
+
SENDGRID_FROM_NAME=MyApp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Sending Email
|
|
50
|
+
|
|
51
|
+
### Simple Email
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
await sgMail.send({
|
|
55
|
+
to: 'user@example.com',
|
|
56
|
+
from: { email: process.env.SENDGRID_FROM_EMAIL!, name: 'MyApp' },
|
|
57
|
+
subject: 'Your order has shipped',
|
|
58
|
+
text: 'Order #1234 shipped via FedEx. Tracking: ABC123',
|
|
59
|
+
html: '<p>Order <strong>#1234</strong> shipped via FedEx.</p>',
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Dynamic Template
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
await sgMail.send({
|
|
67
|
+
to: 'user@example.com',
|
|
68
|
+
from: { email: process.env.SENDGRID_FROM_EMAIL!, name: 'MyApp' },
|
|
69
|
+
templateId: 'd-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
|
70
|
+
dynamicTemplateData: {
|
|
71
|
+
name: 'Jane Doe',
|
|
72
|
+
orderNumber: '1234',
|
|
73
|
+
items: [
|
|
74
|
+
{ name: 'Widget', qty: 2, price: '$19.99' },
|
|
75
|
+
{ name: 'Gadget', qty: 1, price: '$49.99' },
|
|
76
|
+
],
|
|
77
|
+
total: '$89.97',
|
|
78
|
+
trackingUrl: 'https://tracking.example.com/ABC123',
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Batch Send (Multiple Recipients)
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const messages = users.map(user => ({
|
|
87
|
+
to: user.email,
|
|
88
|
+
from: { email: process.env.SENDGRID_FROM_EMAIL!, name: 'MyApp' },
|
|
89
|
+
templateId: 'd-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
|
90
|
+
dynamicTemplateData: { name: user.name, code: user.resetCode },
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
// Send up to 1000 per batch
|
|
94
|
+
await sgMail.send(messages);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Send with Attachments
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
await sgMail.send({
|
|
101
|
+
to: 'user@example.com',
|
|
102
|
+
from: process.env.SENDGRID_FROM_EMAIL!,
|
|
103
|
+
subject: 'Your invoice',
|
|
104
|
+
html: '<p>Please find your invoice attached.</p>',
|
|
105
|
+
attachments: [
|
|
106
|
+
{
|
|
107
|
+
content: base64EncodedPdf,
|
|
108
|
+
filename: 'invoice-1234.pdf',
|
|
109
|
+
type: 'application/pdf',
|
|
110
|
+
disposition: 'attachment',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Event Webhooks
|
|
117
|
+
|
|
118
|
+
### Setup Webhook Handler
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// POST /api/webhooks/sendgrid
|
|
122
|
+
export async function POST(request: Request) {
|
|
123
|
+
const events = await request.json();
|
|
124
|
+
|
|
125
|
+
for (const event of events) {
|
|
126
|
+
switch (event.event) {
|
|
127
|
+
case 'delivered':
|
|
128
|
+
await markEmailDelivered(event.sg_message_id);
|
|
129
|
+
break;
|
|
130
|
+
case 'open':
|
|
131
|
+
await trackEmailOpen(event.sg_message_id, event.timestamp);
|
|
132
|
+
break;
|
|
133
|
+
case 'click':
|
|
134
|
+
await trackEmailClick(event.sg_message_id, event.url);
|
|
135
|
+
break;
|
|
136
|
+
case 'bounce':
|
|
137
|
+
await handleBounce(event.email, event.type); // 'bounce' or 'blocked'
|
|
138
|
+
break;
|
|
139
|
+
case 'spam_report':
|
|
140
|
+
await addToSuppressionList(event.email);
|
|
141
|
+
break;
|
|
142
|
+
case 'unsubscribe':
|
|
143
|
+
await unsubscribeUser(event.email);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return new Response('OK', { status: 200 });
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Verify Webhook Signature
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { EventWebhook } from '@sendgrid/eventwebhook';
|
|
156
|
+
|
|
157
|
+
export async function POST(request: Request) {
|
|
158
|
+
const publicKey = process.env.SENDGRID_WEBHOOK_VERIFICATION_KEY!;
|
|
159
|
+
const signature = request.headers.get('x-twilio-email-event-webhook-signature') ?? '';
|
|
160
|
+
const timestamp = request.headers.get('x-twilio-email-event-webhook-timestamp') ?? '';
|
|
161
|
+
const body = await request.text();
|
|
162
|
+
|
|
163
|
+
const ew = new EventWebhook();
|
|
164
|
+
const key = ew.convertPublicKeyToECDSA(publicKey);
|
|
165
|
+
const isValid = ew.verifySignature(key, body, signature, timestamp);
|
|
166
|
+
|
|
167
|
+
if (!isValid) {
|
|
168
|
+
return new Response('Invalid signature', { status: 403 });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const events = JSON.parse(body);
|
|
172
|
+
// Process events...
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Email Validation
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import Client from '@sendgrid/client';
|
|
180
|
+
Client.setApiKey(process.env.SENDGRID_API_KEY!);
|
|
181
|
+
|
|
182
|
+
async function validateEmail(email: string) {
|
|
183
|
+
const [response] = await Client.request({
|
|
184
|
+
url: '/v3/validations/email',
|
|
185
|
+
method: 'POST',
|
|
186
|
+
body: { email },
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const result = response.body.result;
|
|
190
|
+
return {
|
|
191
|
+
valid: result.verdict === 'Valid',
|
|
192
|
+
score: result.score, // 0-1 confidence
|
|
193
|
+
suggestion: result.suggestion, // e.g., "Did you mean user@gmail.com?"
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Key Limits
|
|
199
|
+
|
|
200
|
+
| Limit | Value |
|
|
201
|
+
|-------|-------|
|
|
202
|
+
| Free tier | 100 emails/day |
|
|
203
|
+
| Max recipients per API call | 1,000 |
|
|
204
|
+
| Max email size (with attachments) | 30 MB |
|
|
205
|
+
| Template dynamic data | 10,000 bytes |
|
|
206
|
+
| Rate limit (default) | 600 requests/min |
|
|
207
|
+
| Webhook events batch size | Up to 1,000 events per POST |
|
|
208
|
+
|
|
209
|
+
## Anti-Patterns
|
|
210
|
+
|
|
211
|
+
| Don't | Do |
|
|
212
|
+
|-------|-----|
|
|
213
|
+
| Hardcode `from` email in every send call | Use a shared constant or env var for `from` |
|
|
214
|
+
| Send HTML without a text fallback | Always provide both `text` and `html` content |
|
|
215
|
+
| Ignore bounce events | Handle bounces — suppress future sends to bounced addresses |
|
|
216
|
+
| Use personal email as sender | Use a domain you own with proper SPF/DKIM/DMARC |
|
|
217
|
+
| Skip webhook signature verification | Always verify `x-twilio-email-event-webhook-signature` |
|
|
218
|
+
| Send bulk email via the Mail Send API | Use Marketing Campaigns API for bulk/marketing sends |
|
|
219
|
+
| Store API key in client-side code | Keep `SENDGRID_API_KEY` server-side only |
|
|
220
|
+
| Log full email content | Never log email bodies — they may contain PII |
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: twilio
|
|
3
|
+
description: "Twilio communication patterns covering SMS/MMS sending, voice calls, WhatsApp, webhook handling, phone number management, and verification (Verify API). Use when implementing communications with Twilio."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
source: self
|
|
6
|
+
date_added: "2026-03-14"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Twilio
|
|
10
|
+
|
|
11
|
+
Cloud communications platform for SMS, voice, WhatsApp, and phone verification. Programmable via REST API with webhook-driven inbound message handling.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- Need to send or receive SMS/MMS messages
|
|
16
|
+
- Implementing phone number verification (OTP)
|
|
17
|
+
- Building voice call features (IVR, call forwarding)
|
|
18
|
+
- Sending WhatsApp messages programmatically
|
|
19
|
+
|
|
20
|
+
## When NOT to Use
|
|
21
|
+
|
|
22
|
+
- Email-only communications (use SendGrid, Resend)
|
|
23
|
+
- Push notifications to mobile apps (use FCM/APNs)
|
|
24
|
+
- Real-time chat in-app (use websockets or a chat SDK)
|
|
25
|
+
|
|
26
|
+
## Setup
|
|
27
|
+
|
|
28
|
+
### Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install twilio
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Client Initialization
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import twilio from 'twilio';
|
|
38
|
+
|
|
39
|
+
const client = twilio(
|
|
40
|
+
process.env.TWILIO_ACCOUNT_SID,
|
|
41
|
+
process.env.TWILIO_AUTH_TOKEN
|
|
42
|
+
);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Environment Variables
|
|
46
|
+
|
|
47
|
+
```env
|
|
48
|
+
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
49
|
+
TWILIO_AUTH_TOKEN=your-auth-token
|
|
50
|
+
TWILIO_PHONE_NUMBER=+15551234567
|
|
51
|
+
TWILIO_VERIFY_SERVICE_SID=VAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## SMS/MMS
|
|
55
|
+
|
|
56
|
+
### Send SMS
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const message = await client.messages.create({
|
|
60
|
+
body: 'Your order #1234 has shipped!',
|
|
61
|
+
from: process.env.TWILIO_PHONE_NUMBER,
|
|
62
|
+
to: '+15559876543',
|
|
63
|
+
});
|
|
64
|
+
console.log(`Sent: ${message.sid} — Status: ${message.status}`);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Send MMS (with media)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const message = await client.messages.create({
|
|
71
|
+
body: 'Your receipt is attached',
|
|
72
|
+
from: process.env.TWILIO_PHONE_NUMBER,
|
|
73
|
+
to: '+15559876543',
|
|
74
|
+
mediaUrl: ['https://example.com/receipt.pdf'],
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Receive SMS (Webhook)
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// POST /api/webhooks/twilio/sms
|
|
82
|
+
import { twiml } from 'twilio';
|
|
83
|
+
|
|
84
|
+
export async function POST(request: Request) {
|
|
85
|
+
const formData = await request.formData();
|
|
86
|
+
const from = formData.get('From') as string;
|
|
87
|
+
const body = formData.get('Body') as string;
|
|
88
|
+
|
|
89
|
+
// Process inbound message
|
|
90
|
+
await processInboundSMS(from, body);
|
|
91
|
+
|
|
92
|
+
// Respond with TwiML
|
|
93
|
+
const response = new twiml.MessagingResponse();
|
|
94
|
+
response.message('Thanks for your message! We\'ll get back to you soon.');
|
|
95
|
+
|
|
96
|
+
return new Response(response.toString(), {
|
|
97
|
+
headers: { 'Content-Type': 'text/xml' },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Phone Verification (Verify API)
|
|
103
|
+
|
|
104
|
+
### Send OTP
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const verification = await client.verify.v2
|
|
108
|
+
.services(process.env.TWILIO_VERIFY_SERVICE_SID!)
|
|
109
|
+
.verifications.create({
|
|
110
|
+
to: '+15559876543',
|
|
111
|
+
channel: 'sms', // or 'call', 'email', 'whatsapp'
|
|
112
|
+
});
|
|
113
|
+
console.log(`Verification status: ${verification.status}`); // 'pending'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Check OTP
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const check = await client.verify.v2
|
|
120
|
+
.services(process.env.TWILIO_VERIFY_SERVICE_SID!)
|
|
121
|
+
.verificationChecks.create({
|
|
122
|
+
to: '+15559876543',
|
|
123
|
+
code: '123456',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (check.status === 'approved') {
|
|
127
|
+
// Phone number verified
|
|
128
|
+
} else {
|
|
129
|
+
// Invalid code
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Voice Calls
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const call = await client.calls.create({
|
|
137
|
+
url: 'https://example.com/api/webhooks/twilio/voice',
|
|
138
|
+
to: '+15559876543',
|
|
139
|
+
from: process.env.TWILIO_PHONE_NUMBER,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Webhook handler responds with TwiML
|
|
143
|
+
export async function POST(request: Request) {
|
|
144
|
+
const response = new twiml.VoiceResponse();
|
|
145
|
+
response.say('Hello! Thank you for calling. Press 1 for support.');
|
|
146
|
+
response.gather({
|
|
147
|
+
numDigits: 1,
|
|
148
|
+
action: '/api/webhooks/twilio/voice/menu',
|
|
149
|
+
});
|
|
150
|
+
return new Response(response.toString(), {
|
|
151
|
+
headers: { 'Content-Type': 'text/xml' },
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Webhook Signature Validation
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { validateRequest } from 'twilio';
|
|
160
|
+
|
|
161
|
+
export async function POST(request: Request) {
|
|
162
|
+
const signature = request.headers.get('x-twilio-signature') ?? '';
|
|
163
|
+
const url = request.url;
|
|
164
|
+
const body = Object.fromEntries(await request.formData());
|
|
165
|
+
|
|
166
|
+
const isValid = validateRequest(
|
|
167
|
+
process.env.TWILIO_AUTH_TOKEN!,
|
|
168
|
+
signature,
|
|
169
|
+
url,
|
|
170
|
+
body as Record<string, string>
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
if (!isValid) {
|
|
174
|
+
return new Response('Invalid signature', { status: 403 });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Process webhook...
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Key Limits
|
|
182
|
+
|
|
183
|
+
| Limit | Value |
|
|
184
|
+
|-------|-------|
|
|
185
|
+
| SMS body max length | 1,600 characters (concatenated) |
|
|
186
|
+
| MMS max media size | 5 MB per media |
|
|
187
|
+
| MMS max media count | 10 per message |
|
|
188
|
+
| Verify OTP expiry | 10 minutes (default) |
|
|
189
|
+
| Messages per second (default) | 1 msg/sec per number |
|
|
190
|
+
| Toll-free throughput | 3 msg/sec |
|
|
191
|
+
| Short code throughput | 100 msg/sec |
|
|
192
|
+
|
|
193
|
+
## Anti-Patterns
|
|
194
|
+
|
|
195
|
+
| Don't | Do |
|
|
196
|
+
|-------|-----|
|
|
197
|
+
| Hardcode phone numbers in source | Use environment variables for all phone numbers |
|
|
198
|
+
| Skip webhook signature validation | Always validate `x-twilio-signature` header |
|
|
199
|
+
| Build your own OTP system | Use Twilio Verify API — handles rate limiting, expiry, retries |
|
|
200
|
+
| Store `TWILIO_AUTH_TOKEN` in client-side code | Keep all Twilio credentials server-side only |
|
|
201
|
+
| Send SMS from a single number at high volume | Use a messaging service with number pool for throughput |
|
|
202
|
+
| Ignore delivery status callbacks | Set `statusCallback` URL to track delivery outcomes |
|
|
203
|
+
| Use long codes for marketing/bulk SMS | Use toll-free or short codes for high-volume messaging |
|
|
204
|
+
| Log full phone numbers | Redact/mask phone numbers in logs (PII) |
|