Skip to content

Commit 2811386

Browse files
Upgrade: [dependabot] - sync Copilot instructions (#26)
Syncing Copilot instructions from central repo. Ref: `main` Co-authored-by: eps-create-pull-request[bot] <270920461+eps-create-pull-request[bot]@users.noreply.github.com>
1 parent f42badd commit 2811386

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

.github/instructions/languages/cdk.instructions.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@ This file provides instructions for generating, reviewing, and maintaining AWS C
2323
- Suppress warnings with `nagSuppressions.ts` only when justified and documented
2424
- Use `bin/` for entrypoint apps, `constructs/` for reusable components, and `stacks/` for stack definitions
2525
- Prefer `props` interfaces for construct configuration
26+
- For Step Functions definitions, prefer a chain-centric style where states are defined inline within `Chain.start(...).next(...)` so the execution flow reads top-to-bottom in one place. Avoid mixing a chain with many separately declared state `const`s; instead embed calls to helper functions directly in the chain when needed.
27+
- For Step Functions chain formatting, place `.start`, `.next`, `.when`, and `.otherwise` on their own lines, and give helper calls such as `.jsonata(...)` the same line-break weight so nested flow blocks are visually aligned and easy to scan.
28+
- For construct props that group resources (for example lambda functions or state machines), prefer explicit named object shapes (e.g. `{status: TypescriptLambdaFunction}`) over generic index signatures or broad maps so consumers are strongly typed to only the supported resources.
29+
- For construct props that consume grouped resources, prefer inline explicit object shapes in the props contract (for example `functions: { status: TypescriptLambdaFunction }`) over `Pick<...>` or generic map types.
30+
31+
### Good Example - Inline Explicit Shape
32+
33+
```typescript
34+
interface ApisProps {
35+
readonly functions: {
36+
readonly status: TypescriptLambdaFunction
37+
}
38+
readonly stateMachines: {
39+
readonly getMyPrescriptions: ExpressStateMachine
40+
}
41+
}
42+
```
43+
44+
### Bad Example - Hidden Contract via Pick
45+
46+
```typescript
47+
interface ApisProps {
48+
readonly functions: Pick<FunctionResources, "status" | "capabilityStatement">
49+
}
50+
```
51+
52+
### Bad Example - Generic Map
53+
54+
```typescript
55+
interface ApisProps {
56+
functions: {[key: string]: TypescriptLambdaFunction}
57+
stateMachines: {[key: string]: ExpressStateMachine}
58+
}
59+
```
2660

2761
## Code Standards
2862

@@ -33,6 +67,7 @@ This file provides instructions for generating, reviewing, and maintaining AWS C
3367
- Variables: camelCase
3468
- Stacks: Suffix with `Stack` (e.g., `CptsApiAppStack`)
3569
- Entry points: Suffix with `App` (e.g., `CptsApiApp.ts`)
70+
- CDK app entry points must follow `<app acronym><Api|Ui>[Sandbox]App` naming (e.g., `PsuApiApp`, `PsuApiSandboxApp`)
3671

3772
### File Organization
3873

@@ -88,11 +123,26 @@ export class CptsApiAppStack extends Stack {
88123
- Prefer VPC endpoints for private connectivity
89124
- Minimize resource creation in test environments
90125

126+
## Unit Testing
127+
128+
- Write unit tests for CDK stacks and constructs using synthesis-based assertions.
129+
- Prefer in-process tests that instantiate CDK `App` and `Stack` objects directly and assert on synthesized templates.
130+
- Keep assertions light-touch and stable, such as resource counts and a small number of important properties.
131+
- Avoid mocking AWS resources or writing tests that attempt to exercise live AWS behaviour.
132+
- CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo.
133+
- Do not test AWS implementation details owned by the CDK library. Test the resources and properties your code is responsible for declaring.
134+
135+
### Recommended Test Styles
136+
137+
- Smoke tests for `bin/` files: execute the entrypoint and assert that synthesis completes without throwing.
138+
- In-process synth tests for stacks and constructs: instantiate the stack directly and assert resource counts or key CloudFormation properties with `Template.fromStack(...)`.
139+
91140

92141
## Validation and Verification
93142

94143
- Build: `make cdk-synth`
95144
- Lint: `npm run lint --workspace packages/cdk`
145+
- Test: `npm test --workspace packages/cdk`
96146

97147
## Maintenance
98148

.github/instructions/languages/typescript.instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This document provides instructions for generating, reviewing, and maintaining T
2323
- Use destructuring for objects and arrays to improve readability.
2424
- Avoid magic numbers and hardcoded values; use named constants.
2525
- Keep functions pure and side-effect free when possible.
26+
- Do not use the `void` operator to silence unused-value warnings; prefer code that makes usage explicit.
2627

2728
## Code Standards
2829

@@ -92,6 +93,7 @@ This document provides instructions for generating, reviewing, and maintaining T
9293
### Type Safety
9394

9495
- Prefer interfaces and types. You MUST NOT use `any`.
96+
- Prefer `Array<T>` over `T[]` for array type annotations.
9597
- Use type guards and assertions when necessary.
9698
- Example:
9799

0 commit comments

Comments
 (0)