AGENTS.md — Astro
- Default to zero client-side JavaScript: Astro renders components to HTML & CSS and strips JS.
- A
.astrofile = component script in a---fence (runs at build/server time, stripped from output) + an HTML template with{ }expressions. - Read props from
Astro.props; type them withinterface Props. Use<slot />and named slots for composition. - Add interactivity only as islands: framework components marked with a
client:*directive ship JS, nothing else does. - Choose the lightest directive:
client:load(immediate),client:idle(browser idle),client:visible(in viewport),client:media={QUERY},client:only="framework"(client-only render). - No directive means the framework component renders to static HTML with no JS — keep it that way unless interactivity is required.
- Plain
.astrocomponents cannot takeclient:*; only framework components hydrate. Useserver:deferfor dynamic server islands. - Only Astro components can combine multiple UI frameworks; framework components cannot import
.astrofiles. - Props to a hydrated island must be serialisable (no functions). Pass children via
children(React/Preact/Solid) or<slot />(Svelte/Vue). - Store structured content in content collections, outside
src/pages/. - Define collections in
src/content.config.tswithdefineCollection(), a loader (glob()/file()), and a Zodschemafor type-safe frontmatter. - Query collections with
getCollection()/getEntry()and render entries withawait render(entry)(the{ Content }it returns), all fromastro:content. - Don't add
client:*to non-interactive UI, pass functions as island props, or skip the collection schema.