AGENTS.md: Add design system package guide#77264
Conversation
Add a new section to AGENTS.md that helps AI agents identify the correct package when working with WordPress Design System components. This addresses a recurring problem where agents pick components from @wordpress/components or @wordpress/ui at random, or fabricate tokens instead of using the theme package. The guide covers package responsibilities, component-to-package mapping, token usage rules, and the relationship between the legacy /components package and the newer /ui package. Part of WordPress#77205. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @jarekmorawski! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Add a new "Design system package guide" section and two new common pitfalls to help AI agents work correctly with WordPress Design System packages. The guide covers: - Package-to-role mapping for @wordpress/theme, /ui, /icons, /admin-ui, /dataviews, and /components - Token usage rules and the preference for /ui over /components - The distinction between --wp--preset--* (block rendering) and --wpds-* (admin UI) CSS custom property namespaces New common pitfalls: - @wordpress/dataviews registers a @wordpress/data store on import - /ui and /components use different styling systems (CSS Modules vs Emotion) — contributors should match the package they're working in Part of WordPress#77205. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
Should this information live in IMO, information about what a package does and how to use its APIs shoud live as close as possible to the source (ie in the package's README, in each component docs, etc). As for where wider "Design System orchestration" info should live, that's something to discuss and agree on: my take is that it should live on a reference site (either a dedicated site, or a section of Storybook), and agents should be pointed to fetch every time the latest version as the canonical source of information. |
|
What's currently proposed here as a package summary might work well as a replacement or extension of the current design system introduction documentation in Storybook, and we could either summarize or redirect agents to that documentation (being mindful that agents tend to not always follow redirection, but also wary of the maintenance cost and drift potential of maintaining a duplicate summary copy). There's been some concerns raised about the existence of this AGENTS file in the first place (related to Trac#63901 discussion), but I can see from my own experience with agents where this guidance may be helpful (e.g. preferring tokens over hardcoded values). With many of these, I do find myself asking:
|
| Key rules: | ||
|
|
||
| - **Never hardcode colors, spacing, or typography values.** Always reference `--wpds-*` tokens from `@wordpress/theme`. If a token doesn't exist for your use case, that's a gap worth reporting — not a reason to use a raw value. | ||
| - **Prefer `@wordpress/ui` over `@wordpress/components`.** The `/ui` package is the design system implementation; `/components` is a legacy collection being incrementally replaced. When both packages export a component with the same purpose, use the `/ui` version. |
There was a problem hiding this comment.
There's been some work to try to document status on a component-by-component basis.
Examples:
gutenberg/packages/components/src/h-stack/stories/index.story.tsx
Lines 77 to 81 in d5be89a
gutenberg/packages/components/src/button/stories/index.story.tsx
Lines 54 to 58 in d5be89a
I don't think we're at a point where we'd want to make a blanket statement to always prefer @wordpress/ui (related: #76135), but ideally we could and should be pointing towards these component-specific statuses if they're known.
There was a problem hiding this comment.
This is a good reminder that we should ideally be considering these component statuses as part of an MCP offering; for example, maybe we should include some @wordpress/components components in the design system MCP responses if they're stable, i.e. there's not an equivalent in @wordpress/ui or it's not ready to be used.
|
|
||
| - **Never hardcode colors, spacing, or typography values.** Always reference `--wpds-*` tokens from `@wordpress/theme`. If a token doesn't exist for your use case, that's a gap worth reporting — not a reason to use a raw value. | ||
| - **Prefer `@wordpress/ui` over `@wordpress/components`.** The `/ui` package is the design system implementation; `/components` is a legacy collection being incrementally replaced. When both packages export a component with the same purpose, use the `/ui` version. | ||
| - **`@wordpress/components` uses a different styling system.** It consumes Sass variables from `@wordpress/base-styles`, not `--wpds-*` tokens. Mixing `/ui` and `/components` on the same page may produce minor visual inconsistencies. |
There was a problem hiding this comment.
This feels like something we're actively trying to avoid (i.e. @wordpress/components and @wordpress/ui should be expected to coexist without perceivable visual differences), so I'd be hesitant to document that this is expected, or that the components shouldn't be used together.
There was a problem hiding this comment.
Right, and "can they coexist visually" is part of the criteria for adding a new @wordpress/ui component to the list of recommended components.

Description
Adds a "Design system package guide" section and two new common pitfalls to
AGENTS.md, helping AI agents work correctly with WordPress Design System packages.Design system package guide (new section)
@wordpress/theme,@wordpress/ui,@wordpress/icons,@wordpress/admin-ui,@wordpress/dataviews, and@wordpress/components--wp--preset--*(block rendering / front-end) vs.--wpds-*(admin UI / design system components) — two CSS custom property namespaces that coexist in GutenbergCommon pitfalls (new bullets)
@wordpress/dataviewsregisters a@wordpress/datastore at import time; removing a<DataViews>usage without removing theimportstill ships the store registry@wordpress/uiand@wordpress/componentsuse different styling systems (CSS Modules vs. Emotion) — contributors should match the styling approach of the package they're working inMotivation
This addresses a recurring problem where AI agents working with Gutenberg:
@wordpress/componentsor@wordpress/uiat random, requiring manual cleanup@wordpress/theme--wp--preset--*vs.--wpds-*)/uito/components(or when not to)These patterns were observed across multiple prototyping projects that stress-tested the WPDS packages. The component lists in the table use "e.g." so they remain accurate as new components are added.
Part of #77205.
Testing Instructions
This is a documentation-only change to
AGENTS.md. No code, tests, or build changes.Pre-merge Checklist
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com