You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+76-87Lines changed: 76 additions & 87 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,126 +4,115 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Repository Overview
6
6
7
-
This is an Nx-based monorepo containing AWS CDK v2 construct packages. Each package provides reusable infrastructure components for common AWS patterns.
7
+
Nx-based monorepo of independently versioned AWS CDK v2 construct packages published under the `@aligent/cdk-*` scope. Yarn 4 (Berry) workspaces, managed via Corepack. Node version is pinned in `.nvmrc` (currently v22.14.0).
8
+
9
+
Workspaces:
10
+
-`packages/constructs/*` — one CDK construct per directory (e.g. `static-hosting`, `waf`, `prerender-fargate`)
11
+
-`packages/cdk-aspects` — shared CDK aspects
8
12
9
13
## Key Commands
10
14
11
-
### Development
15
+
### Setup and development
12
16
```bash
13
-
# Install dependencies
14
-
npm ci
17
+
# Install dependencies (matches CI)
18
+
yarn install --frozen-lockfile
15
19
16
-
# Build a specific package
20
+
# Build / test / lint a single package (use the project name from project.json, not the npm name)
# then in the target project: npm i <path-to-tarball>
42
49
```
43
50
44
-
## Architecture
51
+
### Releases (Changesets)
52
+
This repo uses [Changesets](https://github.com/changesets/changesets); each package has an independent release cycle. Manual `npm publish` / `nx publish` is **not** the normal flow.
45
53
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
-
```
54
+
Every PR that modifies a published package must include a changeset file in `.changeset/`. On merge to `main`, the `changeset-release` workflow opens/updates a "Release: Version Packages" PR; merging that PR publishes to npm and creates GitHub releases.
61
55
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
56
+
**Before writing a changeset, confirm with the user:**
57
+
- which package(s) are affected
58
+
- the bump type (`patch` for bug fixes / non-breaking tweaks, `minor` for backwards-compatible features, `major` for breaking changes)
59
+
- the description
85
60
86
-
## Code Quality and Git Workflow
61
+
Then either run `yarn changeset` (interactive) or create `.changeset/<descriptive-slug>.md` directly:
87
62
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>
63
+
```markdown
64
+
---
65
+
"@aligent/<package-name>": patch | minor | major
66
+
---
93
67
94
-
# Fix any linting issues automatically when possible
95
-
yarn nx lint <package-name> --fix
68
+
Short description of the change.
96
69
```
97
70
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
71
+
Useful commands:
72
+
```bash
73
+
yarn changeset:status # see pending changesets
74
+
yarn affected:packages # list affected @aligent/cdk-* packages — handy when picking targets
75
+
```
105
76
106
-
**Never push code that fails linting checks** - this will cause GitHub Actions to fail and block the PR.
77
+
## Architecture
107
78
108
-
### Changesets
79
+
### Package layout
80
+
```
81
+
packages/constructs/<name>/
82
+
├── index.ts # main exports
83
+
├── lib/
84
+
│ ├── <construct>.ts # CDK construct(s)
85
+
│ └── handlers/ # Lambda source (excluded from tsc build; bundled via esbuild at synth time)
After `nx build`, compiled `index.js` / `index.d.ts` (and `lib/*.js`) sit next to the sources — that is what gets published.
109
93
110
-
This repo uses [Changesets](https://github.com/changesets/changesets) for versioning. Every PR that modifies a package must include a changeset file in `.changeset/`.
94
+
### Construct pattern
95
+
Each package exports CDK Constructs that extend `Construct`, accept a typed props interface, and create AWS resources. Lambda handlers under `lib/handlers/` are excluded from the package's `tsc` build and are bundled via `@aligent/cdk-esbuild` during CDK synth (using AWS SDK v3 clients).
111
96
112
-
Before writing a changeset, confirm with the user:
113
-
-which package(s) are affected
114
-
- the bump type (`patch`, `minor`, or `major`)
115
-
- the description
97
+
### Cross-package rules
98
+
-`aws-cdk-lib` and `constructs`are **peer** dependencies in every package — do not add them as regular `dependencies`.
99
+
-ESLint enforces Nx module boundaries; the only cross-package import explicitly allowed is `@aligent/cdk-esbuild` (see `.eslintrc.json`). New cross-package coupling needs an explicit allowlist entry.
100
+
-`constructs` is pinned via a workspace-level `resolutions` entry in the root `package.json`.
116
101
117
-
Then create `.changeset/<descriptive-slug>.md`:
102
+
## Testing
103
+
- Jest + ts-jest, `*.test.ts` pattern, 80% coverage threshold per package.
104
+
- Mock AWS SDK calls (e.g. `aws-sdk-client-mock`); do not hit real AWS.
118
105
119
-
```markdown
120
-
---
121
-
"@aligent/<package-name>": patch | minor | major
122
-
---
106
+
## Code Quality and Git Workflow
123
107
124
-
Short description of the change.
108
+
### Pre-commit
109
+
Always lint the affected package before pushing — CI runs `nx affected:lint` and will block the PR otherwise:
110
+
```bash
111
+
yarn nx lint <package-name>
112
+
yarn nx lint <package-name> --fix # auto-fix where possible
125
113
```
126
114
127
-
-`patch` — bug fixes, non-breaking tweaks
128
-
-`minor` — new backwards-compatible features
129
-
-`major` — breaking changes
115
+
### PRs
116
+
- One logical change per PR.
117
+
- Include a changeset for any user-visible change to a published package (see [Releases (Changesets)](#releases-changesets) above).
118
+
- The `check-readme` workflow flags missing README updates — keep the package README in sync with functional changes.
0 commit comments