Skip to content

chore: add agent-facing design guidelines#37565

Merged
mergify[bot] merged 2 commits intomainfrom
feat/agent-facing-doc
Apr 14, 2026
Merged

chore: add agent-facing design guidelines#37565
mergify[bot] merged 2 commits 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)

@alvazjor alvazjor force-pushed the feat/agent-facing-doc branch from bf62df1 to ced432e Compare April 9, 2026 20:40
@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
Comment thread AGENTS.md Outdated
- **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 Author

@alvazjor alvazjor Apr 13, 2026

Choose a reason for hiding this comment

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

Good catch, this needs to be reformated to explain better the condition. From a pure technical perspective, even tho the original input never worked as intended, a change modifying how a validation used to work will be considered a breaking change. But is a valid breaking change, and then a feature flag will not be rquired, and the validation alone is enough. But, imo, we still need a way to alert consumers that the change was done, and justify why the breaking change was permitted without a flag.
Will rewrite this in a new revision

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 topic, please see topic-specific md file".

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 thread AGENTS.md Outdated
Comment thread AGENTS.md
Comment thread docs/AGENTS_CONSTRUCT_DESIGN.md
Comment thread AGENTS.md
Comment thread AGENTS.md
Comment thread AGENTS.md
@@ -0,0 +1,326 @@
# AGENTS.md — AWS CDK

> Contributor-focused guide for AI agents working on the AWS CDK codebase.
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.

The main difference between this and other documents is the enforcement language used.

The other two documents use MUST, MUST NOT and SHOULD which are better keywords to guide agents.
Meanwhile this document used keywords like NEVER, Don't etc. which not be interpreted as strictly as the keywords in other documents.
Is this intentional ? Are we going to be using this as mainly context file for an agents meanwhile the other two act as exact prescriptive guidance ?

Copy link
Copy Markdown
Contributor Author

@alvazjor alvazjor Apr 13, 2026

Choose a reason for hiding this comment

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

Is this intentional ? Are we going to be using this as mainly context file for an agents meanwhile the other two act as exact prescriptive guidance ?

Yes and yes. The language here is a bit more natural because this file is more for general context, tho there are some rules here that follow the imperative language. The other 2 are loaded based on what the agent defines for the task it is implementing, and they are a repository of rules of instructions that need to be followed to comply with our expectations, so the language used is more unambiguous

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
Comment thread AGENTS.md

## Anti-Patterns — Things NOT To Do

- **MUST NOT use jsii-incompatible patterns** — mapped types, conditional types, overloaded functions, TypeScript namespaces, `export const` objects (use `public static readonly` on classes). MUST NOT move public types between files — file location is part of the external contract in jsii bindings
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.

Like the MUST NOT here

Copy link
Copy Markdown
Contributor

@kumvprat kumvprat left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 14, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 14, 2026

Merge Queue Status

  • Entered queue2026-04-14 15:31 UTC · Rule: default-squash
  • Checks passed · in-place
  • Merged2026-04-14 16:34 UTC · at b14111e190e30dc6f86bef8ae9a0fe8ba5c63033

This pull request spent 1 hour 3 minutes 5 seconds in the queue, including 51 minutes 12 seconds running CI.

Required conditions to merge

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Apr 14, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 14, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify Bot merged commit 9ca251b into main Apr 14, 2026
20 of 21 checks passed
@mergify mergify Bot deleted the feat/agent-facing-doc branch April 14, 2026 16:34
@github-actions
Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants