Back to Skills

construct-development

majiayu000
Updated Today
1 views
58
9
58
View on GitHub
Metadesign

About

This skill provides AWS CDK construct development patterns and type-driven design principles for building or modifying CDK constructs. It includes practical examples like factory functions that return CDK resources with proper configuration patterns. Use it when creating reusable infrastructure components to follow AWS CDK best practices.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/majiayu000/claude-skill-registry
Git CloneAlternative
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/construct-development

Copy and paste this command in Claude Code to install this skill

Documentation

Construct Development Guidelines

Construct Pattern

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',
    });
};

Design Principles

1. Secure by Default

  • Enable encryption (S3_MANAGED or KMS)
  • Enforce SSL
  • Block public access
  • Use private subnets

2. Environment-Aware

  • Gate expensive features to production
  • Use RemovalPolicy.RETAIN in prod, DESTROY in dev
  • Enable enhanced monitoring only where needed
// 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;

3. Cost-Efficient

// 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;

4. Observable

  • Include CloudWatch log groups
  • Set appropriate retention periods
  • Enable metrics where applicable

Type-Driven Development

Use types, not interfaces. This codebase follows type-driven development where we define all data structures using type declarations.

Why Types Over Interfaces?

  • More flexible for unions and intersections
  • Consistent pattern across the codebase
  • Better for functional programming patterns
  • Clearer intent for data structures

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 Pattern

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';

JSDoc Requirements

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 => {
    // ...
};

GitHub Repository

majiayu000/claude-skill-registry
Path: skills/construct-development

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

creating-opencode-plugins

Meta

This skill provides the structure and API specifications for creating OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It offers implementation patterns for JavaScript/TypeScript modules that intercept and extend the AI assistant's lifecycle. Use it when you need to build event-driven plugins for monitoring, custom handling, or extending OpenCode's capabilities.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

Algorithmic Art Generation

Meta

This skill helps developers create algorithmic art using p5.js, focusing on generative art, computational aesthetics, and interactive visualizations. It automatically activates for topics like "generative art" or "p5.js visualization" and guides you through creating unique algorithms with features like seeded randomness, flow fields, and particle systems. Use it when you need to build reproducible, code-driven artistic patterns.

View skill