<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: docs/agents/ in the magma monorepo.
  Regenerate with: npm run sync.agent-docs (from the stencil package).
-->
# @maggioli-design-system/magma - agent install guide

> Version 2.15.0. You (the agent) are installing Magma into THIS project. Do not
> assume the setup - detect it from the project, then ask the user only for what you
> cannot infer. The detailed steps live in [`agents/install.md`](agents/install.md)
> (this target) and [`agents/assets.md`](agents/assets.md) (shared styles, fonts,
> icons). This package targets: **none (plain HTML / vanilla JS, or any framework via custom elements)**.

## Step 1 - detect (read, do not ask)

Inspect the consumer project before asking anything:

| What | Where to look |
| ---- | ------------- |
| Framework | `package.json` deps: `@angular/core` -> Angular, `react`/`next` -> React, else vanilla |
| Magma wrapper installed | presence of `magma-angular` / `magma-react` / `magma` in deps |
| Bundler / static dir | `angular.json` (Angular CLI assets), `vite.config.*`, `next.config.*` (`public/`), webpack |
| Tailwind + version | `tailwindcss` in deps: v4 -> the CSS imports, v3 -> the JS preset (see agents/assets.md) |
| SSR | `@angular/ssr` / Angular Universal, or Next App Router |
| Compatible versions | derive from the installed `@maggioli-design-system/magma` major (see matrix in install.md) |
| Editor | a `.vscode/` folder -> VS Code; nothing -> ask (step 2) |

## Step 2 - ask only the gaps

Ask the user only what detection left undecided. Typical questions:

1. **Icons**: which sets does the app use, and how should they be served? Every slug must
   be served at `<mdsIconSvgPath><slug>.svg`, and each set comes from its own package:
   Magma ships only `mgg/` (`@maggioli-design-system/svg-icons`), while `mi/` and
   `mdi/` come from `@material-icons/svg` and `@mdi/svg`, and none of them is a
   dependency of this package. The routes are in agents/assets.md section 3: **iconsauce**,
   what Magma uses (it reads the sources and writes only the icons they name), or a copy
   script that serves the files in the slug layout. Copying the `svg-icons` folder as it
   is renders nothing: its files are not under `mgg/`.
2. **Static assets path**: where are static files served from? This sets `mdsIconSvgPath`
   and the SVG copy destination.
3. **Dark mode / preferences**: needed? If yes, wire the preference classes and components.
4. Confirm the version row if the installed major is ambiguous.
5. **Editor**: VS Code? It gets token and class autocomplete through two files in
   `.vscode/` (agents/assets.md section 5); for another editor only the token file applies.

## Step 3 - execute

1. Install packages and the shared assets - see [`agents/install.md`](agents/install.md).
2. Wire styles in the exact cascade-layer order - see [`agents/assets.md`](agents/assets.md).
3. Serve every icon slug the app uses at the static path, with the route from step 2, and
   set `mdsIconSvgPath`.
4. Register components: the defineCustomElement* functions from '@maggioli-design-system/magma/components' (tree-shakeable), or defineCustomElements() from '@maggioli-design-system/magma/loader' to register everything at once.
5. Set up editor autocomplete - see [`agents/assets.md`](agents/assets.md) section 5: MERGE the
   keys into `.vscode/settings.json` and `.vscode/extensions.json`, never overwrite them.
6. Set up the lint - see [`agents/lint.md`](agents/lint.md): the ESLint and Stylelint rules ship
   in this package; MERGE the Magma presets into the project's ESLint and Stylelint
   configurations, never overwrite them.
7. Set up the MCP server - see [`agents/mcp.md`](agents/mcp.md): it ships in this package as
   the `magma-mcp` command, started with `npx --no magma-mcp` (never without `--no`, which
   would let npx install a package of that name from the registry). For Claude Code, register
   the Magma plugin in the project's `.claude/settings.json` instead: it starts the server and
   adds the Magma skills (`/magma:setup`, `/magma:review`, `/magma:migrate`,
   `/magma:pattern-layer`). For the other
   clients MERGE the entry into `.vscode/mcp.json`, `.cursor/mcp.json` or
   `opencode.json`; never both the plugin and an `.mcp.json` entry, or the server runs
   twice. Then call its `check_setup` tool: it lists what the integration still misses.

## Step 4 - verify

Build the app and confirm an `mds-*` component renders and every icon it names loads
from the configured path (no 404 on `<path><slug>.svg`). In VS Code, check both halves of
the autocomplete: `var(--magma-` completes Magma tokens in a CSS file and, with Tailwind,
`bg-surface-default` shows a swatch. Run the lint ([`agents/lint.md`](agents/lint.md)): no
error. Report what was installed, the cascade order used, the icon route, the icon path and
the lint configuration.

## Using the components

Once installed, do not guess component APIs or rules - read only the file you need:

| You need | Read |
| -------- | ---- |
| Which component to reach for | [`agents/components.md`](agents/components.md) - the catalogue by category, one line each |
| A task that spans components, solved the same way in every product: where a message goes, confirming an action, an empty, a loading or a failed part | [`agents/patterns.md`](agents/patterns.md) - the catalogue of the patterns; ask `get_pattern` of the MCP server for the case of your situation |
| How the parts of a screen stand together: the space between two elements, which action weighs more, the style of a title, when a surface, how wide | [`agents/patterns.md`](agents/patterns.md), section Design language - the rules of composition; ask `get_pattern` for the rule of your context, `get_guide` for a domain by its id (`rhythm`) |
| One component's API (props with allowed values, events, methods, slots, parts, CSS vars) | its `AGENTS.md`, linked from the catalogue |
| Correct usage and mistakes for one component | `examples.md` / `mistakes.md` beside its `AGENTS.md` |
| Rules shared by every component: naming, events, slots, compound, icons, a11y, styling from outside | [`agents/conventions.md`](agents/conventions.md) |
| `variant` and `tone` values | [`agents/variants.md`](agents/variants.md) |
| Mistakes to avoid with any component | [`agents/mistakes.md`](agents/mistakes.md) |
| Coloring your own UI | [`agents/color.md`](agents/color.md) |
| Colors in an Android, iOS or Flutter app, where the components do not run | [`agents/color.md`](agents/color.md), "Outside the web" |
| Typography utilities | [`agents/typography.md`](agents/typography.md) |
| Dark mode, preferences, named themes, surface levels and elevation, global design decisions, corner geometry | [`agents/theming.md`](agents/theming.md) |
| Asking instead of reading: the API of a component, the role for a need, a class, an icon slug, a guide section, a snippet checked before writing | the tools of the `magma` MCP server, [`agents/mcp.md`](agents/mcp.md) |
| Checking what you wrote: run ESLint and Stylelint with the Magma presets after every change, and fix what they report | [`agents/lint.md`](agents/lint.md) |
| Reporting a problem that is Magma's, not this project's (bug, wrong guide, missing token), with this project's origin label | [`agents/reporting.md`](agents/reporting.md) |
| What changed between the installed version and a newer one, before upgrading | `CHANGELOG.md` of each Magma package, newest release first (`magma-react` and `magma-angular` carry the releases of `magma`) |

Tooling that needs structured data reads `documentation.json`: one per component beside
its `AGENTS.md`, or `@maggioli-design-system/magma/dist/documentation.json` for all of them
(over 2 MB - do not load it into context). In both, the relative links of the `usage`
texts resolve from the component's folder, `dist/collection/components/<tag>/`.
`dist/types/components.d.ts` drives editor IntelliSense.
