cdk-patterns
Build AWS CDK Infrastructure Patterns
Design production-ready AWS infrastructure using CDK constructs. Apply proven patterns for serverless APIs, containers, and data pipelines with reusable L2/L3 constructs.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "cdk-patterns". Create a serverless API with Lambda and DynamoDB
Expected outcome:
Generates a complete CDK construct with API Gateway integration, Lambda function with proper runtime configuration, DynamoDB table with on-demand billing, IAM permissions using grantReadWriteData, and X-Ray tracing enabled for observability.
Using "cdk-patterns". Review my CDK stack for best practices
Expected outcome:
Provides specific recommendations: replace CfnFunction with lambda.Function L2 construct, add RemovalPolicy.RETAIN for stateful resources, implement least privilege IAM using table.grantReadWriteData instead of inline policies, and add cdk.Tags for resource organization.
Security Audit
SafeAll static analysis findings are false positives. The 'Dynamic function constructor' at line 53 is actually a CDK Lambda construct (new lambda.Function). The 'Ruby/shell backtick execution' detections are markdown code block delimiters (```typescript), not shell commands. The 'Weak cryptographic algorithm' findings reference description text, not actual crypto code. This skill contains only documentation and example CDK TypeScript code with no executable security risks.
Quality Score
What You Can Build
Serverless API Development
Build production-ready serverless APIs using API Gateway, Lambda, and DynamoDB with proper IAM permissions and monitoring enabled.
Reusable Infrastructure Constructs
Create organization-standard L3 constructs that encode best practices for consistent infrastructure deployments across teams.
CDK Code Review and Optimization
Review existing CDK code for anti-patterns, security issues, and opportunities to use higher-level constructs.
Try These Prompts
Create a CDK stack in TypeScript that deploys a Lambda function with an S3 bucket. Use L2 constructs, apply removal policies, and enable X-Ray tracing.
Generate a reusable CDK construct for a serverless API with API Gateway, Lambda, and DynamoDB. Include proper IAM permissions, environment variables, and CloudWatch alarms.
Design a multi-stack CDK application separating stateful resources (RDS, S3) from stateless compute (Lambda, ECS). Show how to pass references between stacks.
Review this CDK stack for security anti-patterns, IAM over-permissions, and opportunities to use L2 constructs instead of L1. Suggest specific improvements.
Best Practices
- Use L2 constructs over L1 (Cfn*) constructs for safer defaults and less boilerplate code
- Separate stateful resources (databases, buckets) from stateless compute into different stacks for independent lifecycle management
- Apply the principle of least privilege to all IAM roles using grant methods instead of broad inline policies
Avoid
- Using L1 (Cfn*) constructs when L2 alternatives exist, resulting in more code and weaker safety guarantees
- Hardcoding account IDs or regions instead of using cdk.Aws.ACCOUNT_ID and cdk.Aws.REGION for portability
- Deploying stateful and stateless resources in the same stack, coupling their lifecycles unnecessarily