AGENTS.md
AGENTS.mdAGENTS.mdroot
Quality
100/100
Scores the file, not the repository.Length
1,084 words
24 headings · 14 code blocksRepository
99k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# AGENTS.md23This file provides guidance for AI agents working with code in this repository.45## Package Manager67**Only pnpm is supported** (yarn/npm will fail). Use the `-F` flag for workspace operations:89```bash10pnpm -F @mui/material add some-package # Add dependency to a package11pnpm -F @mui/material build # Build a specific package12```1314Never use `cd` to navigate into package directories for commands.1516## Common Commands1718### Development1920```bash21pnpm install # Install deps if necessary22pnpm docs:dev # Start docs dev server only23```2425### Building2627```bash28pnpm release:build # Build all packages (except docs)29pnpm docs:build # Build documentation site30```3132### Testing3334```bash35pnpm test:unit # Run all unit tests (jsdom)36pnpm test:unit ComponentName # Run tests matching pattern37pnpm test:unit -t "test name" # Grep for specific test name38pnpm test:browser # Run tests in real browsers (Chrome, Firefox, WebKit)39pnpm test:e2e # End-to-end tests40pnpm test:regressions # Visual regression tests41```4243### Code Quality4445```bash46pnpm prettier # Format staged changes47pnpm eslint # Lint with cache48pnpm typescript # Type check all packages49```5051### API Documentation5253After changing component props or TypeScript declarations:5455```bash56pnpm proptypes && pnpm docs:api57```5859### Docs demos6061Always author the TypeScript version of the demos. To generate the JavaScript variant, run:6263```bash64pnpm docs:typescript:formatted65```6667## Architecture6869This is a monorepo managed by Lerna with Nx for caching. Key packages:7071- `@mui/material` - Core Material UI components72- `@mui/system` - Styling system (sx prop, styled, theme)73- `@mui/lab` - Experimental components (new components go here first)74- `@mui/icons-material` - Material Design icons75- `@mui/utils` - Internal utilities76- `@mui/styled-engine` - CSS-in-JS abstraction (Emotion by default)7778Internal packages (not published): `@mui-internal/*`, `@mui/internal-*`7980## Code Conventions8182### TypeScript8384- Use `interface` (not `type`) for component props85- Export `{ComponentName}Props` interface from component files86- Path aliases available: `@mui/material` → `./packages/mui-material/src`8788### Errors8990These guidelines only apply for errors thrown from public packages.9192Every error message must:93941. **Say what happened** - Describe the problem clearly952. **Say why it's a problem** - Explain the consequence963. **Point toward how to solve it** - Give actionable guidance9798Format:99100- Prefix with `MUI: `101- Use string concatenation for readability102- Include a documentation link when applicable (`https://mui.com/r/...`)103104#### Error Minifier105106Use the `/* minify-error */` comment to activate the babel plugin:107108```tsx109throw /* minify-error */ new Error(110 'MUI: Expected valid input target. ' +111 'Did you use a custom `inputComponent` and forget to forward refs? ' +112 'See https://mui.com/r/input-component-ref-interface for more info.',113);114```115116The minifier works with both `Error` and `TypeError` constructors.117118#### After Adding/Updating Errors119120Run `pnpm extract-error-codes` to update `docs/public/static/error-codes.json`.121122**Important:** If the update created a new error code, but the new and original message have the same number of arguments and semantics haven't changed, update the original error in `error-codes.json` instead of creating a new code.123124### Component Structure125126```text127packages/mui-material/src/Button/128├── Button.tsx # Component implementation129├── Button.d.ts # TypeScript declarations (for JSDoc API docs)130├── Button.test.js # Unit tests131├── buttonClasses.ts # CSS classes132└── index.ts # Public exports133```134135### Testing136137- Use `createRenderer()` from `@mui/internal-test-utils`138- Use Chai BDD-style assertions (`expect(x).to.equal(y)`)139- Custom matchers: `toErrorDev()`, `toWarnDev()` for console assertions140- Prefer testing components with full interactions using `user.*` methods. Avoid `fireEvent` and `setProps` if possible.141- If tests require the browser because, for example, they require layout measurements, restrict it to the Chromium env by using `it.skipIf(isJsdom())` or `describe.skipIf(isJsdom())` (search other tests for example usage if unsure).142143```js144import { createRenderer } from '@mui/internal-test-utils';145146describe('Button', () => {147 const { render } = createRenderer();148149 it('renders children', async () => {150 const handleClick = vi.fn();151 const { getByRole, user } = render(<Button onClick={handleClick}>Hello</Button>);152153 const button = getByRole('button');154 expect(button).to.have.text('Hello');155156 await user.click(button);157 expect(handleClick).toHaveBeenCalledTimes(1);158 });159});160```161162### Accessibility Testing163164axe-core runs inside the visual-regression Playwright loop (`test/regressions/index.test.js`) — no separate browser session. Screenshots and a11y are independent: a demo can opt out of one and still run the other.165166Key files:167168- `test/regressions/demoMeta.ts` — `SCREENSHOT_RULES` and `A11Y_RULES` arrays, matched last-wins (no inheritance: overrides restate every field) against `docs/data/material/components/{slug}/{Demo}` (minimatch globs).169- `test/regressions/a11y/axe.ts` — asserts `color-contrast` and `link-in-text-block` unless listed in `skipAssertions`.170- `test/regressions/a11y/a11yReporter.ts` — writes one file per slug at `docs/data/material/components/{slug}/{slug}.a11y.json`. Each file is keyed by demo name, then by axe rule ID. Each rule records a `status` (`pass`, `fail`, or `incomplete`) and WCAG tags.171172Enroll a component (slug-wide, or narrow with brace-glob):173174```ts175// test/regressions/demoMeta.ts176{ test: 'docs/data/material/components/alert/*', enabled: true, skipAssertions: ['color-contrast'] },177{ test: 'docs/data/material/components/buttons/{BasicButtons,ColorButtons}', enabled: true },178```179180Override a specific demo: append a per-demo rule _after_ the slug-wide rule (last-match-wins; the override must restate every field it wants):181182```ts183{ test: 'docs/data/material/components/popover/AnchorPlayground', enabled: false }, // Redux isolation184```185186Run `pnpm test:regressions` to refresh the `*.a11y.json` files. CI fails if any are stale.187188For local iteration, scope the run with vitest's `-t` test-name filter (matched against the `it()` strings, which contain the route). Non-matching tests are skipped — their bodies don't execute, so the browser never navigates to those routes.189190```bash191# in one terminal192pnpm test:regressions:server193194# in another — note no `--`, pnpm forwards args directly195pnpm test:regressions:run -t '/docs-components-buttons/' # one slug196pnpm test:regressions:run -t '/docs-components-buttons/BasicButtons$' # one demo197pnpm test:regressions:run -t '/docs-components-(buttons|chips)/' # multiple slugs198```199200Filtered runs only refresh the matched slugs' `*.a11y.json`. Run the unfiltered `pnpm test:regressions` before pushing.201202### Imports203204Use one-level deep imports to avoid bundling entire packages:205206```js207import Button from '@mui/material/Button'; // Good208import { Button } from '@mui/material'; // Avoid in packages209```210211## Agent Skills212213Packaged guidance for common integration topics lives under `skills/`. Each skill is a self-contained directory:214215| Skill | Focus |216| :--------------------------------------------------------------------- | :---------------------------------------------------------- |217| [skills/material-ui-styling](./skills/material-ui-styling/AGENTS.md) | `sx`, `styled()`, theme overrides, slots, global CSS |218| [skills/material-ui-theming](./skills/material-ui-theming/AGENTS.md) | `createTheme`, design tokens, `colorSchemes`, CSS variables |219| [skills/material-ui-nextjs](./skills/material-ui-nextjs/AGENTS.md) | App/Pages Router, Emotion cache, `next/font`, `Link`, SSR |220| [skills/material-ui-tailwind](./skills/material-ui-tailwind/AGENTS.md) | Tailwind v4 `@layer`, `enableCssLayer`, v3 interop |221222Read the relevant `AGENTS.md` when helping users with those topics.223224## Pre-PR Checklist2252261. `pnpm prettier` - Format code2272. `pnpm eslint` - Pass linting2283. `pnpm typescript` - Pass type checking2294. `pnpm test:unit` - Pass unit tests2305. If API changed: `pnpm proptypes && pnpm docs:api`2316. If demos changed: `pnpm docs:typescript:formatted`2327. If `.md` files changed: `pnpm vale <file1> <file2> ...` - Check prose style and grammar233234## PR Title Format235236`[component] Imperative description`237238Examples:239240- `[button] Add loading state`241- `[docs] Fix typo in Grid documentation`242
Also in mui/material-ui
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| mui/material-uiskills/material-ui-nextjs/AGENTS.md · 99k | AGENTS.md | setupstylearchtypes+2 | 70/100 | 3 days ago | |
| mui/material-uiskills/material-ui-styling/AGENTS.md · 99k | AGENTS.md | styleui | 58/100 | 3 days ago | |
| mui/material-uiskills/material-ui-tailwind/AGENTS.md · 99k | AGENTS.md | styleui | 58/100 | 3 days ago | |
| mui/material-uiskills/material-ui-theming/AGENTS.md · 99k | AGENTS.md | setupstyleui | 58/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| wpscanteam/wpscanAGENTS.md · 9.7k | AGENTS.md | setupbuildteststyle+6 | 100/100 | 2 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 3 days ago |
