Astro - Advanced Developer — Astro工具
v1.0.0[AI辅助] Comprehensive skill for building, configuring, and troubleshooting Astro projects. Use this skill whenever the user mentions Astro, .astro files, Astro confi...
详细分析 ▾
运行时依赖
版本
Astro Advanced Skill v1.0.0 - Introduces comprehensive guidance for building, configuring, and troubleshooting Astro projects. - Covers project setup, rendering strategies (SSG/SSR/hybrid), adapters, and framework integrations. - Includes best practices for SEO, layouts, content collections, performance, and SSR caching. - Features a step-by-step decision tree for common Astro scenarios and mistakes. - Provides clear troubleshooting tips for issues like hydration mismatches and build/deploy errors.
安装命令 点击复制
技能文档
), or island architecture concepts. This skill covers project setup, rendering modes (SSG/SSR/hybrid), SSR caching, SEO, layouts, templates, Vue island integration, content collections, data fetching, deployment, auth, performance, and troubleshooting.
# Astro Advanced Skill
This skill provides production-grade guidance for Astro projects — from initial scaffolding through deployment, caching, and performance tuning. It covers the patterns that actually matter in real projects and the mistakes that actually happen.
如何 到 使用 skill
- 读取 file 第一个 对于 core workflow 和 decision tree.
- Consult reference files 在...中
references/对于 deep dives 在...上 specific topics:
references/setup-和-structure.md — Project creation, file structure, 配置, adapters
- references/rendering-modes.md — SSG vs SSR vs Hybrid, 当...时 到 使用 每个, caching strategies
- references/seo.md — Meta tags, 打开 图形, JSON-LD, sitemaps, canonical URLs
- references/islands-和-vue.md — Island architecture, client directives, Vue/React/Svelte integration
- references/content-和-data.md — Content collections, data fetching, dynamic routes
- references/deployment.md — Adapters, static hosts, serverless, environment variables
- references/performance.md — Image optimization, bundle analysis, hydration control
- references/troubleshooting.md — Common errors 和 fixes organized 由 symptomCore decision tree
When helping with an Astro project, follow this sequence:
1. Identify rendering strategy 第一个
This is the single most important decision in any Astro project. Everything else flows from it.- Pure static site (blog, docs, marketing)? → SSG (默认). 否 adapter needed.
- Needs 用户-specific data, auth, 或 real-时间 content? → SSR 带有 adapter.
- Mostly static 但是 few dynamic pages? → Hybrid mode. 设置
输出: 'static'在...中 配置 和 使用导出 const prerender = 假在...上 dynamic pages.
2. Pick right adapter
Only needed for SSR or hybrid:- Vercel →
@astrojs/vercel(serverless 或 edge) - Netlify →
@astrojs/netlify - Cloudflare Pages →
@astrojs/cloudflare - Self-hosted 节点 →
@astrojs/节点(standalone 或 中间件)
3. 设置 up integrations
Add only what you need. Each integration is a potential build-time dependency:# Common additions
npx astro add vue # Vue islands
npx astro add tailwind # Tailwind CSS
npx astro add mdx # MDX support
npx astro add sitemap # Auto sitemap generation
4. Establish content strategy
- Few pages, hand-authored → Regular
.astropages 在...中/src/pages - Blog/docs 带有 structured content → Content collections 带有 Zod schemas
- CMS-driven → 获取 在 build 时间 (SSG) 或 runtime (SSR)
5. Apply SEO 从 开始
Don't bolt it on later. Seereferences/seo.md for the full pattern, but at minimum:
- 创建 reusable
组件 对于 head tags - 设置 up canonical URLs
- 添加 structured data (JSON-LD) 对于 键 pages
- Generate sitemap 通过
@astrojs/sitemap
键 patterns 到 always 关注
布局 pattern
Every page should use a layout. Layouts handle, , and shared chrome:---
// src/layouts/Base.astro
import SEO from '../components/SEO.astro';
const { title, description } = Astro.props;
Island pattern
Static by default. Only hydrate what needs interactivity:
#1 Astro mistake: forgetting client: 在...上 组件 needs interactivity,
then wondering why click handlers don't work.
SSR caching pattern
SSR without caching is just a slow website. Always pair SSR with a caching strategy:// In an SSR endpoint or page
return new Response(JSON.stringify(data), {
headers: {
"Cache-Control": "public, s-maxage=60, stale-while-revalidate=300",
"Content-Type": "application/json"
}
});
当...时 things go wrong
Read references/troubleshooting.md for a symptom-based guide. The top 5 issues:
- "组件 doesn't 做 anything" → Missing
client:directive - Build fails 之后 adding integration → Version mismatch, check
包.json - SSR returns 500 → Missing adapter 或 wrong
输出mode 在...中 配置 - Broken links 之后 deploy → Base path 不 设置, 或 trailing slash mismatch
- Hydration mismatch errors → Server/client HTML differs (conditional rendering, dates, randomness)
File 输出 conventions
When generating Astro project files:
- Always include frontmatter fence (
---) 甚至 如果 空 - 使用
.astro扩展 对于 Astro components 和 pages - Place pages 在...中
src/pages/, components 在...中src/components/, layouts 在...中src/layouts/ - 使用 TypeScript 在...中 frontmatter 当...时 project uses TS
- Include
astro.配置.mjs带有 仅 integrations 和 settings actually needed
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制