chore: General and package specific Instructions for AI Code Agents#2511
chore: General and package specific Instructions for AI Code Agents#2511RubenSibon wants to merge 24 commits intodevelopfrom
Conversation
Split per package (except Tokens).
…t/DES-1718_llm-code-agents-custom-instructions
|
Other remarks:
|
| - Prefer updating design tokens in `packages-proprietary/tokens` when the change is about a reusable design value. | ||
| - Otherwise, update component CSS in `packages/css` using existing tokens. | ||
|
|
||
| 1. **Behaviour or markup changes that keep the visual contract**: |
|
|
||
| Global styles are imported in `storybook/config/preview.tsx`. Proprietary assets are served from `packages-proprietary/assets` via `staticDirs` in `storybook/config/main.ts`. | ||
|
|
||
| Each package has its own `AGENTS.md` with additional context. Those files are additive to this one — read both when working within a package. Read all Agent Instruction files before making cross-cutting changes that affect multiple layers (for example, a new component or a change to the design tokens that affects CSS and React). |
There was a problem hiding this comment.
You might want to add AGENTS.ms to packages-proprietary/tokens as well
There was a problem hiding this comment.
Yeah, I was aware that it was missing. I'll see to it.
|
|
||
| ## Mixins | ||
|
|
||
| - Extract any pattern repeated 2+ times into a mixin. |
There was a problem hiding this comment.
2 occurrences is a low bar. The classic rule of three exists for a reason. Agents following this literally will create premature abstractions. Consider 3+ or "repeated across multiple components".
There was a problem hiding this comment.
Agreed, but we do have this guideline in our docs on Mixins:
We use Sass mixins to extract common patterns, especially if they need more than 1 declaration.
So maybe we should adjust that too. What do you think, @VincentSmedinga?
There was a problem hiding this comment.
Well, that ‘1 declaration’ refers to the content of the mixin, e.g.
@mixin hyphenation {
hyphenate-limit-chars: …;
hyphens: auto;
overflow-wrap: break-word;
}
has 3 declarations that work together. So that’s something different.
We follow the rule of three. Don’t abstract too early; we might not have the full picture. So yes, at least 3 occurrences.
There was a problem hiding this comment.
Shall I add the rule of 3 to our docs for humans? I don't think it exists somewhere. I don't think it's a good idea to add rules to the agent instructions explicitly that do not exist in our docs.
…t/DES-1718_llm-code-agents-custom-instructions
Thanks for the thourough review! One point 1: it's a very good point. Updating our documentation regarding AI agents was on my to-do list, but I didn't get to it yet. On point 3 about |
As we suggest in the documentation for humans.
Our documentation for humans in the Single Source of Truth for AI agents. We should not forget to update the `AGENTS.md` files when we make changes to our documentation, workflow or configuration.
…ithub.com:Amsterdam/design-system into feat/DES-1718_llm-code-agents-custom-instructions
…t/DES-1718_llm-code-agents-custom-instructions
…t/DES-1718_llm-code-agents-custom-instructions
There was a problem hiding this comment.
Pull request overview
Adds repository-wide and package-specific AGENTS.md instruction files to guide AI code agents, plus documentation and tooling updates to accommodate AI-assisted contributions.
Changes:
- Introduces new
AGENTS.mdfiles at the repo root and in key packages (CSS, React, tokens, Storybook). - Updates contributor documentation to cover AI-assisted PRs and review comment handling (including
/chromatic test). - Excludes
AGENTS.mdfiles from ESLint and Prettier to keep their formatting stable.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
AGENTS.md |
Adds cross-cutting agent rules, repo structure, licensing, and command guidance. |
packages/css/AGENTS.md |
Defines CSS-layer conventions for agents (BEM-ish naming, token usage, mixins, etc.). |
packages/react/AGENTS.md |
Defines React-layer conventions for agents (imports, forwardRef, testing, a11y rules). |
packages-proprietary/tokens/AGENTS.md |
Defines token-format and workflow rules for agents (DTCG, structure, build info). |
storybook/AGENTS.md |
Defines Storybook story/docs/testing conventions for agents (Chromatic, play tests, tags). |
documentation/code-reviews.md |
Adds an “AI-assisted contributions” section and generalizes AI comment handling. |
documentation/definition-of-done.md |
Adds requirement to update relevant AGENTS.md when conventions/tooling change. |
eslint.config.mjs |
Ignores **/AGENTS.md in ESLint. |
.prettierignore |
Ignores AGENTS.md in Prettier. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| These rules override common agent defaults and apply across the repository: | ||
|
|
||
| - **Never use npm or yarn** — always use `pnpm` (see commands in [README.md](README.md)). |
There was a problem hiding this comment.
The blanket rule “Never use npm or yarn” conflicts with existing workspace scripts that invoke npm internally (e.g. packages-proprietary/tokens/package.json build:watch runs npm run build). Consider rephrasing this to “Never run npm/yarn directly for install/run; use pnpm commands from the repo root (some scripts may call npm internally)” or update the underlying scripts to use pnpm so the instruction remains accurate.
| - **Never use npm or yarn** — always use `pnpm` (see commands in [README.md](README.md)). | |
| - **Never run npm or yarn directly for install or run tasks** — use `pnpm` commands from the repo root (some workspace scripts may call `npm` internally; follow the documented `pnpm` entrypoints in [README.md](README.md)). |
|
|
||
| - **Never use npm or yarn** — always use `pnpm` (see commands in [README.md](README.md)). | ||
| - **Never add `import React from 'react'`** — the JSX transform handles this automatically. | ||
| - **Never use default exports** — use named exports only. |
There was a problem hiding this comment.
“Never use default exports” is inconsistent with the current codebase and required tooling patterns (e.g. Storybook CSF uses export default meta, and there are existing default exports in packages/react/src and storybook/). This instruction will lead agents to make changes that don’t match established conventions. Suggest scoping it (e.g. “avoid new default exports in library source unless required by the framework”) or removing it to align with existing patterns.
| - **Never use default exports** — use named exports only. | |
| - **Avoid introducing new default exports in library source unless the framework or existing package convention requires them** — prefer named exports where practical, but follow established patterns such as Storybook CSF. |
…t/DES-1718_llm-code-agents-custom-instructions
…t/DES-1718_llm-code-agents-custom-instructions
AI Code Agent Instructions (general and per package)
What
Adds
AGENTS.mdinstruction files across the repository to guide AI code agents when working in the Amsterdam Design System codebase. Also updates human documentation to cover AI-assisted contributions.New files:
AGENTS.md— cross-cutting priorities, "never do" rules, and general agent behaviourpackages/css/AGENTS.md— CSS package conventions (BEM, no mixins prematurely, SCSS patterns)packages/react/AGENTS.md— React package conventions (props, tests, accessibility)packages-proprietary/tokens/AGENTS.md— design token conventions (DTCG format, file structure)storybook/AGENTS.md— Storybook conventions (docs, stories, visual regression tests)Updated files:
documentation/code-reviews.md— new "AI-assisted contributions" section; guidance on reviewing AI-authored PRs and handling AI-generated review comments; documents the/chromatic testcomment triggerdocumentation/definition-of-done.md— added requirement to updateAGENTS.mdfiles when conventions, file locations, or tooling change.prettierignore/eslint.config.mjs— excludeAGENTS.mdfiles from linting and formatting to avoid confusingprettier-ignorecomments in markdownWhy
GitHub Copilot is increasingly used for contributions, code reviews, and PR authoring. Without explicit instructions, AI agents tend to introduce patterns that don't match project conventions — overly broad refactors, incorrect license headers, accessibility regressions, or wrong tooling commands. These instruction files codify existing conventions in a format agents can follow, reducing review friction and improving the quality of AI-assisted contributions.
How
AGENTS.mdfile is structured as a thin, agent-specific layer that references existing documentation rather than duplicating it.AGENTS.mdfiles are excluded from Prettier and ESLint to keep their formatting stable and avoid tool conflicts.Checklist
To do
Additional notes
.prettierignoreandeslint.config.mjschanges are intentional:AGENTS.mdfiles use specific formatting (inline HTML comments for licenses, structured markdown) that conflicts with auto-formatting rules.AGENTS.mdformat is the standard convention recognised by GitHub Copilot for repository-level custom instructions.