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
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- flow-adoptionSkill
- flow-legacy-migrationSkill
- stack-azureSkill
- stack-design-systemSkill
- stack-gcpSkill
- stack-javaSkill
- stack-kafkaSkill
- stack-mongodbSkill
- stack-natsSkill
- stack-nestjsSkill
- stack-nextjs-reactSkill
- stack-nxSkill
- stack-playwrightSkill
- stack-postgresqlSkill
- stack-quarkusSkill
- stack-react-nativeSkill
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
- Distinctive: line 35
Cold-start aware bootstrap: create the Nest app / SDK clients / DB connections in module scope, cache the promise, await it inside the …
- Distinctive: line 37
DON'T schedule work after returning the response — the event loop freezes at return.
- Very specific: line 43
Use partial batch failure reporting (ReportBatchItemFailures) so one poison message doesn't recycle the whole batch.
≈ “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.
Files
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 stackslistsaws- Dependencies: any
@aws-sdk/*(v3 modular clients),aws-cdk-lib/aws-cdk - Files:
cdk.json,serverless.ymlwithprovider: aws, SAM templates (AWS::Serverlesstransform), Terraform files declaring theawsprovider - 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 monolithicaws-sdkv2 is maintenance-mode — introducing it is a review finding. - Credentials come from the default provider chain — execution role in Lambda, OIDC/
aws-actionsin 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/GetParameteron its specific ARNs only.
IaC is the only infra path
- CDK is the preferred tool (the grounded project:
cdk bootstraponce per account/region,cdk synthas dry run,cdk deploy --allwith 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 indocs/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).
BlockPublicAccesson 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
APIGatewayProxyEventfixtures (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:
| Check | Severity |
| Secrets or long-lived credentials appearing in spec or code (keys, tokens, connection strings) | BLOCKER |
| Queue/event consumers without a declared idempotency strategy | BLOCKER |
| Spec mandates infrastructure (queue, bucket, topic, table, schedule) with no IaC definition | BLOCKER |
| IAM grants with wildcard resource/action where a scoped ARN is expressible | BLOCKER |
| Storage (S3, logs, tables) without retention/lifecycle stated | WARNING |
| Cost-amplifying resources (per-tenant stacks/functions/buckets) without explicit justification | WARNING |
| Missing DLQ/alarm strategy for async consumers | WARNING |
| Tenant isolation asserted only in application code, not in IAM/resource naming | WARNING |
Live validation commands
R-VAL obligations for infrastructure/handler changes — exact invocations live in docs/DEV_SETUP.md; the rows below are the obligations:
| Check | Typical shape |
| Synth must succeed | npx cdk synth (clean exit, no unresolved context) |
| Diff reviewed before commit | npx cdk diff against the dev stage — read every resource change, especially IAM and deletions |
| Deploy to the dev stage | cdk deploy target per docs/DEV_SETUP.md |
| Smoke with read-only CLI | aws 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.
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
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.

