Scaffold a Small Serverless Function With Guard Rails
Get a single-purpose serverless function for your platform with input validation, env-var config, structured errors and a local test path.
When to use it: When you need a webhook handler, form receiver or scheduled job and want a clean starting point instead of a hello-world that falls over on the first bad request.
You are a senior developer scaffolding a small serverless function. You favour boring, readable code with explicit failure handling over cleverness.
Platform: [PLATFORM — e.g. Cloudflare Workers / AWS Lambda / Supabase Edge Functions]
Language: [LANGUAGE — e.g. TypeScript]
Trigger: [TRIGGER — e.g. HTTP POST webhook from Stripe / cron every hour]
What it must do, in one sentence: [JOB — e.g. verify the webhook signature and write the order to a database]
External services and secrets involved: [SERVICES — e.g. Postgres via connection string, Stripe signing secret]
Before writing code, list the failure modes this function must survive (malformed body, missing signature, upstream timeout, duplicate delivery) and note which the scaffold will handle versus which need my product decision.
Then produce:
1. One function file doing exactly the stated job — no speculative abstractions. Validate inputs at the top and reject bad requests with the correct status code and a short JSON error body.
2. All configuration via environment variables with a documented list; never hardcode secrets or example keys that look real.
3. Structured log lines (start, success, each failure path) with enough context to debug, but never logging secrets or full personal data.
4. Timeout and retry notes for each external call, matched to what my platform actually supports — if unsure of a platform detail, say [CHECK: platform docs for X] rather than inventing an API.
5. A local run/test recipe: the platform's dev command plus two curl examples (one valid, one that must be rejected) with expected responses.
6. A short deploy note for my platform and a list of what I still must decide (idempotency, dead-letter handling).
Output: the failure-mode list, the code in one block, the env-var table, then test and deploy steps. Use only the services I named.
Copy the block above straight into Any AI tool — anything in [BRACKETS] is yours to fill in.
Want it tuned to your business? Bring it to the free weekly call and we'll adapt it live.
Join the free callMore au business & compliance prompts
Plain-English Contract Summariser
Understand what you're signing before you sign it — and know what to ask a professional
Set Up Redirects and Caching on an Apache Site
Get a ready-to-paste .htaccess block with redirects, HTTPS forcing and caching, plus install, test and undo steps.
Script a Hard Conversation Before You Have It
Turn a dreaded workplace conversation into a short, direct script with openers, key lines and responses to likely reactions.