一键导入
construct-development
CDK construct development patterns, design principles, and type-driven development. Use when building or modifying AWS CDK constructs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
CDK construct development patterns, design principles, and type-driven development. Use when building or modifying AWS CDK constructs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | construct-development |
| description | CDK construct development patterns, design principles, and type-driven development. Use when building or modifying AWS CDK constructs. |
Use factory functions that return CDK resources:
import {Construct} from 'constructs';
import {RemovalPolicy} from 'aws-cdk-lib';
import {Bucket, BucketEncryption, BlockPublicAccess} from 'aws-cdk-lib/aws-s3';
export type BucketProps = {
bucketName: string;
env: {
name: string;
region: string;
account: string;
};
enableVersioning?: boolean;
};
export const createBucket = (scope: Construct, props: BucketProps): Bucket => {
return new Bucket(scope, `${props.bucketName}-bucket`, {
bucketName: `${props.bucketName}-${props.env.name}-${props.env.region}`,
enforceSSL: true,
encryption: BucketEncryption.S3_MANAGED,
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
removalPolicy: props.env.name === 'prod' ? RemovalPolicy.RETAIN : RemovalPolicy.DESTROY,
versioned: props.enableVersioning ?? props.env.name === 'prod',
});
};
RemovalPolicy.RETAIN in prod, DESTROY in dev// Performance Insights only in prod
performanceInsightRetention: props.env.name === 'prod' ? 7 : undefined,
// Reader instances only in prod
const createReaders = props.env.account === Account.PROD && props.enableReaders;
// Performance Insights only in prod
performanceInsightRetention: props.env.name === 'prod' ? 7 : undefined,
// Reader instances only in prod
const createReaders = props.env.account === Account.PROD && props.enableReaders;
Use types, not interfaces. This codebase follows type-driven development where we define all data structures using type declarations.
Define all props types in src/types/:
// src/types/bucket-types.ts
import {EnvironmentConfig} from '@cdk-constructs/cdk';
export type BucketProps = {
bucketName: string;
env: EnvironmentConfig['env'];
kmsKeyArn?: string;
lifecycleRules?: BucketLifecycleRule[];
};
export type BucketLifecycleRule = {
id: string;
expiration?: number;
transitions?: StorageTransition[];
};
Export all public APIs from src/index.ts:
// src/index.ts
// Constructs
export {createBucket} from './constructs/bucket';
export {createLambda} from './constructs/lambda';
// Types
export type {BucketProps, BucketLifecycleRule} from './types/bucket-types';
export type {LambdaProps} from './types/lambda-types';
// Enums
export {StorageClass} from './enums/storage';
// Utilities
export {getAbsoluteLambdaPath} from './util/paths';
All public functions, types, and enums should have JSDoc comments:
/**
* Creates a CodeArtifact domain.
*
* @param scope - The parent construct
* @param id - The construct ID
* @param props - The domain properties
* @returns The created CodeArtifact domain
*
* @public
*/
export const createCodeArtifactDomain = (scope: Construct, id: string, props: CodeArtifactDomainProps): CfnDomain => {
// ...
};
Patterns and standards for creating new AWS service subpackages in the monorepo. Use when adding new service packages like Lambda, DynamoDB, Step Functions, etc.
Build commands, build order, TypeScript configuration, and CDK deployment. Use when building packages, troubleshooting build issues, or deploying stacks.
JSDoc/TSDoc standards for documenting types, functions, and constructs. Use when writing or reviewing documentation.
Claude Code specific instructions for working with this CDK monorepo. General guidance on code generation, refactoring, and feature additions.
Step-by-step guides for common development tasks like adding constructs, creating packages, and using workspace packages. Use when performing routine development tasks.
Formatting and linting standards using GTS, ESLint, and Prettier. Use when writing or formatting TypeScript code in this project.