astro
Assists with building content-driven websites using Astro's island architecture. Use when creating static sites, blogs, documentation, or marketing pages that ship zero JavaScript by default. Trigger words: astro, static site, island architecture, content collections, SSG, hybrid rendering, astro components.
Usage
Getting Started
- Install the skill using the command above
- Open your AI coding agent (Claude Code, Codex, Gemini CLI, or Cursor)
- Reference the skill in your prompt
- The AI will use the skill's capabilities automatically
Example Prompts
- "Review the open pull requests and summarize what needs attention"
- "Generate a changelog from the last 20 commits on the main branch"
Documentation
Overview
Astro is a web framework for building content-driven websites that ships zero JavaScript by default. Its island architecture hydrates only interactive components, achieving excellent Lighthouse scores while supporting React, Vue, Svelte, or any UI framework where interactivity is needed.
Instructions
- When creating pages, use file-based routing in
src/pages/with.astro,.md, or.mdxfiles, and organize shared structure insrc/layouts/. - When adding interactivity, use client directives on framework components: prefer
client:visibleorclient:idleoverclient:loadsince most components do not need immediate hydration. - When managing content, define Content Collections in
src/content/with strict Zod schemas usingdefineCollection(), and query withgetCollection()andgetEntry(). - When choosing rendering modes, default to static (SSG) for marketing and content pages, use
output: "server"for dynamic pages, or use hybrid rendering with per-pageexport const prerender = false. - When optimizing images, use the
<Image>component fromastro:assetsfor automatic format conversion (WebP/AVIF), resizing, and lazy loading instead of raw<img>tags. - When adding page transitions, enable View Transitions with
<ViewTransitions />for SPA-like navigation without shipping a client-side router. - When integrating UI frameworks, install the appropriate integration (
@astrojs/react,@astrojs/vue,@astrojs/svelte) and use Astro components for static content, reaching for framework components only when interactivity is required.
Examples
Example 1: Build a blog with Content Collections
User request: "Create an Astro blog with type-safe Markdown content"
Actions:
- Define a blog Content Collection with Zod schema for frontmatter (title, date, tags, author)
- Create dynamic route
src/pages/blog/[slug].astrowithgetStaticPaths() - Build blog index page querying
getCollection("blog")with sorting - Add layout with SEO meta tags, navigation, and View Transitions
Output: A statically generated blog with validated content, clean URLs, and smooth page transitions.
Example 2: Add interactive components to a static site
User request: "Add a React search component to my Astro documentation site"
Actions:
- Install
@astrojs/reactintegration - Create the React search component with state and event handling
- Add the component to the page with
client:idledirective - Pass static data as props from the Astro page frontmatter
Output: A documentation site that is fully static except for the interactive search island.
Guidelines
- Use Astro components (
.astro) for static content; only use React/Vue/Svelte when interactivity is needed. - Default to
client:visibleorclient:idleoverclient:loadfor hydration directives. - Define Content Collections with strict Zod schemas to catch content errors at build time.
- Use
astro:assets<Image>over raw<img>tags for automatic optimization. - Keep layouts thin with shared
<head>, navigation, and footer; put page-specific content in pages. - Use hybrid rendering: static for marketing pages, SSR only for personalized or dynamic pages.
- Enable View Transitions for SPA-like navigation without shipping a router.
Information
- Version
- 1.0.0
- Author
- terminal-skills
- Category
- Development
- License
- Apache-2.0