Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Serverless Patterns Guide

Serverless Patterns Guide

Build efficient serverless applications with Google Antigravity

serverlessaws-lambdastep-functionseventbridge
by antigravity-team
⭐0Stars
.antigravity
# Serverless Patterns Guide for Google Antigravity

Master serverless architecture patterns for building scalable, cost-effective applications with Google Antigravity IDE.

## Lambda Function Patterns

```typescript
// functions/api-handler.ts
import { APIGatewayProxyHandlerV2, APIGatewayProxyResultV2 } from "aws-lambda";
import { z } from "zod";
import middy from "@middy/core";
import httpJsonBodyParser from "@middy/http-json-body-parser";
import httpErrorHandler from "@middy/http-error-handler";
import validator from "@middy/validator";
import { transpileSchema } from "@middy/validator/transpile";

const createUserSchema = z.object({
  name: z.string().min(1).max(100),
  email: z.string().email(),
  role: z.enum(["user", "admin"]).default("user")
});

type CreateUserInput = z.infer<typeof createUserSchema>;

const baseHandler: APIGatewayProxyHandlerV2 = async (event) => {
  const body = event.body as unknown as CreateUserInput;
  
  const user = await createUser(body);
  
  return {
    statusCode: 201,
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ data: user })
  };
};

export const handler = middy(baseHandler)
  .use(httpJsonBodyParser())
  .use(validator({ eventSchema: transpileSchema(createUserSchema) }))
  .use(httpErrorHandler());

// Cold start optimization
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";

// Initialize outside handler for connection reuse
const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);

async function createUser(input: CreateUserInput) {
  const { PutCommand } = await import("@aws-sdk/lib-dynamodb");
  const userId = crypto.randomUUID();
  
  await docClient.send(new PutCommand({
    TableName: process.env.USERS_TABLE,
    Item: { pk: `USER#${userId}`, sk: "PROFILE", ...input, createdAt: new Date().toISOString() }
  }));
  
  return { id: userId, ...input };
}
```

## Step Functions Workflow

```typescript
// workflows/order-processing.ts
import { SFNClient, StartExecutionCommand } from "@aws-sdk/client-sfn";

interface OrderWorkflowInput {
  orderId: string;
  customerId: string;
  items: { productId: string; quantity: number; price: number }[];
  totalAmount: number;
}

export const startOrderWorkflow = async (input: OrderWorkflowInput) => {
  const client = new SFNClient({});
  
  await client.send(new StartExecutionCommand({
    stateMachineArn: process.env.ORDER_STATE_MACHINE_ARN,
    input: JSON.stringify(input),
    name: `order-${input.orderId}-${Date.now()}`
  }));
};

// Step function definition (CDK)
import * as sfn from "aws-cdk-lib/aws-stepfunctions";
import * as tasks from "aws-cdk-lib/aws-stepfunctions-tasks";

const validateOrder = new tasks.LambdaInvoke(this, "ValidateOrder", {
  lambdaFunction: validateOrderFn,
  outputPath: "$.Payload"
});

const processPayment = new tasks.LambdaInvoke(this, "ProcessPayment", {
  lambdaFunction: paymentFn,
  outputPath: "$.Payload"
});

const reserveInventory = new tasks.LambdaInvoke(this, "ReserveInventory", {
  lambdaFunction: inventoryFn,
  outputPath: "$.Payload"
});

const definition = validateOrder
  .next(new sfn.Parallel(this, "ProcessParallel")
    .branch(processPayment)
    .branch(reserveInventory))
  .next(new sfn.Choice(this, "CheckResults")
    .when(sfn.Condition.booleanEquals("$.success", true), sendConfirmation)
    .otherwise(handleFailure));
```

## Event Bridge Patterns

```typescript
// events/event-bridge.ts
import { EventBridgeClient, PutEventsCommand } from "@aws-sdk/client-eventbridge";

const eventBridge = new EventBridgeClient({});

interface DomainEvent {
  source: string;
  detailType: string;
  detail: Record<string, unknown>;
}

export const publishEvent = async (event: DomainEvent) => {
  await eventBridge.send(new PutEventsCommand({
    Entries: [{
      Source: event.source,
      DetailType: event.detailType,
      Detail: JSON.stringify(event.detail),
      EventBusName: process.env.EVENT_BUS_NAME
    }]
  }));
};

// Event handler
export const orderEventHandler = async (event: { detail: OrderEvent }) => {
  const { detail } = event;
  
  switch (detail.type) {
    case "ORDER_PLACED":
      await notifyWarehouse(detail);
      await updateAnalytics(detail);
      break;
    case "ORDER_SHIPPED":
      await notifyCustomer(detail);
      break;
  }
};
```

## Best Practices

1. **Minimize cold starts** with provisioned concurrency
2. **Use connection pooling** for database connections
3. **Implement idempotency** for retry safety
4. **Set appropriate timeouts** and memory settings
5. **Use dead letter queues** for failed events
6. **Implement circuit breakers** for external calls
7. **Monitor with X-Ray** for distributed tracing

Google Antigravity optimizes serverless function code and provides intelligent suggestions for cost and performance improvements.

When to Use This Prompt

This serverless prompt is ideal for developers working on:

  • serverless applications requiring modern best practices and optimal performance
  • Projects that need production-ready serverless code with proper error handling
  • Teams looking to standardize their serverless development workflow
  • Developers wanting to learn industry-standard serverless patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their serverless implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the serverless code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this serverless prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For serverless projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...