Communitygithub.com

reyalka/astro

用于 Astro 单仓库开发的综合指南。涵盖架构、调试、测试和关键约束。在处理功能、修复、测试或理解代码库结构时使用。

astro 是什么?

Astro 开发者技能是一个上下文加载技能,专为在 Astro 单仓库中工作的 AI 智能体和开发者设计。它根据用户的任务类型(如添加核心功能、修复 Bug、编写测试或理解架构)提供相关文档的快速决策矩阵,帮助用户高效定位资源。该技能强调了关键约束和常见陷阱,例如优先使用单元测试、在 runtime/ 代码中限制 Node.js API 使用、测试隔离中设置唯一 outDir 等。除了详细描述 Astro 的架构(包括三个执行上下文和五种管道类型)以及测试哲学(优先单元测试),还提供了常用的开发命令(如 pnpm install 和 pnpm run build)和关键文件路径。用户应加载该技能以获取背景知识,然后结合具体需求阅读推荐文档,并应用其中描述的模式和命令。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/reyalka/astro/tree/HEAD/.agents/skills/astro-developer

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Astro 开发者技能

面向在 Astro 单仓库中工作的 AI 智能体和开发者的上下文加载技能。根据你的任务加载相关文档。

快速决策矩阵

你在做什么? → 阅读以下文件:

任务主要文档辅助文档
添加核心功能architecture.md, constraints.mdtesting.md
修复 Bugdebugging.mdarchitecture.md
编写/修复测试testing.mdconstraints.md
创建集成探索 packages/integrations/ 中的示例testing.md
理解架构architecture.md-
处理错误debugging.md, constraints.mdtesting.md
理解约束constraints.mdarchitecture.md

关键警告

开始之前,请注意以下常见陷阱:

  1. 优先使用单元测试:默认编写可单元测试的代码。仅当必要时使用集成测试 → testing.md
  2. Node.js API 限制:不能在 runtime/ 代码中使用 Node.js API → constraints.md
  3. 测试隔离:必须为每个集成测试设置唯一的 outDir → testing.md
  4. 运行时边界:核心 vs Vite vs 浏览器执行上下文 → architecture.md
  5. 预发布模式:Changesets 以 origin/next 分支为目标(检查 .changeset/config.json)

快速命令参考

# 开发
pnpm install                                    # 安装(仅根目录)
pnpm run build                                  # 构建所有包
pnpm run dev                                    # 监视模式
pnpm run lint                                   # 检查代码

# 测试
pnpm -C packages/astro exec astro-scripts test "test/**/*.test.js"  # 所有测试
pnpm -C packages/astro exec astro-scripts test -m "pattern"         # 过滤测试
pnpm run test:e2e                               # 端到端测试
node --test test/file.test.js                   # 单个测试

# 示例
pnpm --filter @example/minimal run dev          # 运行示例

# Changesets
pnpm exec changeset --empty                     # 创建 changeset,无交互模式

关键文件路径

packages/astro/src/
├── core/              # Node.js 执行上下文(构建/开发命令)
├── runtime/
│   ├── server/        # Vite SSR 执行上下文
│   └── client/        # 浏览器执行上下文
├── virtual-modules/   # 虚拟模块入口点
├── content/           # 内容层系统
├── vite-plugin-*/     # Vite 插件
└── types/             # 集中式 TypeScript 类型

packages/integrations/  # 官方集成
examples/              # 在这里测试你的修改
test/fixtures/         # 测试夹具

注意:node_modules/ 中的错误堆栈跟踪映射到 packages/ 中的源文件。详见 architecture.md。

使用方式

此技能用于加载相关上下文——它不协调工作流。加载适当的文档后:

  1. 阅读你任务的推荐文件
  2. 应用描述的模式和约束
  3. 使用提供的命令和文件路径
  4. 如果遇到问题,搜索错误消息的文档

架构快速总结

三个执行上下文:

  • core/ → Node.js,构建/开发命令,除了 Vite 插件外避免使用 Node API
  • runtime/server/ → Vite SSR,不能使用 Node API
  • runtime/client/ → 浏览器,完全不能使用 Node API

五种管道类型:

  • RunnablePipeline → astro dev 与 Vite 加载器系统
  • NonRunnablePipeline → astro dev 无运行时模块加载(Cloudflare 适配器)
  • BuildPipeline → astro build + 预渲染
  • AppPipeline → 生产环境无服务器/SSR
  • ContainerPipeline → 容器 API

详见 architecture.md 获取完整细节。

测试快速总结

理念:优先编写单元测试而非集成测试。默认编写可单元测试的代码。

单元测试(快速,推荐):

  • 测试纯函数和业务逻辑
  • 从基础设施中提取业务逻辑
  • 使用依赖注入

集成测试(慢速,谨慎使用):

  • 仅用于无法进行单元测试的特性(虚拟模块、完整构建管道)
  • 始终设置唯一的 outDir 以避免缓存污染

详见 testing.md 获取完整的模式和示例。

何时不使用此技能

  • Bug 分类:使用 triage 技能
  • GitHub Actions 分析:使用 analyze-github-action-logs 技能
  • 简单问题:直接提问,无需加载此技能

相关文档

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

reyalka/astro

Analyze recent GitHub Actions workflow runs to identify patterns, mistakes, and improvements. Use when asked to "analyze workflow logs", "review action runs", or "analyze GitHub Actions".

reyalka/astro

Independently implement and validate an alternative solution for an Astro pull request. Use only for Factory's adversary blue team.

reyalka/astro

Qualify and compare red and blue solutions for an Astro pull request using Astro-specific merge and tie-break criteria. Use only for Factory's adversary purple team.

reyalka/astro

Perform a static, read-only code review of an Astro pull request or of a local branch, commit range, diff, patch, or working tree being prepared as a pull request. Determine whether the change satisfies its stated business requirements and is good enough to merge, using the PR description, linked requirement issues and roadmap items, and PR or issue discussions when available. Use this skill only for PR review or self-review, not issue triage or bug investigation. It reports only merge-relevant findings and never edits code or runs project code, tests, builds, checks, or scripts.

reyalka/astro

Write and update Astro pull requests with reviewer-friendly titles and high-signal bodies. Trigger whenever the user asks to create a PR, open a PR, draft a PR, update PR title/body, or write PR notes/summary/description.

reyalka/astro

Handle main-to-next merge tasks including conflict resolution, changeset cleanup, and CI fix-ups. Use when merging main into next.

reyalka/astro

How to write JSDoc (/** */) and inline (//) comments in the Astro codebase, for contributors reading the source — not end users. Use whenever writing or editing comments in .ts/.js source, including comments added incidentally while fixing bugs or building features. Does not cover the @docs-generated config/error reference.

相关技能