一键导入
astro
Fast static sites with SSG/SSR and component islands. Trigger: When building Astro websites, implementing islands, or configuring SSG/SSR.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Fast static sites with SSG/SSR and component islands. Trigger: When building Astro websites, implementing islands, or configuring SSG/SSR.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Paste-ready session summary for context transfer to a new chat. Trigger: User says 'context handoff', 'start fresh', or session needs to continue.
One-at-a-time questioning to fully profile a goal before acting. Trigger: User says 'grill me', goal is vague, or clarification is needed first.
Batch execution with checkpoints. Trigger: When executing plans with batched tasks.
Universal coding principles: DRY, security by default, null guards, and YAGNI. Trigger: When writing or reviewing code in any language or technology.
Accessibility guide (WCAG 2.1/2.2, Level A–AAA). Trigger: When building UI components, interactive elements, or auditing accessibility compliance.
Astro quality patterns: island philosophy, SEO by page type, and Core Web Vitals. Trigger: When reviewing Astro site quality or hydration decisions.
| name | astro |
| description | Fast static sites with SSG/SSR and component islands. Trigger: When building Astro websites, implementing islands, or configuring SSG/SSR. |
| license | Apache 2.0 |
| metadata | {"version":"1.1","type":"framework","skills":["react","typescript"],"dependencies":{"astro":">=5.0.0 <6.0.0","typescript":">=5.0.0 <6.0.0","react":">=18.0.0 <19.0.0"}} |
Fast sites with SSG/SSR, minimal JS, TypeScript, and client island architecture.
Client island examples use React (
@astrojs/react). For Vue, Svelte, or Solid islands, replace<ReactComp client:load />with your framework's component — the directive syntax (client:load,client:visible,client:idle) is identical.
Don't use for:
Check astro.config.mjs for project type before coding.
// SSG-only (no adapter) -- default
export default defineConfig({ output: 'static' });
// SSR (has adapter)
export default defineConfig({ output: 'server', adapter: node() });
// Hybrid (SSG default, opt-in SSR per page)
export default defineConfig({ output: 'hybrid', adapter: node() });
// WRONG: Using SSR patterns (prerender: false, Astro.locals) in SSG-only project
---
interface Props { title: string; }
const { title } = Astro.props;
---
<h1>{title}</h1>
<!-- WRONG: React for static content (unnecessary JS) -->
<!-- <ReactHeader title={title} client:load /> -->
<!-- CORRECT: Only interactive components get JS -->
<Counter client:load />
<StaticContent /> <!-- No directive = zero JS -->
<!-- WRONG: Everything hydrated -->
<Header client:load />
<Footer client:load />
export async function getStaticPaths() {
const posts = await getPosts();
return posts.map((post) => ({
params: { slug: post.slug },
props: { post },
}));
}
---
export const prerender = false; // Requires adapter
const user = Astro.locals.user;
const data = await fetchUserData(user.id);
---
<h1>Welcome, {user.name}</h1>
// astro.config.mjs
// SSG (default): all pages pre-rendered at build
export default defineConfig({ output: 'static' });
// SSR: all pages server-rendered
export default defineConfig({ output: 'server', adapter: node() });
// Hybrid: SSG default, opt-in SSR per page
export default defineConfig({ output: 'hybrid', adapter: node() });
No adapter (SSG-only)?
→ see ssg-patterns.md
Has adapter + output: 'server'?
→ see ssr-patterns.md
Has adapter + output: 'hybrid'?
→ see hybrid-strategies.md
Adding interactivity?
→ see client-directives.md
Managing content (blog, docs)?
→ see content-collections.md
Building forms?
→ see actions.md
Smooth page transitions or faster navigation?
→ see client-navigation.md
Auth or request logging?
→ see middleware.md
API keys or secrets?
→ see env-variables.md
Dynamic routes with known paths?
→ getStaticPaths (SSG)
Dynamic routes with user data?
→ prerender: false (SSR)
Immediate interaction?
→ client:load
Below fold interaction?
→ client:visible
Non-critical interaction?
→ client:idle
---
// src/pages/blog/[slug].astro
interface Props { post: { title: string; content: string }; }
export async function getStaticPaths() {
const posts = await getPosts();
return posts.map((post) => ({ params: { slug: post.slug }, props: { post } }));
}
const { post } = Astro.props;
---
<article>
<h1>{post.title}</h1>
<div set:html={post.content} />
</article>
---
// src/pages/dashboard.astro
export const prerender = false;
const user = Astro.locals.user;
const data = await fetchUserData(user.id);
---
<h1>Welcome, {user.name}</h1>
<p>Last login: {data.lastLogin}</p>
// astro.config.mjs
import { defineConfig } from "astro/config";
import node from "@astrojs/node";
export default defineConfig({
output: "hybrid",
adapter: node({ mode: "standalone" }),
});
// index.astro -> SSG (default)
// profile.astro -> SSR (export const prerender = false)
prerender: false/Astro.locals/POST fail build.output: 'server'/'hybrid'.prerender: false (routes render on request).prerender: false only for SSR.PUBLIC_ prefix for client-side, no prefix for server.'hybrid', add prerender: false per page.astro.config.mjs before writing code.astro components used by default; React only for interactivityclient:load, client:visible, client:idle)getStaticPaths used for dynamic SSG routesprerender: false only on SSR pages with adapter installed