agentleFS
isabelle-barpisabelle-barp/agent-brain/skills/stack-aws/SKILL.md

stack-aws

Skill0 starsChanged 5 months agoApache-2.0View on GitHub

AWS implementation patterns for agents working in projects whose docs/TECH_STACK.md lists `aws`. Load when implementing, testing, reviewing, or deploying code on this stack.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Cold-start aware bootstrap: create the Nest app / SDK clients / DB connections in module scope, cache the promise, await it inside the …

    line 35
  2. Distinctive:

    DON'T schedule work after returning the response — the event loop freezes at return.

    line 37
  3. Very specific:

    Use partial batch failure reporting (ReportBatchItemFailures) so one poison message doesn't recycle the whole batch.

    line 43

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Stack: AWS

Grounded in host-aws's CDK/Lambda architecture; broader sections seeded from best practice — refine via repository-discovery. Where the host project's docs/ARCHITECTURE.md/deployment docs contradict a default below, the generated docs win.

Reference architecture (the extracted source): CloudFront → S3 (static SPA) + CloudFront /api/* → API Gateway → Lambda (Node 20) for business logic, Cognito for auth, infrastructure as AWS CDK stacks (Cognito/Api/Frontend, deployed in dependency order), region us-east-1.

When this applies

Detection markers (any of):

  • docs/TECH_STACK.md ## Detected stacks lists aws
  • Dependencies: any @aws-sdk/* (v3 modular clients), aws-cdk-lib/aws-cdk
  • Files: cdk.json, serverless.yml with provider: aws, SAM templates (AWS::Serverless transform), Terraform files declaring the aws provider
  • CI: aws-actions/* steps in workflow files

Implementation patterns

Credentials and secrets (BLOCKER discipline)

  • SDK v3 modular clients only (@aws-sdk/client-s3, @aws-sdk/client-sqs, ...). The monolithic aws-sdk v2 is maintenance-mode — introducing it is a review finding.
  • Credentials come from the default provider chain — execution role in Lambda, OIDC/aws-actions in CI, profile/SSO locally. A hardcoded access key anywhere (code, spec, CDK context, committed .env) is a BLOCKER, no exceptions.
  • Secrets live in Secrets Manager or SSM Parameter Store, read through the config layer at runtime and cached at module scope. DON'T bake secrets into build artifacts or synth-time environment; DO grant each function GetSecretValue/GetParameter on its specific ARNs only.

IaC is the only infra path

  • CDK is the preferred tool (the grounded project: cdk bootstrap once per account/region, cdk synth as dry run, cdk deploy --all with stacks split by bounded concern — auth, API, frontend).
  • Console changes are drift and drift is a violation. Any fix discovered in the console is back-ported into stack code before the task is done.
  • Cross-stack values travel via stack outputs, never copy-pasted physical IDs.
  • Stack layout and environment contexts (-c env=<stage>) are documented in docs/ARCHITECTURE.md.

Lambda handler discipline (Node/NestJS)

  • One handler per API Gateway integration; handlers are stateless between invocations.
  • Cold-start aware bootstrap: create the Nest app / SDK clients / DB connections in module scope, cache the promise, await it inside the handler. Never rebuild per invocation; never assume the cache survives (warm-start optimization, not state).
  • Translate APIGatewayProxyEvent → domain input at the adapter boundary. Business logic never imports Lambda types.
  • DON'T schedule work after returning the response — the event loop freezes at return.

Event/queue consumers (SQS, SNS, EventBridge)

  • Idempotent consumers, always — at-least-once delivery is the contract. Dedupe on a persisted idempotency key; map the duplicate to a typed replay outcome, not an error.
  • Visibility timeout strictly greater than worst-case processing time (AWS guidance: ~6× the function timeout).
  • DLQ mandatory on every queue and event source mapping, with an alarm on DLQ depth ≥ 1.
  • Use partial batch failure reporting (ReportBatchItemFailures) so one poison message doesn't recycle the whole batch.

S3

  • Presigned URLs over proxying — clients upload/download directly; Lambda/API Gateway never streams file bytes (payload caps, duration cost).
  • BlockPublicAccess on every bucket; static assets served only via CloudFront OAC (the grounded pattern).
  • Retention/lifecycle rules declared in IaC for every bucket holding user or derived data.

IAM and multi-tenant orientation

  • Least-privilege per function: each Lambda gets its own role scoped to exact actions and resource ARNs. Wildcard resource where a scoped ARN is expressible is a review BLOCKER.
  • Tenant isolation is expressed in IAM — policy conditions (e.g. dynamodb:LeadingKeys), tenant-prefixed resource naming/key prefixes — never only in application code. Code-level filtering is the first line; IAM is the wall behind it.

Testing on this stack

  • Unit: aws-sdk-client-mock — mock at the v3 client/command level, assert the exact Command inputs sent. Never stub HTTP underneath the SDK.
  • Integration: LocalStack via Testcontainers — real S3/SQS/SNS/Lambda-adjacent behavior, same spirit as R-TESTI-01 in .claude/rules/TESTING_INTEGRATION.md. Never hit real cloud from tests.
  • Contract: handlers are tested through the API Gateway event shape — build APIGatewayProxyEvent fixtures (headers, path/query params, base64 body flags), assert the proxy result (statusCode, headers, stringified body).
  • Tests own their data and clean up (R-TESTI-04/05): fresh bucket/queue name per suite or purge in afterEach.
  • Idempotency ACs deliver the same message twice (R-TESTI-02 adapted) and assert exactly one side effect.

Spec validation checks

Stack-specific checks the spec validators delegate here:

CheckSeverity
Secrets or long-lived credentials appearing in spec or code (keys, tokens, connection strings)BLOCKER
Queue/event consumers without a declared idempotency strategyBLOCKER
Spec mandates infrastructure (queue, bucket, topic, table, schedule) with no IaC definitionBLOCKER
IAM grants with wildcard resource/action where a scoped ARN is expressibleBLOCKER
Storage (S3, logs, tables) without retention/lifecycle statedWARNING
Cost-amplifying resources (per-tenant stacks/functions/buckets) without explicit justificationWARNING
Missing DLQ/alarm strategy for async consumersWARNING
Tenant isolation asserted only in application code, not in IAM/resource namingWARNING

Live validation commands

R-VAL obligations for infrastructure/handler changes — exact invocations live in docs/DEV_SETUP.md; the rows below are the obligations:

CheckTypical shape
Synth must succeednpx cdk synth (clean exit, no unresolved context)
Diff reviewed before commitnpx cdk diff against the dev stage — read every resource change, especially IAM and deletions
Deploy to the dev stagecdk deploy target per docs/DEV_SETUP.md
Smoke with read-only CLIaws s3 ls, aws lambda get-function, aws apigateway get-rest-apis against the dev stage
Run integration tests (LocalStack/Testcontainers)affected test target per docs/DEV_SETUP.md

A synth that succeeds but a diff that was never read is a missed BLOCKER — IAM widening and resource replacement hide there. All rows must pass before commit per .claude/rules/LIVE_VALIDATION.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.