Advanced Serverless patterns — Lambda idempotency (Lambda Powertools + DynamoDB persistence layer), Lambda cost model (pricing formula, break-even vs containers), and CloudWatch Insights observability queries for cold starts, duration, and errors.
From clarcnpx claudepluginhub marvinrichter/clarc --plugin clarcThis skill uses the workspace's default tool permissions.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
This skill extends serverless-patterns with idempotency, cost modeling, and observability. Load serverless-patterns first.
Lambda can be invoked multiple times for the same event (at-least-once delivery). Always design for idempotency.
import { makeHandlerIdempotent } from '@aws-lambda-powertools/idempotency';
import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb';
const persistenceStore = new DynamoDBPersistenceLayer({
tableName: 'IdempotencyTable',
});
// Wrap handler — duplicate events return cached result
export const handler = makeHandlerIdempotent(
async (event: OrderEvent) => {
await chargePayment(event.paymentId, event.amount);
await createOrder(event);
return { orderId: event.orderId, status: 'created' };
},
{ persistenceStore }
);
# Required DynamoDB table
IdempotencyTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
TimeToLiveSpecification:
AttributeName: expiration
Enabled: true
BillingMode: PAY_PER_REQUEST
Lambda pricing (us-east-1):
Break-Even: Lambda vs. Container
Lambda cost/month = requests × $0.0000002 + (avg_duration_s × memory_GB × requests × $0.0000166667)
Example: 10M requests/month, 200ms avg, 512MB
= 10M × $0.0000002 + (0.2 × 0.5 × 10M × $0.0000166667)
= $2 + $16.67
= ~$18.67/month
ECS Fargate (0.25 vCPU, 0.5GB) = ~$12/month (continuous)
Rule of thumb: Lambda wins below ~5M requests/month or spiky traffic.
Containers win with constant high-volume predictable load.
# CloudWatch Insights — Lambda performance
fields @timestamp, @duration, @billedDuration, @memorySize, @maxMemoryUsed, @initDuration
| filter @type = "REPORT"
| stats avg(@duration), max(@duration), avg(@initDuration) by bin(5m)
# Cold starts only
fields @timestamp, @initDuration
| filter @type = "REPORT" and ispresent(@initDuration)
| stats count(), avg(@initDuration) by bin(1h)
# Errors
fields @timestamp, @message
| filter @message like /ERROR/
| sort @timestamp desc
| limit 50
serverless-patterns — cold starts, Step Functions, Lambda Powertools (Logger, Metrics, Tracer)edge-patterns — Cloudflare Workers, Vercel Edge Middlewareobservability — OpenTelemetry, Grafana, distributed tracingchaos-engineering — Testing Lambda failure modes (throttling, DLQ exhaustion)