This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Run tests for affected projects:
yarn test - Run tests for all projects:
yarn test:all - Run a single test file:
npx vitest run path/to/test.spec.ts - Run tests in watch mode:
npx vitest watch - Run tests for specific project:
npx nx test @libs/cdk-utils - Run specific test file with Nx:
npx nx test @libs/cdk-utils -- path/to/test.spec.ts
- Lint affected projects:
yarn lint - Lint all projects:
yarn lint:all - Type check affected projects:
yarn typecheck - Type check all projects:
yarn typecheck:all
- Generate new service:
npx nx g service <service-name> - Generate notification service:
npx nx g service <service-name> notification - Deploy service to AWS:
npx nx deploy <service-name> -- -s <stage> --aws-profile <profile> - Remove service from AWS:
npx nx run <service-name>:remove -- -s <stage> --aws-profile <profile>
- Deploy all stacks:
cd applications/core && cdk deploy - Deploy staging stacks:
cd applications/core && cdk deploy stg/** - Deploy production stacks:
cd applications/core && cdk deploy prd/** - View CDK diff:
cd applications/core && cdk diff
- Generate typed API client:
npx nx g client <client-name>
This is an AWS microservices template using:
- Nx monorepo structure with services in
services/and libraries inlibs/ - AWS CDK v2 for infrastructure as code (recently migrated from Serverless Framework)
- TypeScript with strict type checking extending @aligent/ts-code-standards
- Node.js 22.14.0 runtime
-
Service-Based Architecture
- Each service is a separate CDK Stack defined in
services/<service-name>/src/index.ts - Services export a Stack class that extends
aws-cdk-lib.Stack - Services are imported and instantiated in
ApplicationStageinsideapplications/core/bin/main.ts
- Each service is a separate CDK Stack defined in
-
CDK Application Structure
- Entry point:
applications/core/bin/main.tscreates CDK App and stages - Stages (dev/stg/prd) are created as ApplicationStage instances directly in
main.ts - Stage-specific configuration is applied via property injectors and aspects
- Each stage automatically configures resources based on deployment environment
- Entry point:
-
Lambda and Step Functions
- Lambda functions are in
services/<service>/src/lambda/ - Step Functions use YAML definitions in
services/<service>/src/step-functions/ - Shared constructs in
services/<service>/src/lib/constructs/ - Step Functions use JSONata for output transformations
- Automatic versioning and aliasing applied via VersionFunctionsAspect
- Stage-specific configuration applied via property injectors
- Lambda functions are in
-
Property Injection Architecture
- Configuration-based defaults applied via property injectors:
- NodeJsFunctionDefaultsInjector: Bundling configuration (sourceMap, esm, minify)
- LogGroupDefaultsInjector: Duration-based retention (SHORT/MEDIUM/LONG)
- StepFunctionDefaultsInjector: Automatic logging for EXPRESS workflows
- BucketDefaultsInjector: Auto-cleanup policies for S3 buckets
- Cross-cutting concerns handled by aspects (VersionFunctionsAspect for automatic versioning)
- Configuration can be customized per stage or globally
- Uses CDK's built-in property injection system - no custom constructs needed
- Configuration-based defaults applied via property injectors:
-
CDK Constructs and Utilities
- S3Bucket: Lifecycle management with duration-based rules (SHORT/MEDIUM/LONG/PERMANENT)
- SsmParameterGroup: Abstract class for grouping and managing SSM parameters
- StepFunctionFromFile: Load Step Function definitions from YAML/JSON files
-
Testing Strategy
- Vitest for unit testing with coverage reports
- Test files colocated with source files as
*.spec.tsor*.test.ts - Workspace-level Vitest configuration in
vitest.workspace.ts
- Project migrated from Serverless Framework to CDK using property injection pattern
- CDK construct IDs are critical - changing them will replace resources
- Lambda versions and aliases are automatically created via VersionFunctionsAspect
- Step Functions use
LambdaInvokeresource with automatic retry blocks - Task outputs are nested in
Payloadproperty - use JSONata to transform - Stage-specific resource configuration handled by property injectors
- Update brand name in
nx.jsongenerators section before first use - Package name in
package.jsonshould follow@<brand>-int/integrationsformat - Services are tagged with STAGE and SERVICE tags automatically
- Always run lint and type checks before committing
- Use Nx affected commands to optimize CI/CD performance
- Follow existing code patterns and conventions in the codebase
- Check
CDK-MIGRATION-NOTES.mdfor CDK-specific guidance
The docs/ai-helpers/ folder contains documentation templates to assist AI code assistants in creating consistent and comprehensive documentation:
When using Claude Code or other MCP-compatible tools, the following MCP servers are recommended for this repository:
- context7: Provides up-to-date documentation for libraries and frameworks
- eslint: Enables linting capabilities for code quality checks
- nx: Offers Nx-specific commands and workspace insights
These servers should be used when available to enhance development capabilities.
-
APPLICATION_ARCHITECTURE_FORMAT.md: Template for creating comprehensive architecture diagrams for AWS CDK services- Provides guidelines for analyzing CDK application structure
- Includes Mermaid diagram formats with consistent color palettes
- Shows how to map Step Function workflows and Lambda functions
- Contains common architectural patterns and best practices
-
SERVICE_README_FORMAT.md: Template for creating service-specific README documentation- Standardized format for service documentation
- Context diagram template showing external system interactions
- Sections for workflows, critical information, and operational details
- Consistent color palette for system visualization
Reference these templates when:
- Creating new architecture documentation (
ARCHITECTURE.md) - Documenting a new service with a README
- Updating existing service documentation
- Generating visual representations of service interactions
- Ensuring consistency across all service documentation