cdk-patterns
Common AWS CDK patterns and constructs for building cloud infrastructure with TypeScript, Python, or Java. Use when designing reusable CDK stacks and L3 constructs.
About this skill
This skill positions the AI as an expert in AWS Cloud Development Kit (CDK), specializing in reusable patterns, L2/L3 constructs, and production-grade infrastructure stacks. It provides access to common AWS CDK patterns and constructs for building robust and scalable cloud infrastructure using TypeScript, Python, or Java. The skill is designed to assist in creating reusable CDK stacks, L3 constructs, implementing common infrastructure patterns (like serverless APIs, ECS services, or static sites), and reviewing existing CDK code for best practices and anti-patterns.
Best use case
Designing and implementing reusable cloud infrastructure using AWS CDK, developing multi-stack applications, and ensuring adherence to best practices in CDK code development across TypeScript, Python, or Java.
Common AWS CDK patterns and constructs for building cloud infrastructure with TypeScript, Python, or Java. Use when designing reusable CDK stacks and L3 constructs.
Well-architected, reusable, and production-ready AWS CDK code, patterns, or architectural guidance tailored to specified requirements, leveraging best practices for cloud infrastructure development.
Practical example
Example input
I need a CDK construct for a serverless API using TypeScript. It should include an API Gateway, a Lambda function, and a DynamoDB table. The Lambda needs permission to interact with the DynamoDB table, and the table should have a primary key 'id' of type string.
Example output
```typescript
import { Construct } from 'constructs';
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as path from 'path';
export class ServerlessApiConstruct extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
// DynamoDB Table
const table = new dynamodb.Table(this, 'MyApiTable', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
removalPolicy: cdk.RemovalPolicy.DESTROY // For development, consider RETAIN for production
});
// Lambda Function
const apiLambda = new lambda.Function(this, 'MyApiHandler', {
runtime: lambda.Runtime.NODEJS_20_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')), // Assumes 'lambda-handler' directory contains index.ts
environment: {
TABLE_NAME: table.tableName,
},
});
// Grant Lambda permissions to read/write from DynamoDB table
table.grantReadWriteData(apiLambda);
// API Gateway
const api = new apigw.RestApi(this, 'MyRestApi', {
restApiName: 'My Serverless API',
description: 'A serverless API with Lambda and DynamoDB.',
deployOptions: {
stageName: 'dev',
},
});
const apiIntegration = new apigw.LambdaIntegration(apiLambda);
// Example: Add a GET method to the root path
api.root.addMethod('GET', apiIntegration);
new CfnOutput(this, 'ApiEndpoint', {
value: api.url,
description: 'The endpoint URL for the API Gateway.'
});
}
}
```
_Note: This is a simplified example. The actual `lambda-handler/index.ts` code and a full CDK Stack definition would also be generated._When to use this skill
- Building reusable CDK constructs or patterns
- Designing multi-stack CDK applications
- Implementing common infrastructure patterns (e.g., API + Lambda + DynamoDB, ECS services, static sites)
- Reviewing CDK code for best practices and anti-patterns
When not to use this skill
- The user needs raw CloudFormation templates without CDK abstraction
- The task involves Terraform or other infrastructure-as-code frameworks (e.g., Pulumi, Ansible)
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cdk-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How cdk-patterns Compares
| Feature / Agent | cdk-patterns | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | medium | N/A |
Frequently Asked Questions
What does this skill do?
Common AWS CDK patterns and constructs for building cloud infrastructure with TypeScript, Python, or Java. Use when designing reusable CDK stacks and L3 constructs.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as medium. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
You are an expert in AWS Cloud Development Kit (CDK) specializing in reusable patterns, L2/L3 constructs, and production-grade infrastructure stacks.
## Use this skill when
- Building reusable CDK constructs or patterns
- Designing multi-stack CDK applications
- Implementing common infrastructure patterns (API + Lambda + DynamoDB, ECS services, static sites)
- Reviewing CDK code for best practices and anti-patterns
## Do not use this skill when
- The user needs raw CloudFormation templates without CDK
- The task is Terraform-specific
- Simple one-off CLI resource creation is sufficient
## Instructions
1. Identify the infrastructure pattern needed (e.g., serverless API, container service, data pipeline).
2. Use L2 constructs over L1 (Cfn*) constructs whenever possible for safer defaults.
3. Apply the principle of least privilege for all IAM roles and policies.
4. Use `RemovalPolicy` and `Tags` appropriately for production readiness.
5. Structure stacks for reusability: separate stateful (databases, buckets) from stateless (compute, APIs).
6. Enable monitoring by default (CloudWatch alarms, X-Ray tracing).
## Examples
### Example 1: Serverless API Pattern
```typescript
import { Construct } from "constructs";
import * as apigateway from "aws-cdk-lib/aws-apigateway";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
export class ServerlessApiPattern extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
const table = new dynamodb.Table(this, "Table", {
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
removalPolicy: cdk.RemovalPolicy.RETAIN,
});
const handler = new lambda.Function(this, "Handler", {
runtime: lambda.Runtime.NODEJS_20_X,
handler: "index.handler",
code: lambda.Code.fromAsset("lambda"),
environment: { TABLE_NAME: table.tableName },
tracing: lambda.Tracing.ACTIVE,
});
table.grantReadWriteData(handler);
new apigateway.LambdaRestApi(this, "Api", { handler });
}
}
```
## Best Practices
- ✅ **Do:** Use `cdk.Tags.of(this).add()` for consistent tagging
- ✅ **Do:** Separate stateful and stateless resources into different stacks
- ✅ **Do:** Use `cdk diff` before every deploy
- ❌ **Don't:** Use L1 (`Cfn*`) constructs when L2 alternatives exist
- ❌ **Don't:** Hardcode account IDs or regions — use `cdk.Aws.ACCOUNT_ID`
## Troubleshooting
**Problem:** Circular dependency between stacks
**Solution:** Extract shared resources into a dedicated base stack and pass references via constructor props.Related Skills
cc-skill-frontend-patterns
Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.
new-rails-project
Create a new Rails project
makepad-widgets
Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > > Check for updates: https://crates.io/crates/makepad-widgets
makepad-splash
CRITICAL: Use for Makepad Splash scripting language. Triggers on: splash language, makepad script, makepad scripting, script!, cx.eval, makepad dynamic, makepad AI, splash 语言, makepad 脚本
makepad-dsl
CRITICAL: Use for Makepad DSL syntax and inheritance. Triggers on: makepad dsl, live_design, makepad inheritance, makepad prototype, "<Widget>", "Foo = { }", makepad object, makepad property, makepad DSL 语法, makepad 继承, makepad 原型, 如何定义 makepad 组件
javascript-typescript-typescript-scaffold
You are a TypeScript project architecture expert specializing in scaffolding production-ready Node.js and frontend applications. Generate complete project structures with modern tooling (pnpm, Vite, N
frontend-ui-dark-ts
A modern dark-themed React UI system using Tailwind CSS and Framer Motion. Designed for dashboards, admin panels, and data-rich applications with glassmorphism effects and tasteful animations.
frontend-mobile-development-component-scaffold
You are a React component architecture expert specializing in scaffolding production-ready, accessible, and performant components. Generate complete component implementations with TypeScript, tests, s
frontend-dev-guidelines
You are a senior frontend engineer operating under strict architectural and performance standards. Use when creating components or pages, adding new features, or fetching or mutating data.
fp-backend
Functional programming patterns for Node.js/Deno backend development using fp-ts, ReaderTaskEither, and functional dependency injection
fastapi-templates
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
fastapi-router-py
Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes.