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.

31,392 stars
Complexity: medium

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

$curl -o ~/.claude/skills/cdk-patterns/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/cdk-patterns/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/cdk-patterns/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How cdk-patterns Compares

Feature / Agentcdk-patternsStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/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

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

31392
from sickn33/antigravity-awesome-skills

Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.

Code GenerationClaude

new-rails-project

31392
from sickn33/antigravity-awesome-skills

Create a new Rails project

Code GenerationClaude

makepad-widgets

31392
from sickn33/antigravity-awesome-skills

Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > > Check for updates: https://crates.io/crates/makepad-widgets

Code GenerationClaude

makepad-splash

31392
from sickn33/antigravity-awesome-skills

CRITICAL: Use for Makepad Splash scripting language. Triggers on: splash language, makepad script, makepad scripting, script!, cx.eval, makepad dynamic, makepad AI, splash 语言, makepad 脚本

Code GenerationClaude

makepad-dsl

31392
from sickn33/antigravity-awesome-skills

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 组件

Code GenerationClaude

javascript-typescript-typescript-scaffold

31392
from sickn33/antigravity-awesome-skills

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

Code GenerationClaude

frontend-ui-dark-ts

31392
from sickn33/antigravity-awesome-skills

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.

Code GenerationClaude

frontend-mobile-development-component-scaffold

31392
from sickn33/antigravity-awesome-skills

You are a React component architecture expert specializing in scaffolding production-ready, accessible, and performant components. Generate complete component implementations with TypeScript, tests, s

Code GenerationClaude

frontend-dev-guidelines

31392
from sickn33/antigravity-awesome-skills

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.

Code GenerationClaude

fp-backend

31392
from sickn33/antigravity-awesome-skills

Functional programming patterns for Node.js/Deno backend development using fp-ts, ReaderTaskEither, and functional dependency injection

Code GenerationClaudeChatGPTGemini

fastapi-templates

31392
from sickn33/antigravity-awesome-skills

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.

Code GenerationClaude

fastapi-router-py

31392
from sickn33/antigravity-awesome-skills

Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes.

Code GenerationClaude