From d7cbe87705bb12d2d021302f9ffff7a7b8125c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kuna?= <1282324+codecalm@users.noreply.github.com> Date: Fri, 28 Aug 2026 18:39:00 +0200 Subject: [PATCH] Add Astro agent skills and `color`/`vertical` props to `Steps` (#2908) --- .agents/rules/main.mdc | 32 +++++ .agents/skills/astro-dev/SKILL.md | 80 +++++++++++++ .agents/skills/astro-scripts/SKILL.md | 122 +++++++++++++++++++ .agents/skills/build-pipeline/SKILL.md | 80 +++++++++++++ .agents/skills/core-js/SKILL.md | 99 ++++++++++++++++ .agents/skills/core-scss/SKILL.md | 121 +++++++++++++++++++ .agents/skills/html-diff/SKILL.md | 91 ++++++++++++++ .agents/skills/navigation/SKILL.md | 86 ++++++++++++++ .agents/skills/page-layouts/SKILL.md | 92 ++++++++++++++ .agents/skills/shared-lib/SKILL.md | 86 ++++++++++++++ .agents/skills/ui-component/SKILL.md | 145 +++++++++++++++++++++++ .changeset/steps-color-vertical-props.md | 5 + preview/pages/steps.astro | 7 +- shared/ui/Steps.astro | 8 +- 14 files changed, 1047 insertions(+), 7 deletions(-) create mode 100644 .agents/skills/astro-dev/SKILL.md create mode 100644 .agents/skills/astro-scripts/SKILL.md create mode 100644 .agents/skills/build-pipeline/SKILL.md create mode 100644 .agents/skills/core-js/SKILL.md create mode 100644 .agents/skills/core-scss/SKILL.md create mode 100644 .agents/skills/html-diff/SKILL.md create mode 100644 .agents/skills/navigation/SKILL.md create mode 100644 .agents/skills/page-layouts/SKILL.md create mode 100644 .agents/skills/shared-lib/SKILL.md create mode 100644 .agents/skills/ui-component/SKILL.md create mode 100644 .changeset/steps-color-vertical-props.md diff --git a/.agents/rules/main.mdc b/.agents/rules/main.mdc index 0af24066a..9a3da1c0e 100644 --- a/.agents/rules/main.mdc +++ b/.agents/rules/main.mdc @@ -18,6 +18,28 @@ Shared instructions for all AI agents (Claude Code, Cursor, etc.). Canonical age - `docs/components/` — docs-only Astro components (`Example`, menu, …) via `@components`. - Package manager: pnpm workspaces + turbo. Node.js >= 22.12. +## Skills + +Task-specific instructions live in `.agents/skills//SKILL.md` — read the matching one before starting, it is the source of truth for that area. + +| Skill | Use it when | +| --- | --- | +| `ui-component` | creating or extending a component in `shared/ui/` or `shared/components/` | +| `astro-scripts` | a component or page needs client-side JavaScript | +| `page-layouts` | choosing or changing the page chrome (`shared/layouts/`) | +| `shared-lib` | moving logic into `shared/lib/` and testing it | +| `core-scss` | writing or changing styles in `core/scss/` | +| `core-js` | working on the framework JavaScript in `core/js/` | +| `demo-pages` | adding or updating a page in `preview/pages/` | +| `write-docs` | writing or updating a page in `docs/content/` | +| `class-reference` | a docs page needs its `classnames` table added or refreshed | +| `navigation` | menus, page URLs and docs redirects | +| `astro-dev` | starting a dev server and verifying a change in the browser | +| `html-diff` | proving a refactor changes no rendered HTML | +| `build-pipeline` | assets missing, stale or growing; editing `.build/` or the asset manifests | +| `generate-changeset` | writing a changeset (always — never hand-write the file) | +| `mr-description` | drafting an MR/PR title and description | + ## Language - Write all repository content in English: code, comments, documentation, commit messages, PR titles and descriptions. @@ -28,6 +50,10 @@ Shared instructions for all AI agents (Claude Code, Cursor, etc.). Canonical age ### Astro pages and components - Pages are Astro components; reusable markup lives in `shared/components/`. +- Building or changing a shared component: follow the `ui-component` skill (Props interface, prop names, class composition, slots). +- Client-side JavaScript: follow the `astro-scripts` skill. Always ` + + +``` + +- `BEGIN … / END …` comments mark the block in the copied HTML. Use the component name in caps. +- A named `init…` function plus the `readyState` guard, never a bare call: the script may be parsed after `DOMContentLoaded` has already fired. +- The component takes a required `id` prop and derives ids and selectors from it in the frontmatter. Never query by class or by tag — a page renders many instances. + +## 4. Passing data with `define:vars` + +`define:vars` JSON-serialises the values and declares them as consts at the top of the script. It carries data only: no functions, no DOM nodes, no closures over frontmatter helpers. Pass config objects whole (`chartOptions`, `markers`, `sortKeys`) instead of interpolating them into a template string. + +Two known snags: + +- **Astro wraps a `define:vars` script in an IIFE.** Anything the markup calls (`onclick="setPageListItems(this)"`) must be assigned to `window` explicitly — see `shared/components/demo/AdvancedTable.astro`. If several instances define the same global, make it stateless and resolve the instance from the clicked element. +- The type checker does not see `define:vars` bindings used inside template literals. `shared/components/marketing/hero/Side.astro` carries a `// @ts-nocheck` for exactly that; copy the comment with its explanation rather than restructuring the script. + +## 5. When the script has to be a string + +If caller-supplied JS must land *inside* a function body, `define:vars` cannot do it — it injects variables, not code. Then build the script as a template string in the frontmatter and render it with `` inside `` (see `shared/ui/Signature.astro`). Serialise every interpolated value with `JSON.stringify` and keep raw-JS props documented as an escape hatch. + +## 6. Instance registries + +Plugin instances go into a namespaced global keyed by id, so demo pages, docs examples, and the browser console can reach them: + +```js +window.tabler_rating ??= {} +window.tabler_rating[ratingKey] = new StarRating(ratingSelector, { … }) +``` + +`window.tabler_list`, `window.tabler_rating`, … follow the same shape. Never store an instance in a bare global. + +## 7. Loading the library + +The library itself is not imported — it is a global loaded from `libs.json`: + +1. Check `core/libs.json` for the plugin (`npm`, `js`, `css`, `head`); add an entry if it is missing. +2. Preview pages declare it on the layout: `pageLibs={['nouislider', 'tom-select']}` on `DefaultLayout` / `BaseLayout`. +3. Docs pages declare it in front matter: `docs-libs: apexcharts` (and `css-plugins:` for extra `tabler-*.css`). + +A component that silently assumes a global is a broken page whenever someone forgets the prop — say which lib it needs in a frontmatter comment and in the docs page. + +## 8. Prettier caveat + +`prettier-plugin-astro` cannot parse HTML comments or `