incluud/astro-agent-skills

astro-best-practices

Apply performant, accessible, and maintainable defaults when building or reviewing Astro projects.

查看源码

使用方法

  1. 复制安装命令,在自己的智能体环境安装前先检查源码包。
  2. 从原始文档核对所需工具、凭据和支持的宿主。
  3. 说明输入材料与期望交付物,并对照来源检查输出。
npx skills add https://github.com/incluud/astro-agent-skills --skill astro-best-practices

开始前需了解

  • 安装不包含模型订阅、API 额度或访问文件的权限。
  • 仓库星数和安装量反映活跃情况,不等于独立质量或安全测试。
仓库原始内容

按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。

Astro Best Practices

Use this skill as the baseline when designing, implementing, or reviewing Astro work. It translates Astro-specific architectural guidance into portable instructions that can be applied across agents.

Core Principles

  • prefer static generation when request-time rendering is not necessary
  • keep client-side JavaScript minimal
  • use framework islands only for real interactivity
  • preserve clear project structure and predictable routing
  • optimize for accessibility and maintainability, not just output parity

Architecture Defaults

Prefer .astro first

  • use .astro components for static and mostly static UI
  • reach for React, Vue, or another framework only when local state or client-side behavior is genuinely needed
  • keep interactive islands small and leaf-like

Use hydration deliberately

  • client:visible for deferred UI
  • client:idle for lower-priority enhancement
  • client:load for critical immediate interactivity only
  • client:only only when skipping server rendering is intentional

Default away from hydrating broad layout regions.

Keep the project shape predictable

Typical structure:

text
src/
  components/
  layouts/
  pages/
  content/
  styles/
  assets/
public/

Do not invent novel folder structure without a clear project-specific reason.

Content and Data

  • use content collections for structured content
  • define schemas instead of accepting loose frontmatter
  • fetch server-side data in Astro frontmatter unless there is a clear reason not to
  • keep data flow obvious and close to the component or page that owns it

Accessibility

  • use semantic landmarks such as header, nav, main, article, and footer
  • ensure keyboard access for all interactive controls
  • provide meaningful labels and accessible names
  • maintain correct heading hierarchy
  • use appropriate image alt text
  • preserve visible focus states
  • treat color contrast as a non-negotiable baseline

Performance

  • use astro:assets or the project’s chosen image pipeline intentionally
  • prevent layout shift by providing image dimensions or stable containers
  • avoid unnecessary client hydration
  • keep CSS and JavaScript scoped to the features that need them
  • prefer simple server-rendered markup over client complexity

Styling

  • default to scoped component styles unless the project has a defined styling system
  • use CSS custom properties for reusable tokens
  • favor maintainable layout patterns over one-off utility sprawl when the project is not already utility-first
  • keep responsive behavior intentional and testable

Review Checklist

Before finalizing Astro work, check:

  • is any hydrated code unnecessary
  • does the HTML stay semantic
  • is the route/layout structure still clear
  • are content schemas strong enough
  • is the result accessible by keyboard and assistive tech
  • does the implementation match the existing project conventions

按任务相关推荐

来自同一仓库

更多 Skills

全部 Skills