P
💻DeveloppementAdvancedAll AIs

Prompt to Create Optimized Serverless Functions

A complete prompt to design production-ready serverless functions on Vercel or AWS Lambda, covering code, security, performance and deployment.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert en architectures serverless spécialisé dans [PLATEFORME : Vercel Functions / AWS Lambda / les deux]. Je développe une application [TYPE_APPLICATION : ex. SaaS B2B, e-commerce, API publique, application mobile backend] et j'ai besoin de concevoir des serverless functions pour le cas d'usage suivant :

Contexte fonctionnel : [DESCRIPTION_FONCTIONNALITE : ex. traitement de webhooks Stripe, génération de PDF, envoi d'emails transactionnels, CRON de synchronisation de données]

Stack technique : [STACK : ex. Next.js 14 App Router, Node.js 20, Python 3.12, TypeScript]

Contraintes :

  • Runtime : [RUNTIME : Node.js / Python / Go / Rust]
  • Temps d'exécution max : [TIMEOUT : ex. 10s, 30s, 5min]
  • Mémoire allouée : [MEMOIRE : ex. 128MB, 512MB, 1024MB]
  • Volume estimé : [VOLUME : ex. 100 req/min, 10K/jour, pics à 1000 req/s]

Génère le code complet de la function avec :

  1. Structure du handler — Point d'entrée optimisé avec typage strict, parsing et validation de l'input (utilise zod ou équivalent)
  2. Gestion des erreurs — Try/catch structuré, codes HTTP appropriés, messages d'erreur exploitables sans fuite d'information sensible
  3. Optimisation cold start — Initialisation des clients (DB, SDK) en dehors du handler, lazy loading des dépendances lourdes, tree-shaking
  4. Sécurité — Validation des headers d'authentification, vérification de signature webhook si applicable, rate limiting, CORS
  5. Observabilité — Logging structuré (JSON), métriques custom, trace ID pour le debugging distribué
  6. Configuration — Variables d'environnement requises avec valeurs par défaut sûres, fichier de config séparé
  7. Tests — Un test unitaire du handler et un test d'intégration avec mocks des services externes
  8. Déploiement — Configuration de déploiement (vercel.json ou serverless.yml ou SAM template) avec les settings de mémoire, timeout et environnement

Pour chaque section, explique les choix techniques et les pièges courants à éviter. Indique les coûts estimés pour le volume spécifié.

Personalize this prompt with Léa

Answer 3 questions and Léa tailors the prompt to your situation.

Why this prompt works

<p>This prompt guides AI to produce <strong>complete, production-ready serverless functions</strong>. By specifying your target platform (Vercel or AWS Lambda), tech stack and performance constraints, you get structured code following serverless best practices: cold start management, optimized connection initialization, and deployment configuration.</p><p>The <strong>bracketed variables</strong> let you adapt the prompt to your exact context. The <code>[VOLUME]</code> field is particularly important as it influences recommendations on allocated memory, provisioned concurrency, and cost estimation. Also specify the <code>[TIMEOUT]</code> as strategies differ radically between a fast API function (3-10s) and a long batch process (up to 15min on AWS).</p><p>For optimal results:</p><ul><li><strong>Be specific about the use case</strong> — a Stripe webhook and a REST API don't have the same security and retry patterns</li><li><strong>Mention your external services</strong> (database, S3, third-party APIs) so the AI optimizes connections and pooling</li><li><strong>Iterate on tests</strong> — then request load scenarios and resilience tests (external timeout, network errors)</li></ul>

Use Cases

Create a serverless REST API with JWT authentication and database connectionDevelop a secure Stripe webhook handler with signature verificationSet up a serverless CRON for data synchronization between servicesDesign a function for on-the-fly image processing or PDF generation

Expected Output

Complete, commented code for the serverless function with its handler, tests, deployment configuration, and explanations of architecture choices, performance optimizations and cost estimation.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateGemini

Gemini Prompt for Generating SQL Queries

Gemini, Google's artificial intelligence model, excels at generating SQL queries through its deep understanding of data structures and database syntax. Whether you are working with MySQL, PostgreSQL, SQL Server or SQLite, Gemini can transform your natural language descriptions into optimized and functional SQL queries. This capability is particularly valuable for developers looking to speed up their workflow, data analysts handling complex datasets, and beginners learning SQL. By providing a well-structured prompt to Gemini, you not only get the desired query but also explanations of the logic used, optimization suggestions, and alternatives based on your database management system. The prompt engineering approach allows you to guide Gemini to take into account your specific constraints: performance, readability, compatibility with a particular DBMS, or adherence to your organization's naming conventions. Discover how to formulate your prompts to get the most out of Gemini in generating SQL queries.

0146
💻DeveloppementAdvancedAll AIs

Create Async Workers and Jobs with AI

A complete prompt to design and implement async workers and jobs with queuing, retry, monitoring and deployment.

057
💻DeveloppementIntermediateClaude

Prompt Claude to Create a Prototype

Creating a prototype is a crucial step in developing a product, application, or service. Traditionally, this phase requires a variety of technical skills, time, and often a multidisciplinary team. With Claude, you can significantly accelerate this process by generating functional prototypes from a simple description of your idea. Whether you want to design an interactive user interface, a web application mockup, an API prototype, or even a technical proof of concept, Claude can produce functional code, HTML/CSS wireframes, or complete architectures ready to be tested. The major advantage is Claude's ability to iterate quickly: you describe your vision, get a first prototype, then refine through successive exchanges until you get exactly what you're looking for. This approach democratizes rapid prototyping and allows entrepreneurs, designers, and product managers to validate their hypotheses without fully relying on a development team in the early stages of the project.

0515
💻DeveloppementIntermediateAll AIs

Generate a code coverage report plan

Plan test coverage improvements

0136