用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill lambda-service-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | lambda-service-patterns |
| description | >- Use when this capability is needed. |
You guide implementation of Catalyst's 7+ Lambda functions using aws-lambda-powertools for Python and async patterns where the runtime supports them. You enforce the standards from AGENTS.md and patterns from Platform Engineering for Architects (Ch 5, pp 157-198: integration, delivery, deployment automation). For handler clarity, decorator discipline (Powertools stack order), and testable handler cores, invoke @clean-python-code.
Every Lambda handler follows this structure:
from aws_lambda_powertools import Logger, Tracer, Metrics
from aws_lambda_powertools.metrics import MetricUnit
from aws_lambda_powertools.utilities.idempotency import (
DynamoDBPersistenceLayer, idempotent,
)
from aws_lambda_powertools.utilities.typing import LambdaContext
logger = Logger(service="webhook-handler")
tracer = Tracer(service="webhook-handler")
metrics = Metrics(namespace="Catalyst", service="webhook-handler")
persistence = DynamoDBPersistenceLayer(table_name="catalyst-idempotency")
@logger.inject_lambda_context(log_event=True)
@tracer.capture_lambda_handler
@metrics.log_metrics(capture_cold_start_metric=True)
@idempotent(persistence_store=persistence)
def handler(event: dict, context: LambdaContext) -> dict:
...
Stack order matters: Logger outermost (captures context), then Tracer, then Metrics, then Idempotency innermost.
AGENTS.md §4)| Service | Trigger | Key patterns |
|---|---|---|
webhook-handler | API Gateway HTTP API | HMAC validation, SQS FIFO send, event routing |
deploy-orchestrator | Step Functions invocation | ECS update, ALB rule modify, DDB write, SNS publish |
secrets-rotator | Secrets Manager rotation hook | createSecret / setSecret / testSecret / finishSecret stages |
ops-intel-collector | EventBridge rate(1 hour) | SQS fan-out to 5 probe queues |
ops-intel probes (5x) | SQS | Domain-scoped AWS API reads, S3 raw partition writes |
ops-intel-reporter | EventBridge on probe completion | S3 read, DDB write, Bedrock Haiku summarize, SNS digest |
Use Powertools BatchProcessor for SQS-triggered Lambdas:
from aws_lambda_powertools.utilities.batch import (
BatchProcessor, EventType, batch_processor,
)
processor = BatchProcessor(event_type=EventType.SQS)
@tracer.capture_method
def record_handler(record: SQSRecord) -> None:
payload = json.loads(record.body)
# process one record; raise on failure for partial batch
@logger.inject_lambda_context
@tracer.capture_lambda_handler
@metrics.log_metrics
def handler(event: dict, context: LambdaContext) -> dict:
return processor.process(event, record_handler)
Partial batch failure: configure FunctionResponseTypes: ReportBatchItemFailures in the event source mapping (Terraform side). Failed records retry; successful ones don't.
Per AGENTS.md, the webhook-handler must deduplicate GitHub webhook deliveries:
X-GitHub-Delivery header as MessageDeduplicationId.catalyst-idempotency DynamoDB table with event_key_jmespath set to the delivery ID.Lambda functions are packaged as Docker images (not zip):
FROM public.ecr.aws/lambda/python:3.14 AS builder
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt -t /opt/python
FROM public.ecr.aws/lambda/python:3.14
COPY --from=builder /opt/python ${LAMBDA_TASK_ROOT}
COPY src/ ${LAMBDA_TASK_ROOT}/
CMD ["handler.handler"]
Per Platform Engineering for Architects Ch 5 (pp 167-175): source → container image → metadata-enriched deployment artifact. Tag images with git SHA, never :latest.
webhook-handler (latency-sensitive, API Gateway origin).__init__ outside the handler.POWERTOOLS_DEV=true locally for human-readable logs; JSON in production.logger.info("webhook_received",
delivery_id=delivery_id,
event_type=event["headers"]["X-GitHub-Event"],
repo=payload["repository"]["full_name"],
)
Every log line automatically includes trace_id (X-Ray), request_id (Lambda context), service, cold_start, and sampling_rate via Powertools.
metrics.add_metric(name="WebhookProcessed", unit=MetricUnit.Count, value=1)
metrics.add_dimension(name="EventType", value=event_type)
metrics.add_dimension(name="Repository", value=repo_name)
Per AGENTS.md: emit EMF metrics for any long-running operation with latency, error count, and relevant dimensions.
error level, return failure response, do NOT retry.IllegalTransitionError, comment on the GitHub Issue, move to DLQ.# tests/unit/test_webhook_handler.py
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEventV2
def test_valid_push_event(mock_sqs, sample_push_payload):
event = APIGatewayProxyEventV2({"body": json.dumps(sample_push_payload), ...})
result = handler(event.raw_event, MockContext())
assert result["statusCode"] == 200
mock_sqs.send_message.assert_called_once()
Use Powertools event classes for test fixtures. Mock AWS services with moto or manual mocks.
infrastructure/modules/composite/lambda-python-fn/)boto3 in handler hot path — use aioboto3 or Powertools utilities.print() — Powertools Logger only.get_secret utility.:latest image tags — git SHA or semver.Source: Cloud-Byte-Consulting/Catalyst — distributed by TomeVault.