← ClaudeAtlas

astro-best-practiceslisted

This skill should be used when working on any Astro project or when the user asks about Astro best practices, conventions, or patterns. Trigger when: working on an Astro project, creating Astro components/pages/layouts, configuring astro.config, setting up Content Collections, using Content Layer API, choosing client directives (client:load/idle/visible/media/only), using server:defer or server islands, deciding between SSR and SSG, working with Astro Actions for forms, configuring middleware, using Zod schemas for content, building with TypeScript in Astro, creating API endpoints, using @astro/autoload, working with .astro files, Astro 5 or Astro 6 development.
radesjardins/RAD-Claude-Skills · ★ 3 · Web & Frontend · score 76
Install: claude install-skill radesjardins/RAD-Claude-Skills
# Astro: Core Architecture & Best Practices ## Core Philosophy Astro is content-first and ships ZERO JavaScript by default. Internalize this before writing any code. Assume every component renders as plain HTML unless interactivity is strictly necessary — only opt in to JavaScript through explicit client directives when state or event handling is required. Astro uses a Multi-Page Application (MPA) mindset, not a Single-Page Application (SPA) mindset. Do not attempt to replicate SPA patterns like global client-side state stores or full-page client-side routing unless explicitly asked. Understand the strict separation of environments: build-time (Content Layer fetches and transforms data), server-time (SSR endpoints, Server Islands, middleware), and browser-time (Client Islands, `<script>` tags). Never mix these boundaries. Data flows downward: build-time or server-time code produces HTML and passes serializable props to client components. The browser never calls `getCollection()` or accesses `Astro.locals`. ## Component Model Every `.astro` file has two regions: the frontmatter fence (`---`) and the template below it. The frontmatter is SERVER-ONLY code that runs at build time or request time. Use it to import components, fetch data, define variables, and destructure props. Never access `window`, `document`, `localStorage`, or any browser API in frontmatter — doing so causes `document is not defined` or `window is not defined` errors. Client-side JavaScript belongs in `<