|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +This is an Nx-based monorepo containing AWS CDK v2 construct packages. Each package provides reusable infrastructure components for common AWS patterns. |
| 8 | + |
| 9 | +## Key Commands |
| 10 | + |
| 11 | +### Development |
| 12 | +```bash |
| 13 | +# Install dependencies |
| 14 | +npm ci |
| 15 | + |
| 16 | +# Build a specific package |
| 17 | +yarn nx build <package-name> |
| 18 | + |
| 19 | +# Run tests for a package |
| 20 | +yarn nx test <package-name> |
| 21 | + |
| 22 | +# Lint a package |
| 23 | +yarn nx lint <package-name> |
| 24 | + |
| 25 | +# Run a single test file |
| 26 | +yarn nx test <package-name> --testFile=<test-file-name> |
| 27 | +``` |
| 28 | + |
| 29 | +### Local Testing |
| 30 | +```bash |
| 31 | +# After building, pack the package |
| 32 | +cd dist/<package-name> && npm pack |
| 33 | + |
| 34 | +# Install in your target project |
| 35 | +npm i <path-to-tarball> |
| 36 | +``` |
| 37 | + |
| 38 | +### Publishing |
| 39 | +```bash |
| 40 | +# Publish with version and tag |
| 41 | +yarn nx publish <package-name> --ver=<version> --tag=<tag> |
| 42 | +``` |
| 43 | + |
| 44 | +## Architecture |
| 45 | + |
| 46 | +### Package Structure |
| 47 | +All packages follow this pattern: |
| 48 | +``` |
| 49 | +packages/<package-name>/ |
| 50 | +├── src/ |
| 51 | +│ ├── index.ts # Main exports |
| 52 | +│ └── lib/ |
| 53 | +│ ├── <construct>.ts # Main CDK construct |
| 54 | +│ └── handlers/ # Lambda function code |
| 55 | +├── package.json |
| 56 | +├── project.json # Nx configuration |
| 57 | +├── tsconfig.json |
| 58 | +├── jest.config.ts |
| 59 | +└── README.md |
| 60 | +``` |
| 61 | + |
| 62 | +### Construct Pattern |
| 63 | +Each package exports CDK Constructs that: |
| 64 | +- Extend the base `Construct` class from AWS CDK |
| 65 | +- Accept a typed props interface (e.g., `StaticHostingProps`) |
| 66 | +- Create and configure AWS resources |
| 67 | +- May include Lambda functions bundled with esbuild |
| 68 | + |
| 69 | +### Key Architectural Decisions |
| 70 | +1. **Independent Packages**: Each construct is independently versioned and can be used standalone |
| 71 | +2. **Lambda Bundling**: Uses `@aligent/cdk-esbuild` for efficient Lambda deployment |
| 72 | +3. **Peer Dependencies**: All packages require `aws-cdk-lib` and `constructs` as peer dependencies |
| 73 | +4. **TypeScript**: Entire codebase uses TypeScript with strict mode enabled |
| 74 | + |
| 75 | +### Package Dependencies |
| 76 | +- Packages can compose together (e.g., WAF + CloudFront) |
| 77 | +- Lambda functions use AWS SDK v3 clients |
| 78 | +- Build process uses Nx task orchestration with dependency graph |
| 79 | + |
| 80 | +## Testing Approach |
| 81 | +- Jest with ts-jest for all packages |
| 82 | +- 80% code coverage threshold |
| 83 | +- Mock AWS services in tests |
| 84 | +- Test files follow `*.test.ts` pattern |
| 85 | + |
| 86 | +## Code Quality and Git Workflow |
| 87 | + |
| 88 | +### Pre-commit Requirements |
| 89 | +**ALWAYS run linting before pushing code to git:** |
| 90 | +```bash |
| 91 | +# Run lint check for the package being modified |
| 92 | +yarn nx lint <package-name> |
| 93 | + |
| 94 | +# Fix any linting issues automatically when possible |
| 95 | +yarn nx lint <package-name> --fix |
| 96 | +``` |
| 97 | + |
| 98 | +### Git Commit Process |
| 99 | +1. Make code changes |
| 100 | +2. **MANDATORY**: Run `yarn nx lint <package-name>` to check for linting issues |
| 101 | +3. Fix any linting errors or warnings |
| 102 | +4. Stage changes with `git add` |
| 103 | +5. Commit with descriptive message |
| 104 | +6. Push to remote |
| 105 | + |
| 106 | +**Never push code that fails linting checks** - this will cause GitHub Actions to fail and block the PR. |
0 commit comments