Skip to content

chore: add agent-facing design guidelines#37565

Open
alvazjor wants to merge 1 commit intomainfrom
feat/agent-facing-doc
Open

chore: add agent-facing design guidelines#37565
alvazjor wants to merge 1 commit intomainfrom
feat/agent-facing-doc

Conversation

@alvazjor
Copy link
Copy Markdown
Contributor

@alvazjor alvazjor commented Apr 9, 2026

Issue # (if applicable)

NA

Reason for this change

We're adding structured guidelines for AI agents contributing to the CDK codebase. Right now there's no single reference that tells an agent how to write constructs, follow naming conventions, or avoid common mistakes — this fills that gap.

Description of changes

Three new markdown files that give AI agents (and humans) a practical reference for CDK contribution:

  • AGENTS.md — Main entry point. Quick reference commands, coding patterns, props design, testing conventions, PR format, and anti-patterns.
  • docs/AGENTS_CONSTRUCT_DESIGN.md — Design decisions: feature placement (mixins vs facades vs traits), API shape, interfaces, type hierarchy, naming, and type design principles.
  • docs/AGENTS_CONSTRUCT_IMPLEMENTATION.md — Implementation details: grants, metrics, events, connections, IAM integration, L1/L2 mapping, and mixin implementation patterns.

The files cross-reference each other and link to existing docs (DESIGN_GUIDELINES.md, MIXINS_DESIGN_GUIDELINES.md, etc.).

Describe any new or updated permissions being added

NA

Description of how you validated changes

  • Content verified against the existing DESIGN_GUIDELINES.md and MIXINS_DESIGN_GUIDELINES.md
  • Classification of design vs implementation rules validated against RFC Classification Principles
  • Multiple review passes for markdown rendering, grammar, broken links, and formatting consistency
  • Full repo build passes

Checklist

@github-actions github-actions bot added the p2 label Apr 9, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team April 9, 2026 20:27
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 9, 2026
@mergify mergify bot temporarily deployed to automation April 9, 2026 20:28 Inactive
@mergify mergify bot temporarily deployed to automation April 9, 2026 20:28 Inactive
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

Add AGENTS.md with contributor guidelines for AI agents, plus two
linked reference files for construct design and implementation rules.

- AGENTS.md: main entry point with quick reference, coding patterns,
  testing, PR conventions, and anti-patterns
- docs/AGENTS_CONSTRUCT_DESIGN.md: design decisions for mixins, facades,
  traits, API shape, interfaces, type hierarchy, and naming
- docs/AGENTS_CONSTRUCT_IMPLEMENTATION.md: implementation details for
  grants, metrics, events, connections, IAM, L1/L2 mapping, and more
@alvazjor alvazjor force-pushed the feat/agent-facing-doc branch from ced432e to 72096fc Compare April 9, 2026 20:57
@alvazjor alvazjor added p1 and removed p2 labels Apr 9, 2026
@alvazjor alvazjor changed the title feat(repo): add agent-facing design guidelines feat: add agent-facing design guidelines Apr 9, 2026
@alvazjor alvazjor changed the title feat: add agent-facing design guidelines chore: add agent-facing design guidelines Apr 9, 2026
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 9, 2026 21:11

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Apr 9, 2026
- **Don't add speculative abstractions** — add what customers need today; unused abstractions become maintenance burden and API surface that can't be removed ([DESIGN_GUIDELINES.md#general-principles](./docs/DESIGN_GUIDELINES.md#general-principles))
- **Don't change construct IDs** — logical IDs derive from the full construct path; any change replaces all resources in scope, causing data loss ([DESIGN_GUIDELINES.md#construct-ids](./docs/DESIGN_GUIDELINES.md#construct-ids))
- **Don't leave commented-out code, dead code, or `eslint-disable` directives** — they rot, confuse future contributors, and mask real lint violations
- **Don't add validation to existing constructs without a feature flag** — adding validation that rejects previously accepted input is a breaking change, even if the input was invalid. You MUST gate new validation on existing constructs behind feature flags so existing apps continue to synthesize
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if the input was invalid.

Does this mean it's a condition that causes deployment failure?

If so, I disagree with this description. An CDK app that meets the conditions for deployment failure should not be deployable even if the build succeeds, and I believe adding validation to prevent that should be recommended.

Copy link
Copy Markdown
Contributor

@vishaalmehrishi vishaalmehrishi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content looks quite good, but I think we should discuss the organisation a bit.

Here's an alternative approach which is a combination of single-source-of-truth and agent-friendly setup:

  1. A single markdown file for each high-level topic (construct design, implementation, security, contributing, etc) with the relevant guidelines which both humans and agents can read.
  2. The AGENTS.md contains the top 2-3 items for each topic (so the agent does not always need to read a full topic file), and says "for more on , please see .

If we choose to stick with the current approach in the PR, then there should be some mechanism to make sure multiple files are correctly updated every time we change a guideline.

Comment on lines +44 to +45
| Mixin guidelines | `docs/MIXINS_DESIGN_GUIDELINES.md` | |
| New construct guide | `docs/NEW_CONSTRUCTS_GUIDE.md` | |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these are missing notes

Comment on lines +71 to +72
1. Modifies resource's own L1 props, no logic → `CfnPropsMixin`, STOP
2. Modifies resource's own L1 props, has logic → standalone `Mixin`, STOP
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if examples will help here, especially for what logic looks like in CDK

@@ -0,0 +1,300 @@
# Construct Design Rules — Mixins, Facades, Traits & API Design
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a reformatted DESIGN_GUIDELINES doc or are there different instructions? I think it would be best to have one doc which both humans and agents can reference, otherwise we need to keep updating two docs as guidelines change.

- KMS grants SHOULD include `kms:ViaService`
- Emit synthesis-time warnings via `Annotations.of(construct).addWarningV2()` when configuration results in public access

## Implementation Patterns
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there overlap between this and the construct implementation guidelines?


Required for: new CFN resource types, new CFN properties, cross-service integrations, new versions, Custom Resources.

## PR Conventions
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just go in the CONTRIBUTING.md file instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p1 pr/needs-maintainer-review This PR needs a review from a Core Team Member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants