{"id":"60febcb7-7f8c-4ef4-8400-91a1741b9b1d","shortId":"BDWyj5","kind":"skill","title":"astro","tagline":"Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.","description":"# Astro Web Framework\n\n## Overview\n\nAstro is a web framework designed for content-rich websites — blogs, docs, portfolios, marketing sites, and e-commerce. Its core innovation is the **Islands Architecture**: by default, Astro ships zero JavaScript to the browser. Interactive components are selectively hydrated as isolated \"islands.\" Astro supports React, Vue, Svelte, Solid, and other UI frameworks simultaneously in the same project, letting you pick the right tool per component.\n\n## When to Use This Skill\n\n- Use when building a blog, documentation site, marketing page, or portfolio\n- Use when performance and Core Web Vitals are the top priority\n- Use when the project is content-heavy with Markdown or MDX files\n- Use when you want SSG (static) output with optional SSR for dynamic routes\n- Use when the user asks about `.astro` files, `Astro.props`, content collections, or `client:` directives\n\n## How It Works\n\n### Step 1: Project Setup\n\n```bash\nnpm create astro@latest my-site\ncd my-site\nnpm install\nnpm run dev\n```\n\nAdd integrations as needed:\n\n```bash\nnpx astro add tailwind        # Tailwind CSS\nnpx astro add react           # React component support\nnpx astro add mdx             # MDX support\nnpx astro add sitemap         # Auto sitemap.xml\nnpx astro add vercel          # Vercel SSR adapter\n```\n\nProject structure:\n\n```\nsrc/\n  pages/          ← File-based routing (.astro, .md, .mdx)\n  layouts/        ← Reusable page shells\n  components/     ← UI components (.astro, .tsx, .vue, etc.)\n  content/        ← Type-safe content collections (Markdown/MDX)\n  styles/         ← Global CSS\npublic/           ← Static assets (copied as-is)\nastro.config.mjs  ← Framework config\n```\n\n### Step 2: Astro Component Syntax\n\n`.astro` files have a code fence at the top (server-only) and a template below:\n\n```astro\n---\n// src/components/Card.astro\n// This block runs on the server ONLY — never in the browser\ninterface Props {\n  title: string;\n  href: string;\n  description: string;\n}\n\nconst { title, href, description } = Astro.props;\n---\n\n<article class=\"card\">\n  <h2><a href={href}>{title}</a></h2>\n  <p>{description}</p>\n</article>\n\n<style>\n  /* Scoped to this component automatically */\n  .card { border: 1px solid #eee; padding: 1rem; }\n</style>\n```\n\n### Step 3: File-Based Pages and Routing\n\n```\nsrc/pages/index.astro          → /\nsrc/pages/about.astro          → /about\nsrc/pages/blog/[slug].astro    → /blog/:slug (dynamic)\nsrc/pages/blog/[...path].astro → /blog/* (catch-all)\n```\n\nDynamic route with `getStaticPaths`:\n\n```astro\n---\n// src/pages/blog/[slug].astro\nexport async function getStaticPaths() {\n  const posts = await getCollection('blog');\n  return posts.map(post => ({\n    params: { slug: post.slug },\n    props: { post },\n  }));\n}\n\nconst { post } = Astro.props;\nconst { Content } = await post.render();\n---\n\n<h1>{post.data.title}</h1>\n<Content />\n```\n\n### Step 4: Content Collections\n\nContent collections give you type-safe access to Markdown and MDX files:\n\n```typescript\n// src/content/config.ts\nimport { z, defineCollection } from 'astro:content';\n\nconst blog = defineCollection({\n  type: 'content',\n  schema: z.object({\n    title: z.string(),\n    date: z.coerce.date(),\n    tags: z.array(z.string()).default([]),\n    draft: z.boolean().default(false),\n  }),\n});\n\nexport const collections = { blog };\n```\n\n```astro\n---\n// src/pages/blog/index.astro\nimport { getCollection } from 'astro:content';\n\nconst posts = (await getCollection('blog'))\n  .filter(p => !p.data.draft)\n  .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());\n---\n\n<ul>\n  {posts.map(post => (\n    <li>\n      <a href={`/blog/${post.slug}`}>{post.data.title}</a>\n      <time>{post.data.date.toLocaleDateString()}</time>\n    </li>\n  ))}\n</ul>\n```\n\n### Step 5: Islands — Selective Hydration\n\nBy default, UI framework components render to static HTML with no JS. Use `client:` directives to hydrate:\n\n```astro\n---\nimport Counter from '../components/Counter.tsx';  // React component\nimport VideoPlayer from '../components/VideoPlayer.svelte';\n---\n\n<!-- Static HTML — no JavaScript sent to browser -->\n<Counter initialCount={0} />\n\n<!-- Hydrate immediately on page load -->\n<Counter initialCount={0} client:load />\n\n<!-- Hydrate when the component scrolls into view -->\n<VideoPlayer src=\"/demo.mp4\" client:visible />\n\n<!-- Hydrate only when browser is idle -->\n<Analytics client:idle />\n\n<!-- Hydrate only on a specific media query -->\n<MobileMenu client:media=\"(max-width: 768px)\" />\n```\n\n### Step 6: Layouts\n\n```astro\n---\n// src/layouts/BaseLayout.astro\ninterface Props {\n  title: string;\n  description?: string;\n}\nconst { title, description = 'My Astro Site' } = Astro.props;\n---\n\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\" />\n    <title>{title}</title>\n    <meta name=\"description\" content={description} />\n  </head>\n  <body>\n    <nav>...</nav>\n    <main>\n      <slot />  <!-- page content renders here -->\n    </main>\n    <footer>...</footer>\n  </body>\n</html>\n```\n\n```astro\n---\n// src/pages/about.astro\nimport BaseLayout from '../layouts/BaseLayout.astro';\n---\n\n<BaseLayout title=\"About Us\">\n  <h1>About Us</h1>\n  <p>Welcome to our company...</p>\n</BaseLayout>\n```\n\n### Step 7: SSR Mode (On-Demand Rendering)\n\nEnable SSR for dynamic pages by setting an adapter:\n\n```javascript\n// astro.config.mjs\nimport { defineConfig } from 'astro/config';\nimport vercel from '@astrojs/vercel/serverless';\n\nexport default defineConfig({\n  output: 'hybrid',  // 'static' | 'server' | 'hybrid'\n  adapter: vercel(),\n});\n```\n\nOpt individual pages into SSR with `export const prerender = false`.\n\n## Examples\n\n### Example 1: Blog with RSS Feed\n\n```typescript\n// src/pages/rss.xml.ts\nimport rss from '@astrojs/rss';\nimport { getCollection } from 'astro:content';\n\nexport async function GET(context) {\n  const posts = await getCollection('blog');\n  return rss({\n    title: 'My Blog',\n    description: 'Latest posts',\n    site: context.site,\n    items: posts.map(post => ({\n      title: post.data.title,\n      pubDate: post.data.date,\n      link: `/blog/${post.slug}/`,\n    })),\n  });\n}\n```\n\n### Example 2: API Endpoint (SSR)\n\n```typescript\n// src/pages/api/subscribe.ts\nimport type { APIRoute } from 'astro';\n\nexport const POST: APIRoute = async ({ request }) => {\n  const { email } = await request.json();\n\n  if (!email) {\n    return new Response(JSON.stringify({ error: 'Email required' }), {\n      status: 400,\n      headers: { 'Content-Type': 'application/json' },\n    });\n  }\n\n  await addToNewsletter(email);\n  return new Response(JSON.stringify({ success: true }), { status: 200 });\n};\n```\n\n### Example 3: React Component as Island\n\n```tsx\n// src/components/SearchBox.tsx\nimport { useState } from 'react';\n\nexport default function SearchBox() {\n  const [query, setQuery] = useState('');\n  const [results, setResults] = useState([]);\n\n  async function search(e: React.FormEvent) {\n    e.preventDefault();\n    const data = await fetch(`/api/search?q=${query}`).then(r => r.json());\n    setResults(data);\n  }\n\n  return (\n    <form onSubmit={search}>\n      <input value={query} onChange={e => setQuery(e.target.value)} />\n      <button type=\"submit\">Search</button>\n      <ul>{results.map(r => <li key={r.id}>{r.title}</li>)}</ul>\n    </form>\n  );\n}\n```\n\n```astro\n---\nimport SearchBox from '../components/SearchBox.tsx';\n---\n<!-- Hydrated immediately — this island is interactive -->\n<SearchBox client:load />\n```\n\n## Best Practices\n\n- ✅ Keep most components as static `.astro` files — only hydrate what must be interactive\n- ✅ Use content collections for all Markdown/MDX content — you get type safety and auto-validation\n- ✅ Prefer `client:visible` over `client:load` for below-the-fold components to reduce initial JS\n- ✅ Use `import.meta.env` for environment variables — prefix public vars with `PUBLIC_`\n- ✅ Add `<ViewTransitions />` from `astro:transitions` for smooth page navigation without a full SPA\n- ❌ Don't use `client:load` on every component — this defeats Astro's performance advantage\n- ❌ Don't put secrets in `.astro` frontmatter that gets used in client-facing templates\n- ❌ Don't skip `getStaticPaths` for dynamic routes in static mode — builds will fail\n\n## Security & Safety Notes\n\n- Frontmatter code in `.astro` files runs server-side only and is never exposed to the browser.\n- Use `import.meta.env.PUBLIC_*` only for non-sensitive values. Private env vars (no `PUBLIC_` prefix) are never sent to the client.\n- When using SSR mode, validate all `Astro.request` inputs before database queries or API calls.\n- Sanitize any user-supplied content before rendering with `set:html` — it bypasses auto-escaping.\n\n## Common Pitfalls\n\n- **Problem:** JavaScript from a React/Vue component doesn't run in the browser\n  **Solution:** Add a `client:` directive (`client:load`, `client:visible`, etc.) — without it, components render as static HTML only.\n\n- **Problem:** `getStaticPaths` data is stale after content updates during dev\n  **Solution:** Astro's dev server watches content files — restart if changes to `content/config.ts` are not reflected.\n\n- **Problem:** `Astro.props` type is `any` — no autocomplete\n  **Solution:** Define a `Props` interface or type in the frontmatter and Astro will infer it automatically.\n\n- **Problem:** CSS from a `.astro` component bleeds into other components\n  **Solution:** Styles in `.astro` `<style>` tags are automatically scoped. Use `:global()` only when intentionally targeting children.\n\n## Related Skills\n\n- `@sveltekit` — When you need a full-stack framework with reactive UI (vs Astro's content focus)\n- `@nextjs-app-router-patterns` — When you need a React-first full-stack framework\n- `@tailwind-patterns` — Styling Astro sites with Tailwind CSS\n- `@progressive-web-app` — Adding PWA capabilities to an Astro site\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["astro","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity-skills"],"capabilities":["skill","source-sickn33","skill-astro","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/astro","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34964 github stars · SKILL.md body (10,092 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-25T00:50:28.638Z","embedding":null,"createdAt":"2026-04-18T21:31:30.334Z","updatedAt":"2026-04-25T00:50:28.638Z","lastSeenAt":"2026-04-25T00:50:28.638Z","tsv":"'/about':325 '/api/search':703 '/blog':329,335,444,618 '/components/counter.tsx':474 '/components/searchbox.tsx':733 '/components/videoplayer.svelte':480 '/layouts/baselayout.astro':518 '0':483,486 '1':164,574 '2':264,621 '200':668 '3':316,670 '4':373 '400':652 '5':449 '6':490 '7':526 'a.data.date.valueof':439 'access':383 'adapt':220,541,560 'add':184,191,197,204,210,216,790,929 'addtonewslett':659 'advantag':815 'api':622,896 'apirout':629,635 'application/json':657 'architectur':14,52 'as-i':257 'ask':150 'asset':255 'astro':1,8,22,26,55,70,152,170,190,196,203,209,215,229,239,265,268,284,328,334,343,346,395,420,425,470,492,504,513,588,631,729,741,792,812,821,850,957,990,999,1008 'astro.config.mjs':260,543 'astro.props':154,309,366,506,973 'astro.request':890 'astro/config':547 'astrojs/rss':584 'astrojs/vercel/serverless':551 'async':348,591,636,693 'auto':212,762,912 'auto-escap':911 'auto-valid':761 'autocomplet':978 'automat':994 'await':353,369,429,597,640,658,701 'b':437 'b.data.date.valueof':438 'base':227,319 'baselayout':516 'bash':167,188 'below-the-fold':771 'best':734 'bleed':1001 'block':287 'blog':37,102,355,398,419,431,575,599,604 'browser':61,296,863,927 'build':2,100,841 'bypass':910 'call':897 'catch':337 'catch-al':336 'cd':175 'chang':966 'client':158,466,487,765,768,805,828,883,931,933,935 'client-fac':827 'code':272,848 'collect':156,248,375,377,418,751 'commerc':45 'common':914 'compani':524 'compon':18,63,92,200,236,238,266,457,476,672,738,775,809,921,940,1000,1004 'config':262 'const':305,351,364,367,397,417,427,500,569,595,633,638,685,689,699 'content':4,34,126,155,243,247,368,374,376,396,401,426,511,589,655,750,755,903,952,962 'content-focus':3 'content-heavi':125 'content-rich':33 'content-typ':654 'content/config.ts':968 'context':594 'context.site':609 'copi':256 'core':47,113 'counter':472,481,484 'creat':169 'css':194,252,996 'data':700,710,948 'databas':893 'date':406 'default':12,54,411,414,454,553,682 'defeat':811 'defin':980 'definecollect':393,399 'defineconfig':545,554 'demand':531 'descript':303,308,314,498,502,510,512,605 'design':31 'dev':183,955,959 'direct':159,467,932 'doc':38 'document':103 'doesn':922 'draft':412 'dynam':144,331,339,536,836 'e':44,696,719 'e-commerc':43 'e.preventdefault':698 'e.target.value':721 'email':639,643,649,660 'enabl':533 'endpoint':623 'env':873 'environ':783 'error':648 'escap':913 'etc':242,937 'everi':808 'exampl':572,573,620,669 'export':347,416,552,568,590,632,681 'expos':860 'face':829 'fail':843 'fals':415,571 'feed':578 'fenc':273 'fetch':702 'file':132,153,226,269,318,388,742,851,963 'file-bas':225,317 'filter':432 'focus':5 'fold':774 'form':712 'framework':17,24,30,79,261,456 'frontmatt':822,847,988 'full':800 'function':349,592,683,694 'get':593,757,824 'getcollect':354,423,430,586,598 'getstaticpath':342,350,834,947 'give':378 'global':251 'header':653 'heavi':127 'href':301,307,311,312,443 'html':461,908,944 'hybrid':556,559 'hydrat':66,452,469,744 'import':391,422,471,477,515,544,548,581,585,627,677,730 'import.meta.env':781 'import.meta.env.public':865 'individu':563 'infer':992 'initi':778 'initialcount':482,485 'innov':48 'input':715,891 'instal':180 'integr':185 'interact':62,748 'interfac':297,494,983 'island':13,51,69,450,674 'isol':68 'item':610 'javascript':58,542,917 'js':10,464,779 'json.stringify':647,664 'keep':736 'key':726 'latest':171,606 'layout':232,491 'let':85 'li':725 'link':617 'load':488,769,806,934 'markdown':129,385 'markdown/mdx':20,249,754 'market':40,105 'md':230 'mdx':131,205,206,231,387 'meta':508 'mode':528,840,887 'multi':16 'multi-framework':15 'must':746 'my-sit':172,176 'name':509 'navig':797 'need':187 'never':293,859,879 'new':645,662 'non':869 'non-sensit':868 'note':846 'npm':168,179,181 'npx':189,195,202,208,214 'on-demand':529 'onchang':718 'onsubmit':713 'opt':562 'option':141 'output':139,555 'overview':25 'p':433 'p.data.draft':434 'page':106,224,234,320,537,564,796 'param':359 'path':333 'per':91 'perform':111,814 'pick':87 'pitfal':915 'portfolio':39,108 'post':352,358,363,365,428,441,596,607,612,634 'post.data.date':616 'post.data.date.tolocaledatestring':447 'post.data.title':371,446,614 'post.render':370 'post.slug':361,445,619 'posts.map':357,440,611 'practic':735 'prefer':764 'prefix':785,877 'prerend':570 'prioriti':119 'privat':872 'problem':916,946,972,995 'project':84,123,165,221 'prop':298,362,495,982 'pubdat':615 'public':253,786,789,876 'put':818 'q':704 'queri':686,705,717,894 'r':707,724 'r.id':727 'r.json':708 'r.title':728 'react':72,198,199,475,671,680 'react.formevent':697 'react/vue':920 'reduc':777 'reflect':971 'render':458,532,905,941 'request':637 'request.json':641 'requir':650 'respons':646,663 'restart':964 'result':690 'results.map':723 'return':356,600,644,661,711 'reusabl':233 'rich':35 'right':89 'rout':145,228,322,340,837 'rss':577,582,601 'run':182,288,852,924 'safe':246,382 'safeti':759,845 'sanit':898 'schema':402 'search':695,714,722 'searchbox':684,731 'secret':819 'secur':844 'select':65,451 'sensit':870 'sent':880 'server':278,291,558,854,960 'server-on':277 'server-sid':853 'set':539,907 'setqueri':687,720 'setresult':691,709 'setup':166 'shell':235 'ship':56 'side':855 'simultan':80 'site':41,104,174,178,505,608 'sitemap':211 'sitemap.xml':213 'skill':97 'skill-astro' 'skip':833 'slug':327,330,345,360 'smooth':795 'solid':75 'solut':928,956,979,1005 'sort':435 'source-sickn33' 'spa':801 'src':223 'src/components/card.astro':285 'src/components/searchbox.tsx':676 'src/content/config.ts':390 'src/layouts/baselayout.astro':493 'src/pages/about.astro':324,514 'src/pages/api/subscribe.ts':626 'src/pages/blog':326,332,344 'src/pages/blog/index.astro':421 'src/pages/index.astro':323 'src/pages/rss.xml.ts':580 'ssg':137 'ssr':142,219,527,534,566,624,886 'stale':950 'static':138,254,460,557,740,839,943 'status':651,667 'step':163,263,315,372,448,489,525 'string':300,302,304,497,499 'structur':222 'style':250,1006 'success':665 'suppli':902 'support':21,71,201,207 'svelt':74 'syntax':267 'tag':408 'tailwind':192,193 'templat':282,830 'titl':299,306,313,404,496,501,507,602,613 'tool':90 'top':118,276 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'transit':793 'true':666 'tsx':240,675 'type':245,381,400,628,656,758,974,985 'type-saf':244,380 'typescript':389,579,625 'ui':78,237,455 'updat':953 'us':520 'use':95,98,109,120,133,146,465,749,780,804,825,864,885 'user':149,901 'user-suppli':900 'usest':678,688,692 'valid':763,888 'valu':716,871 'var':787,874 'variabl':784 'vercel':217,218,549,561 'videoplay':478 'visibl':766,936 'vital':115 'vue':73,241 'want':136 'watch':961 'web':23,29,114 'websit':6,36 'welcom':521 'without':798,938 'work':162 'z':392 'z.array':409 'z.boolean':413 'z.coerce.date':407 'z.object':403 'z.string':405,410 'zero':9,57","prices":[{"id":"fbd1747e-8ef3-43dd-84ce-e959bf6d65dc","listingId":"60febcb7-7f8c-4ef4-8400-91a1741b9b1d","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:31:30.334Z"}],"sources":[{"listingId":"60febcb7-7f8c-4ef4-8400-91a1741b9b1d","source":"github","sourceId":"sickn33/antigravity-awesome-skills/astro","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/astro","isPrimary":false,"firstSeenAt":"2026-04-18T21:31:30.334Z","lastSeenAt":"2026-04-25T00:50:28.638Z"}],"details":{"listingId":"60febcb7-7f8c-4ef4-8400-91a1741b9b1d","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"astro","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34964,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-24T06:41:17Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"fbff1117f6d4d57c95041b22526d4e9d47e328e6","skill_md_path":"skills/astro/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/astro"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"astro","description":"Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support."},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/astro"},"updatedAt":"2026-04-25T00:50:28.638Z"}}