一键导入
tpl-backend-serverless-lambda
Template do pack (backend/06-serverless-lambda.md). Orienta o agente em APIs, servicos e arquitetura backend alinhado a esse contexto.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Template do pack (backend/06-serverless-lambda.md). Orienta o agente em APIs, servicos e arquitetura backend alinhado a esse contexto.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate custom favicons from logos, text, or brand colours. Produces favicon.svg, favicon.ico, apple-touch-icon.png, icon-192/512.png, and web manifest. Use whenever the user wants a favicon, mentions replacing a CMS default favicon, converting a logo into a favicon, creating branded initials icons, or troubleshooting favicon not displaying / iOS black square / missing manifest.
"Get a second opinion from leading AI models on code, architecture, strategy, prompting, or anything. Queries models via OpenRouter, Gemini, or OpenAI APIs. Supports single opinion, multi-model consensus, and devil's advocate patterns. Use whenever the user says 'brains trust', 'second opinion', 'ask gemini', 'ask gpt', 'peer review', 'consult another model', 'challenge this', or 'devil's advocate'."
Run an independent code review using the OpenAI Codex CLI in headless mode. Gets a second opinion from a different model family (GPT-5/o3) on recent changes, a PR, a commit, or the whole app — covering bugs, regressions, security, data consistency, UX/state bugs, performance risks, and testing gaps. Saves a severity-prioritised report to .jez/reviews/. Triggers: 'codex review', 'review with codex', 'second opinion on this code', 'independent code review', 'what does codex think', 'get codex to review'.
Deep research and discovery before building something new. Explores local projects for reusable code, researches competitors, reads forums and reviews, analyses plugin ecosystems, investigates technical options, and produces a comprehensive research brief. Three depths: focused (30 min), wide (1-2 hours), deep (3-6 hours). Triggers: 'research this', 'deep research', 'discovery', 'explore the space', 'what should I build', 'competitive analysis', 'before I start building', 'research before coding'.
Plan and execute entire application builds. Generates phased delivery roadmaps, then executes them autonomously — phase by phase, committing at milestones, deploying, testing, and continuing until done or stuck. Modes: plan (generate roadmap), start (begin executing), resume (continue from where you left off), status (show progress). Triggers: 'roadmap', 'plan the build', 'start building', 'resume the build', 'keep going', 'build the whole thing', 'execute the roadmap', 'what phase are we on'.
Walk through a live web app AS a real user to find usability + behavioural bugs that static reviews miss. REQUIRES proof of interaction (typing, clicking, sending, observing) before any verdict — a sweep that didn't interact terminates with verdict 'Incomplete'. Walks threads, exercises every element, runs the multi-pane stress matrix, visual polish sweep, component perfection checklist, automated a11y (axe-core), pragmatic performance budget (LCP/CLS/INP), scenario battery (11 scenarios), and stress recipes including the real-flavour data battery. Hard gates: console errors/warnings = 0, network 5xx = 0, layout collapse = 0, axe Critical/Serious = 0, perf budget green. Audit-the-audit meta-check rejects rushed reports. Each finding has reproduction steps, evidence path, and suspected code location. Trigger with 'ux audit', 'walkthrough', 'qa sweep', 'audit the app', 'dogfood this', 'check all pages', 'find what's broken', 'stress the UI'.
| name | tpl-backend-serverless-lambda |
| description | Template do pack (backend/06-serverless-lambda.md). Orienta o agente em APIs, servicos e arquitetura backend alinhado a esse contexto. |
| metadata | {"version":"1.0.0","source_template":"backend/06-serverless-lambda.md","generated_by":"install_pack_templates_as_claude_skills"} |
Skill gerado a partir do pack templates-claude-code. Arquivo de origem: backend/06-serverless-lambda.md. Use como baseline e adapte ao projeto antes de mudancas grandes.
| Technology | Version | Purpose |
|---|---|---|
| Node.js | 22.x (Lambda) | Runtime |
| TypeScript | 5.4+ | Language |
| SST | v3 | Infrastructure as code + local dev |
| AWS Lambda | — | Compute |
| API Gateway v2 (HTTP) | — | HTTP trigger |
| DynamoDB | — | Primary database |
| AWS SDK v3 | 3.x | DynamoDB DocumentClient |
| Zod | 3.x | Input validation |
| AWS Lambda Powertools | 2.x | Logger, Tracer, Metrics middleware |
| Jest | 29.x | Unit tests |
| esbuild | — | Bundler (via SST) |
sst.config.ts # SST stack definitions (infra as code)
packages/
└── functions/
├── package.json
├── tsconfig.json
├── src/
│ ├── handlers/
│ │ ├── users/
│ │ │ ├── create.ts # POST /users
│ │ │ ├── get.ts # GET /users/{id}
│ │ │ ├── list.ts # GET /users
│ │ │ └── delete.ts # DELETE /users/{id}
│ │ └── auth/
│ │ ├── login.ts
│ │ └── refresh.ts
│ ├── services/
│ │ └── users.service.ts # Business logic
│ ├── repositories/
│ │ └── users.repository.ts # DynamoDB queries
│ ├── middleware/
│ │ ├── auth.ts # JWT verification (Powertools middleware)
│ │ └── validate.ts # Zod validation middleware
│ ├── lib/
│ │ ├── dynamo.ts # DocumentClient singleton
│ │ ├── jwt.ts # Sign/verify tokens
│ │ └── response.ts # Standard API Gateway response helpers
│ └── types/
│ └── index.ts
└── tests/
├── unit/
│ └── users.service.test.ts
└── integration/
└── users.handler.test.ts
handler function@aws-sdk/client-dynamodbpackages/core/ (separate SST package) to avoid duplicating across lambdas// ✅ Do: initialize clients OUTSIDE the handler (module scope)
// Runs once per container, not per invocation
const docClient = new DynamoDBDocumentClient(new DynamoDBClient({}))
const userRepo = new UserRepository(docClient)
export const handler = async (event: APIGatewayProxyEventV2) => {
// handler code here — docClient already initialized
}
// ❌ Don't: initialize inside handler (cold start on every call)
export const handler = async (event: APIGatewayProxyEventV2) => {
const docClient = new DynamoDBDocumentClient(new DynamoDBClient({})) // wrong
}
esbuild tree-shaking — import only what you need from AWS SDK v3aws-sdk as external in bundler (provided by Lambda runtime)sst analyze to check bundle sizes before deploy// src/handlers/users/get.ts
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'
import { Logger } from '@aws-lambda-powertools/logger'
import { Tracer } from '@aws-lambda-powertools/tracer'
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'
import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware'
import middy from '@middy/core'
import { z } from 'zod'
import { UserService } from '../../services/users.service'
import { ok, notFound, badRequest } from '../../lib/response'
const logger = new Logger({ serviceName: 'users-api', logLevel: 'INFO' })
const tracer = new Tracer({ serviceName: 'users-api' })
const metrics = new Metrics({ namespace: 'UsersAPI', serviceName: 'users-api' })
const paramsSchema = z.object({
id: z.string().uuid('Invalid user ID format'),
})
const lambdaHandler = async (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> => {
const parsed = paramsSchema.safeParse(event.pathParameters)
if (!parsed.success) {
return badRequest(parsed.error.flatten())
}
const user = await UserService.getById(parsed.data.id)
if (!user) {
logger.warn('User not found', { userId: parsed.data.id })
return notFound('User not found')
}
metrics.addMetric('UserFetched', MetricUnits.Count, 1)
logger.info('User fetched', { userId: user.id })
return ok(user)
}
export const handler = middy(lambdaHandler)
.use(injectLambdaContext(logger, { clearState: true }))
.use(captureLambdaHandler(tracer))
// src/lib/response.ts
import type { APIGatewayProxyResultV2 } from 'aws-lambda'
function json(statusCode: number, body: unknown): APIGatewayProxyResultV2 {
return {
statusCode,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
}
}
export const ok = (data: unknown) => json(200, { data })
export const created = (data: unknown) => json(201, { data })
export const badRequest = (details: unknown) => json(400, { error: 'Bad Request', details })
export const unauthorized = () => json(401, { error: 'Unauthorized' })
export const forbidden = () => json(403, { error: 'Forbidden' })
export const notFound = (msg: string) => json(404, { error: msg })
export const internalError = () => json(500, { error: 'Internal Server Error' })
// sst.config.ts — define explicit permissions, never use AdministratorAccess
const usersTable = new sst.aws.Dynamo('UsersTable', {
fields: { pk: 'string', sk: 'string' },
primaryIndex: { hashKey: 'pk', rangeKey: 'sk' },
})
const getUserFn = new sst.aws.Function('GetUser', {
handler: 'packages/functions/src/handlers/users/get.handler',
environment: {
USERS_TABLE_NAME: usersTable.name,
JWT_SECRET: new sst.Secret('JwtSecret').value,
},
permissions: [
// Only the actions this function needs
{ actions: ['dynamodb:GetItem'], resources: [usersTable.arn] },
],
})
Resource.JwtSecret.value in SST v3 (type-safe binding)environment object (becomes Lambda env var)| Trigger | Method | Route | Auth | Handler |
|---|---|---|---|---|
| Register | POST | /users/register | Public | handlers/auth/register.handler |
| Login | POST | /auth/login | Public | handlers/auth/login.handler |
| Refresh token | POST | /auth/refresh | Refresh token | handlers/auth/refresh.handler |
| Get user | GET | /users/{id} | Bearer JWT | handlers/users/get.handler |
| List users | GET | /users | Bearer + Admin | handlers/users/list.handler |
| Create user | POST | /users | Bearer + Admin | handlers/users/create.handler |
| Update user | PATCH | /users/{id} | Bearer + Admin | handlers/users/update.handler |
| Delete user | DELETE | /users/{id} | Bearer + Admin | handlers/users/delete.handler |
| Health | GET | /health | Public | handlers/health.handler |
Before deploying, verify ALL of the following:
npx tsc --noEmit passes across all packagesjest --runInBand passes (Lambda tests often can't run in parallel)sst analyzesst.Secret or environment varslogger.info/warn/error used (not console.log) for structured logsprocess.env)badRequest, internalError) — no manual statusCodeAdministratorAccess IAM policy — define specific actions + resourcesconsole.log in handlers — use Powertools Logger@aws-sdk/client-dynamodb directly in handlers — go through repository layer